diff --git a/CHANGELOG.md b/CHANGELOG.md index bae566c..86b5792 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ remains unsupported. - Extended the read-only RDNA2 planning CLI (`python3 -m qa rdna2`) with family/status filters, compact summaries, Codex-ready manifests under `artifacts/`, active-claim exclusion (family claims exclude those families; path-only claims block overlapping permitted files), coverage reconcile against `semantic_coverage` without inflating counts, and inventory diffs. Covered by `tests/qa/test_rdna2_plan.py`; planning only, no GPU production edits. ### Fixed +- The import metadata classified `GetCurrentProcess`, `GetCurrentProcessId`, `GetCurrentThread`, `GetCurrentThreadId`, `GetThreadPriority` and `SetThreadPriority` on `kernel32.dll` and `api-ms-win-core-processthreads-l1-1-0.dll` as stubs although the runtime provides them, so the import generator would have emitted stubs for working services. - Removed the unused Linux `AT_EMPTY_PATH` unlink path from host-backed drives and corrected docs/changelog claims: removal is name-based on every host, with the in-mount check-then-unlink race against trusted host writers stated plainly. - Made the native semantic-review timeout in `scripts/test-gpu.sh` configurable with `XENORA_SEMANTIC_TIMEOUT` and raised its default from 120 to 300 seconds, so cold Apple Silicon runs do not fail while the expanded Metal known-answer suite is still progressing. - Added a Python 3 fallback for `timeout` in `scripts/test-gpu.sh`, so the native Metal suite runs on stock macOS without GNU coreutils while preserving bounded execution and the usual timeout exit status. @@ -34,6 +35,7 @@ remains unsupported. - Winsock `ioctlsocket` with `FIONREAD` (unread stream bytes or next datagram size) and `FIONBIO` for non-blocking mode; requesting blocking mode returns `WSAEOPNOTSUPP` because loopback sockets never block. - XInput controller services (`XInputGetState`, `XInputSetState`, `XInputGetCapabilities`, `XInputEnable`) on `xinput1_4.dll`, `xinput1_3.dll` and `xinput9_1_0.dll`, fed by a host-connected controller source. Tests use a simulated controller; no physical controller or app input path is connected yet. - C++ `type_info` helpers on `vcruntime140.dll`: equality, ordering and hashing by decorated name, and readable names for plain class, struct, union and enum types. Unsupported decorations such as templates stop the guest rather than return a wrong name. +- `xenora imports coverage` writes a deterministic report of every standard runtime service by module and status, and lists where the import metadata disagrees with the registry. - Process-local Winsock TCP loopback: `listen`, `accept`, stream `connect`, `send`, `recv` and `shutdown` between guest sockets on 127.0.0.1, with 64 KiB of buffering per socket, end of file on shutdown or close, `WSAECONNRESET` after the peer closes, `POLLHUP` from `WSAPoll`, and separate TCP and UDP port spaces. No host socket is opened. Translated guest tests cover streaming, flow control, shutdown, closing, refusal and external-address rejection. - `MoveFileExW` on host mounts and the synthetic C: drive, with `MOVEFILE_REPLACE_EXISTING` (atomic replacement of a closed file, as in the write-then-replace save pattern), `MOVEFILE_WRITE_THROUGH` (flushes both host directories) and `MOVEFILE_COPY_ALLOWED`. Directories are never replaced, open files cannot be moved or replaced, and moves between drives report `ERROR_NOT_SAME_DEVICE` or, when a copy is allowed, `ERROR_NOT_SUPPORTED`. - `MoveFileW` renames closed files and directories within one writable host mount, including changes of case only. It uses an exclusive host rename (`renameatx_np` with `RENAME_EXCL` on macOS), so an existing name is never replaced. Moves between drives and of open files fail explicitly. A translated guest test covers renames, collisions, confinement and errors. diff --git a/crates/cli/src/coverage.rs b/crates/cli/src/coverage.rs new file mode 100644 index 0000000..5c5f65f --- /dev/null +++ b/crates/cli/src/coverage.rs @@ -0,0 +1,185 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +//! `xenora imports coverage`: what the standard service registry provides, +//! set against what the import metadata says about the same symbols. +//! +//! The report is built from the registry and the built-in symbol database +//! alone, so the same source tree always produces the same bytes. It does not +//! read executables, the network or the clock. + +use std::collections::BTreeMap; +use std::fmt::Write as _; +use std::process::ExitCode; +use std::sync::Arc; +use xenora_import_gen::{Classification, SymbolDb}; +use xenora_loader::ImportRegistry; +use xenora_loader::import_table::ImportName; +use xenora_loader::imports::ServiceStatus; +use xenora_loader::services::{MockClock, ServicesState, register_standard_services}; + +const DEFAULT_OUT: &str = "artifacts/coverage/api-coverage.md"; + +#[derive(Default)] +struct Counts { + implemented: usize, + partial: usize, + stub: usize, + aliases: usize, +} + +/// Render the report. +pub fn render() -> String { + let mut registry = ImportRegistry::new(); + register_standard_services( + &mut registry, + Arc::new(ServicesState::new(Arc::new(MockClock::new(0)))), + ); + let db = SymbolDb::builtin(); + + let mut modules: BTreeMap = BTreeMap::new(); + let mut services: Vec<(String, String, ServiceStatus)> = registry + .iter_registered() + .map(|(module, symbol, status)| (module.to_ascii_lowercase(), symbol.to_owned(), status)) + .collect(); + services.sort_by(|a, b| (&a.0, &a.1).cmp(&(&b.0, &b.1))); + for (module, _, status) in &services { + let counts = modules.entry(module.clone()).or_default(); + match status { + ServiceStatus::Implemented => counts.implemented += 1, + ServiceStatus::Partial => counts.partial += 1, + ServiceStatus::Stub => counts.stub += 1, + } + } + let mut aliases: Vec<(String, String, String)> = registry + .iter_aliases() + .map(|(module, symbol, target)| { + ( + module.to_owned(), + symbol.to_owned(), + target.to_ascii_lowercase(), + ) + }) + .collect(); + aliases.sort(); + for (module, _, _) in &aliases { + modules.entry(module.clone()).or_default().aliases += 1; + } + + // Metadata the registry contradicts, in either direction. + let mut unclassified = Vec::new(); + let mut disagreeing = Vec::new(); + for (module, symbol, status) in &services { + match db.get(module, symbol) { + None => unclassified.push(format!("`{module}!{symbol}` ({})", status.as_str())), + Some(Classification::StandardService) => {} + Some(class) => disagreeing.push(format!( + "`{module}!{symbol}`: registered {}, metadata says {}", + status.as_str(), + class.tier_name() + )), + } + } + let mut missing = Vec::new(); + for (module, symbol, class) in db.entries() { + if matches!(class, Classification::StandardService) + && registry + .resolve(module, &ImportName::Name(symbol.to_owned())) + .is_none() + { + missing.push(format!("`{module}!{symbol}`")); + } + } + + let total = |pick: fn(&Counts) -> usize| modules.values().map(pick).sum::(); + let mut md = String::new(); + let _ = writeln!(md, "# Runtime API coverage"); + let _ = writeln!(md); + let _ = writeln!( + md, + "Generated by `xenora imports coverage` from the standard service registry and the built-in import metadata. Do not edit." + ); + let _ = writeln!(md); + let _ = writeln!( + md, + "A registered service is not a compatibility claim. `implemented` and `partial` describe behaviour against the documented contract for synthetic guests; no service has been independently accepted, and no Xbox or commercial game has run." + ); + let _ = writeln!(md); + let _ = writeln!(md, "## Totals"); + let _ = writeln!(md); + let _ = writeln!(md, "| Measure | Count |"); + let _ = writeln!(md, "| --- | ---: |"); + let _ = writeln!(md, "| Services | {} |", services.len()); + let _ = writeln!(md, "| Implemented | {} |", total(|c| c.implemented)); + let _ = writeln!(md, "| Partial | {} |", total(|c| c.partial)); + let _ = writeln!(md, "| Stub | {} |", total(|c| c.stub)); + let _ = writeln!(md, "| Aliases (not services) | {} |", aliases.len()); + let _ = writeln!( + md, + "| Registered but not in metadata | {} |", + unclassified.len() + ); + let _ = writeln!( + md, + "| Metadata disagrees with registry | {} |", + disagreeing.len() + ); + let _ = writeln!( + md, + "| Metadata expects a service that is missing | {} |", + missing.len() + ); + let _ = writeln!(md); + let _ = writeln!(md, "## By module"); + let _ = writeln!(md); + let _ = writeln!(md, "| Module | Implemented | Partial | Stub | Aliases |"); + let _ = writeln!(md, "| --- | ---: | ---: | ---: | ---: |"); + for (module, c) in &modules { + let _ = writeln!( + md, + "| `{module}` | {} | {} | {} | {} |", + c.implemented, c.partial, c.stub, c.aliases + ); + } + for (title, list) in [ + ("Metadata expects a service that is missing", &missing), + ("Metadata disagrees with registry", &disagreeing), + ("Registered but not in metadata", &unclassified), + ] { + let _ = writeln!(md); + let _ = writeln!(md, "## {title}"); + let _ = writeln!(md); + if list.is_empty() { + let _ = writeln!(md, "None."); + } + for line in list { + let _ = writeln!(md, "- {line}"); + } + } + md +} + +/// `xenora imports coverage [--out ]` +pub fn command(args: &[String]) -> ExitCode { + let out = match args { + [] => DEFAULT_OUT.to_owned(), + [flag, path] if flag == "--out" => path.clone(), + _ => { + eprintln!("usage: xenora imports coverage [--out ]"); + return ExitCode::from(2); + } + }; + let report = render(); + let path = std::path::Path::new(&out); + if let Some(parent) = path.parent().filter(|p| !p.as_os_str().is_empty()) + && let Err(error) = std::fs::create_dir_all(parent) + { + eprintln!("failed to create {}: {error}", parent.display()); + return ExitCode::FAILURE; + } + if let Err(error) = std::fs::write(path, &report) { + eprintln!("failed to write {out}: {error}"); + return ExitCode::FAILURE; + } + println!("Coverage report written to: {out}"); + ExitCode::SUCCESS +} diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 55ba78d..4e7bcb9 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later +mod coverage; mod demo; mod runner; mod shaders; @@ -147,9 +148,10 @@ fn main() -> ExitCode { /// `xenora imports generate --pe [--out ]` /// `xenora imports metadata sync [--out ]` /// `xenora imports verify` +/// `xenora imports coverage [--out ]` fn imports_command(args: Vec) -> ExitCode { if args.is_empty() { - eprintln!("usage: xenora imports [options]"); + eprintln!("usage: xenora imports [options]"); return ExitCode::from(2); } @@ -158,9 +160,10 @@ fn imports_command(args: Vec) -> ExitCode { "sync" => run_imports_sync_cli(&args[1..]), "metadata" => run_imports_metadata_cli(&args[1..]), "verify" => run_imports_verify_cli(&args[1..]), + "coverage" => coverage::command(&args[1..]), other => { eprintln!("unknown imports subcommand: {other}"); - eprintln!("usage: xenora imports [options]"); + eprintln!("usage: xenora imports [options]"); ExitCode::from(2) } } diff --git a/crates/cli/tests/coverage_report.rs b/crates/cli/tests/coverage_report.rs new file mode 100644 index 0000000..f8bb7eb --- /dev/null +++ b/crates/cli/tests/coverage_report.rs @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +//! `xenora imports coverage` is deterministic and agrees with the registry. + +use std::process::Command; + +fn report(name: &str) -> String { + let path = + std::env::temp_dir().join(format!("xenora-coverage-{}-{name}.md", std::process::id())); + let status = Command::new(env!("CARGO_BIN_EXE_xenora")) + .args(["imports", "coverage", "--out"]) + .arg(&path) + .status() + .unwrap(); + assert!(status.success()); + let text = std::fs::read_to_string(&path).unwrap(); + std::fs::remove_file(path).unwrap(); + text +} + +fn count(report: &str, measure: &str) -> usize { + let prefix = format!("| {measure} | "); + let line = report + .lines() + .find(|line| line.starts_with(&prefix)) + .unwrap_or_else(|| panic!("no {measure} row")); + line[prefix.len()..].trim_end_matches(" |").parse().unwrap() +} + +#[test] +fn coverage_is_deterministic_and_consistent() { + let first = report("a"); + assert_eq!(first, report("b"), "two runs differ"); + + let services = count(&first, "Services"); + assert!(services > 100, "{services}"); + assert_eq!( + services, + count(&first, "Implemented") + count(&first, "Partial") + count(&first, "Stub") + ); + // The import generator skips adapters for these, so none may be missing. + assert_eq!( + count(&first, "Metadata expects a service that is missing"), + 0 + ); + for row in [ + "| `xinput1_4.dll` |", + "| `vcruntime140.dll` |", + "| `ws2_32.dll` |", + ] { + assert!(first.contains(row), "{row}"); + } +} + +#[test] +fn coverage_rejects_unknown_arguments() { + let status = Command::new(env!("CARGO_BIN_EXE_xenora")) + .args(["imports", "coverage", "--bogus"]) + .status() + .unwrap(); + assert_eq!(status.code(), Some(2)); +} diff --git a/crates/import-gen/src/classify.rs b/crates/import-gen/src/classify.rs index b2f17ee..e212586 100644 --- a/crates/import-gen/src/classify.rs +++ b/crates/import-gen/src/classify.rs @@ -708,32 +708,22 @@ impl SymbolDb { "TerminateProcess — calls exit(1)", ); self.win32_stub(m, "GetStartupInfoW", false, "GetStartupInfoW — fills zeros"); - self.win32_stub( - m, - "GetCurrentThreadId", - false, - "returns synthetic thread ID", - ); - self.win32_stub( - m, - "GetCurrentProcessId", - false, - "returns synthetic process ID", - ); - self.win32_stub(m, "GetCurrentThread", false, "returns pseudo-handle"); - self.win32_stub(m, "GetCurrentProcess", false, "returns pseudo-handle -1"); - self.win32_stub( - m, - "SetThreadPriority", - false, - "no-op in single-thread context", - ); - self.win32_stub( - m, - "GetThreadPriority", - false, - "returns THREAD_PRIORITY_NORMAL", - ); + // Typed services in crates/loader/runtime/services.txt, which + // does not list the l1-1-2 API set for them. + for (symbol, note) in [ + ("GetCurrentThreadId", "returns synthetic thread ID"), + ("GetCurrentProcessId", "returns synthetic process ID"), + ("GetCurrentThread", "returns pseudo-handle"), + ("GetCurrentProcess", "returns pseudo-handle -1"), + ("SetThreadPriority", "no-op in single-thread context"), + ("GetThreadPriority", "returns THREAD_PRIORITY_NORMAL"), + ] { + if *m == p2 { + self.win32_stub(m, symbol, false, note); + } else { + self.ins(m, symbol, Classification::StandardService); + } + } self.win32_stub(m, "Sleep", false, "Sleep — no-op (single-threaded)"); self.win32_stub(m, "ExitProcess", false, "ExitProcess — calls exit(0)"); self.win32_stub(m, "ExitThread", false, "ExitThread — calls exit(0)"); diff --git a/docs/coordination/system-runtime-handoff.md b/docs/coordination/system-runtime-handoff.md index 69ce98f..557444f 100644 --- a/docs/coordination/system-runtime-handoff.md +++ b/docs/coordination/system-runtime-handoff.md @@ -157,6 +157,14 @@ GitHub PR subscribe MCP returned 403 earlier; the local loop is the reliable pat - Auto-fix cannot be enabled by the agent (no push rights to upstream); the user can enable it from the PR bar. - #392 is claimed by zachdoxsee; #206 still awaits maintainer scope confirmation. Do not take either. +## Session 2026-11-25 additions + +- XInput controller services (`626de36`) with a host-connected `ControllerSource`; tests use `SimulatedControllers`. No physical controller or app input path is connected; `crates/ffi/src/frame_loop.rs` input belongs to the app lane. +- C++ `type_info` helpers on `vcruntime140.dll` (`9f472c9`). Exception handling, `dynamic_cast` and thread-safe statics remain open. +- `xenora imports coverage` report. It lists 107 registered services with no import metadata; classifying them is open work. +- Audio mixer is #306, claimed by elforeign on 2026-11-24. Do not take it. +- Platform settings, saves with quota, profiles, notifications and capability reporting already exist as the synthetic `xenora_fixture.dll` platform fixture. + ## Next actions (priority order) 1. **Check both PRs** using the timestamp under Resume here. diff --git a/docs/runtime/registry.md b/docs/runtime/registry.md index 5096a32..6900cce 100644 --- a/docs/runtime/registry.md +++ b/docs/runtime/registry.md @@ -9,6 +9,7 @@ Guest imports resolve through one lookup, `ImportRegistry::resolve`. Binding, th | Adapters | `crates/loader/src/runtime_table.rs` | Generated Win64 argument and result adapters and static metadata. | | Handlers | `handlers` in `crates/loader/src/services.rs` | Rust implementations. They see guest memory and service state, never the CPU. | | Report | [services.md](services.md) | Generated counts. Aliases are counted apart from services. | +| Coverage | `xenora imports coverage` | Every service the standard registry provides, by module and status, checked against the import metadata. Writes `artifacts/coverage/api-coverage.md` by default. | ## Rules @@ -25,6 +26,16 @@ Guest imports resolve through one lookup, `ImportRegistry::resolve`. Binding, th 2. Add the entry to `services.txt` and the handler to `services.rs`. 3. Run `cargo run -p xenora-import-gen --bin xenora-runtime-gen generate`. +## Coverage report + +`cargo run -p xenora -- imports coverage [--out ]` builds the standard registry and the built-in import metadata and writes one Markdown report. It reads no executable, network or clock, so the same tree gives the same bytes; a CLI test runs it twice and compares. The report lists three kinds of disagreement: + +- the metadata expects a standard service that the registry does not resolve, which the CLI tests also reject; +- the registry provides a service the metadata classifies as something else, such as a stub, so the import generator would emit a stub for a working service; +- the registry provides a service the metadata does not list at all. + +Counts are not compatibility claims, and the report is not committed: it changes whenever a service is added. + ## Outside this registry The fixture graphics services, `XMemAlloc` and the `XMemFree` stub are still registered by hand. The older import-list generator in `crates/import-gen` is separate: its output is not compiled into the loader, and several of its generated conformance tests check Rust library functions rather than a service.