Skip to content

Perceus ARC backend (--memory=arc), osprey test line coverage, and standalone-file LSP diagnostics#170

Merged
MelbourneDeveloper merged 18 commits into
mainfrom
arc
Jul 18, 2026
Merged

Perceus ARC backend (--memory=arc), osprey test line coverage, and standalone-file LSP diagnostics#170
MelbourneDeveloper merged 18 commits into
mainfrom
arc

Conversation

@MelbourneDeveloper

Copy link
Copy Markdown
Collaborator

TLDR

Implements the Perceus ARC reference-counting backend (--memory=arc, plan 0011 phase 2) end-to-end — counting runtime, full compiler dup/drop insertion, and leak diagnostics — plus native line coverage for osprey test (--coverage / --coverage-json) surfaced in the VS Code Test Explorer, and LSP diagnostics for standalone module-bearing files.

Details

ARC memory backend ([GC-ARC-PERCEUS], spec 0018 [MEM-BACKENDS])

  • New counting runtime compiler/runtime/memory_arc.c: 16-byte header (meta + refcount), probe-first open-addressing registry so foreign/rodata pointers are safe no-ops, kind/mask-driven drop walk (RAW / MASK / list-header variants), immortal values (rc < 0), worklist-based recursive drop, and OSPREY_ARC_DEBUG=1 leak statistics. memory_hooks.h + osp_arc_shim.h give all three backends (default / gc / arc) one IR: default and gc define osp_retain/osp_release/osp_mem_immortal as no-ops.
  • Compiler dup/drop discipline in crates/osprey-codegen: new arc.rs ownership ledger inserts Perceus retain/release — producers own +1, dup-on-store, drops at region end and at last use (release_dead_after computes continuation free-idents via the new freevars::free_idents_of_stmts), returns transfer +1, callees borrow. Owned values spill to null-initialized entry-block slots, so untaken match arms/branches need no dominance analysis. New meta.rs computes the per-allocation kind/mask word for @osp_alloc_tagged (unit-tested against the Result, closure-cell, and HttpResponse layouts).
  • Container/boundary soundness: list/map runtimes retain on alias returns, the empty-list singleton is immortal, elements are dup'd at insertion, osprey_map_merge releases unaliased intermediates, fibers release the spawned env cell after the thunk runs, and pointer-erasing boundaries (effect boxing, fiber thunks, fold accumulators) escape-retain before boxing. Container interior nodes stay RAW (leak-safe by construction — never a dangling release); node-level RC is the documented M4b/M5b/M6b remainder in plan 0011.
  • --memory=arc is wired through the CLI/Makefile; make _conformance-arc runs the harness under the counting runtime.

Test coverage ([TESTING-COVERAGE-CLI]/[TESTING-COVERAGE-JSON], spec 0027)

  • osprey test --coverage instruments each suite with line counters (new crates/osprey-codegen/src/coverage.rs + compiler/runtime/coverage_runtime.c), prints per-suite and total # coverage: TAP rows, and --coverage-json <path> writes the merged machine-readable report. Coverage never changes suite outcomes or exit codes.
  • VS Code Test Explorer runs suites through --coverage-json and feeds line hits into the native VS Code coverage API (test-explorer.ts, test-explorer-parse.ts).

LSP

  • diagnostics.rs gains standalone_diagnostics: module-bearing files no project claims (test suites, standalone scripts) are assembled the same way --check/osprey test does, so the editor stops reporting unknown identifier for a file's own modules (backed by the new osprey_project::needs_assembly).

Docs/examples: plan 0011 checklist updated to the landed state; spec 0018 status rewritten; Talon Bank gains accounts.test.ospml; committed wasm bundles regenerated for the new codegen.

How Do The Automated Tests Prove It Works?

  • Backend conformance: the differential harness (crates/diff_examples.sh) passes PASS=148 FAIL=0 NOEXP=0 + FC_OK with byte-identical output under all three backends (default, --memory=gc, --memory=arc) — the [MEM-BACKENDS] conformance bar. With OSPREY_ARC_DEBUG=1, container-free examples (comprehensive_math, record_update_basic, algebraic_effects_comprehensive, fiber_determinism) report zero live language values at exit.
  • Layout metadata: meta.rs unit tests (result_block_masks_depend_on_payload, http_response_marks_words_1_2_5, oversized_structs_fall_back_to_raw) pin the mask encoding to the real C ABIs, including the sign-bit word-55 edge.
  • Runtime: coverage_runtime_tests.c covers the C coverage collector; the string/profiler C suites and cargo test --workspace (all crates, ~1100 tests) are green; per-crate coverage thresholds in coverage-thresholds.json all met ([rust] OK: all crates meet their thresholds, extension 97.7% ≥ 95%).
  • Coverage feature: test_cmd.rs tests (only_test_suffixed_files_are_recognized, coverage_dump_path_is_stable_and_scratch_scoped, arg-parse tests for --coverage-json) plus extension suites test-explorer-parse.test.ts / test-explorer.test.ts (coverage args, JSON parsing, line-hit reporting) — extension suites 3/3 green under the real VS Code host.
  • Cross-flavor: cross_flavor_ir_equiv proves .osp/.ospml twins still lower to byte-identical IR with ARC insertion enabled.
  • End-to-end: bank native tests (osprey test, 13 TAP tests) and bank Playwright e2e (17 passed) run the compiled ARC-era binary serving real HTTP; wasm golden suite PASS=49 FAIL=0 proves the retagged allocator links and runs on wasm32-wasip1; website Playwright 76 passed; Docker web-compiler test passed.

fiber_determinism.osp and fiber_exact_replica.osp carried unresolved
conflict markers from an aborted stash merge. Resolve to the top-level
handle...in form (matching the tested version on main); drop the stray
fn main() wrapper from the stashed side.
# Conflicts:
#	Cargo.lock
#	Makefile
#	compiler/runtime/http_server_request_tests.c
#	compiler/runtime/http_server_runtime.c
#	compiler/runtime/http_server_send_tests.c
#	crates/osprey-cli/Cargo.toml
#	crates/osprey-cli/src/main.rs
#	crates/osprey-cli/src/project.rs
#	crates/osprey-cli/src/test_cmd.rs
#	crates/osprey-cli/src/wasm.rs
#	crates/osprey-lsp/src/diagnostics.rs
#	crates/osprey-project/src/lib.rs
#	crates/osprey-types/src/builtins.rs
#	docs/specs/0027-TestingFramework.md
#	examples/projects/modules/README.md
#	examples/projects/modules/client/src/data.ospml
#	examples/projects/modules/e2e/tests/bank.spec.js
#	examples/projects/modules/src/web/bundle.ospml
#	examples/projects/modules/web/src/host.js
#	examples/projects/modules/web/test/host.test.mjs
#	vscode-extension/client/src/extension.ts
#	vscode-extension/client/src/test-explorer-parse.ts
#	vscode-extension/client/src/test-explorer.ts
#	vscode-extension/package.json
#	vscode-extension/test/suite/test-explorer-harness.ts
#	vscode-extension/test/suite/test-explorer-parse.test.ts
#	vscode-extension/test/suite/test-explorer.test.ts
#	website/src/spec/0001-introduction.md
#	website/src/spec/0002-lexicalstructure.md
#	website/src/spec/0003-syntax.md
#	website/src/spec/0004-typesystem.md
#	website/src/spec/0005-functioncalls.md
#	website/src/spec/0006-stringinterpolation.md
#	website/src/spec/0007-patternmatching.md
#	website/src/spec/0008-blockexpressions.md
#	website/src/spec/0009-booleanoperations.md
#	website/src/spec/0010-loopconstructsandfunctionaliterators.md
#	website/src/spec/0011-lightweightfibersandconcurrency.md
#	website/src/spec/0012-built-infunctions.md
#	website/src/spec/0013-errorhandling.md
#	website/src/spec/0014-http.md
#	website/src/spec/0015-websockets.md
#	website/src/spec/0016-securityandsandboxing.md
#	website/src/spec/0017-algebraiceffects.md
#	website/src/spec/0018-memorymanagement.md
#	website/src/spec/0019-foreignfunctioninterface.md
#	website/src/spec/0020-languageserverandeditors.md
#	website/src/spec/0021-debugger.md
#	website/src/spec/0022-webassemblytarget.md
#	website/src/spec/0023-languageflavors.md
#	website/src/spec/0024-mlflavorsyntax.md
#	website/src/spec/0025-modulesandnamespaces.md
#	website/src/spec/0026-documentationcomments.md
#	website/src/spec/index.md
- osp_release_unique: proved-unique drop with LLVM free-pair attributes so
  -O2 deletes non-escaping scalar Result alloc+release pairs (restores the
  dead-allocation elision the ARC ledger's opaque releases had defeated)
- benchmarks: osprey-arc, C# (NativeAOT) and Dart (AOT) columns; 22 case
  ports per language, oracle-verified; refreshed results + baked website
  tables
@MelbourneDeveloper
MelbourneDeveloper merged commit 9643dbf into main Jul 18, 2026
6 checks passed
@MelbourneDeveloper
MelbourneDeveloper deleted the arc branch July 18, 2026 22:14
MelbourneDeveloper added a commit that referenced this pull request Jul 22, 2026
Reconcile the parallel Perceus ARC landing (#170) with this branch's
superset ARC/GC + benchmark + hardening work. The arc branch already
contains a strict superset of #170 (ARC core evolved 29 commits further;
test line-coverage explorer, 0027 testing spec, and LSP diagnostics are
identical), so every conflict resolved to the arc side and the merged
tree is unchanged from arc HEAD.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant