fix(coherence): honor native graph and obstruction contracts - #703
proffesor-for-testing merged 4 commits into
Conversation
proffesor-for-testing
left a comment
There was a problem hiding this comment.
Verified every native-contract claim directly against the installed prime-radiant-advanced-wasm binary: edges without restriction_map/source_dim/target_dim fail to parse (so main never reached the engine for any connected graph), obstruction records use edge_index/source_node/target_node/magnitude, and endpoints are array positions, which makes the rebuild-on-serialize index fix correct. Energy is additive across edge subsets, so batching with cell budgets is sound. Build passes; the real-WASM suite passes (176/183 with 7 skipped; one heavy 10x384 case is load-sensitive and passes in isolation). Codex adversarial pass found no serialization or aggregation defect; its two findings concern the service's pre-existing catch-all fallback (ignores fallbackEnabled:false, does not update stats), which this PR does not touch.
ca8b863
into
proffesor-for-testing:main
|
Thank you, @rudycelekli! This is a genuinely valuable fix: our adapter never actually reached the native sheaf engine for any connected graph (the serialized edges lacked the required Small follow-ups, none blocking:
|
Summary
Connected coherence graphs fail in the real WASM engine because serialized edges omit the required
restriction_mapand dimension fields. The service catches the native parse error and returns its human-lane fallback. The existing unseeded integration fixture exposed this intermittently; an edge-free graph passes. The adapter also reads obstruction fields that the native engine does not return, which would discard contradictions after fixing serialization alone.Translate both sides of the actual native contract: equal-dimensional sections receive an identity restriction map, and native
source_node/target_node/magnitudebecome the domain contradiction fields. Rebuild endpoint indices from current node positions, including after removals, and keep confidence in its declared range. Preserve native energy values and ordering.Dense restriction matrices need explicit resource limits. Native energy and obstructions are edge-additive, so process bounded batches and merge their results. Preflight the entire operation before allocating matrices or calling WASM: at most 4 Mi matrix cells per batch and 32 Mi cumulative cells per operation. Missing endpoints, incompatible dimensions or oversized work raise a diagnostic; the service retains its existing human-lane fallback. Energy and obstruction detection are separate operations. These limits bound matrix work, not total process RSS or wall-clock time.
CI follow-up
Includes the fork-comment guard from #701 and the runner/reporting correction from #704. Optional fork comments are skipped while artifacts remain available; nonzero runner exits and timeouts remain failures. Coverage uses valid reporters and produces a JSON summary, while JUnit remains a test report.
The 12 fork-comment regressions and nine runner-exit regressions pass. A real 18-test coverage control produces the expected reports with exit 0; an invalid-reporter control retains exit 1 despite all 18 tests passing. Earlier green coverage jobs did not establish completed coverage reporting: the old wrapper could mask the invalid coverage reporter's error. The current full run has now completed successfully with the corrected wrapper.
These reporting and exit-status failure modes are exercised by
tests/unit/scripts/fork-pr-comments.test.ts,tests/unit/scripts/ci-vitest-run.test.ts, and the real reporter controls described in #704.Verification
Final published head
607a00af: all 18 checks pass. Full coverage job: 23,614 tests passed / 62 skipped; 976 files passed / six skipped. Coverage artifacts upload successfully; measured line coverage is 65.46% (the existing 80% comparison is advisory). No reporter errors or exit normalization occur.183 passed across seven files, including real WASM regressions, existing coherence gates, fallback handling, threshold tuning and concurrency tests.
The identical final two-file, 23-case WASM regression suite on pristine main
29f0ed4f: 15 failed / 8 passed. Patched: 23 passed.A connected 10-by-384 graph is compared directly with an unbatched native reference: equal energy and all thresholded obstruction IDs/order, with each adapter call respecting the matrix budget.
npm run typecheck,npm run build, andnpx eslint src/integrations/coherence/engines/cohomology-adapter.ts: passed.Independent built-service checks with all pairs connected (10-by-128 and 20-by-384): native results match the analytical energy and do not fall back. The dense 20-by-384 case takes approximately 3–4 seconds locally; this is a correctness/resource-bound change, not a speed claim.
Replace unseeded test vectors with deterministic connected inputs, including seed 67 that reproduces the original missing-map failure class. The performance test keeps its existing fallback and duration assertions.
Failure modes
Every failure mode mentioned in this PR description has either (a) a test that exercises it, or (b) a linked tracking issue.
Affects published API or CLI surface: the coherence adapter now accepts valid connected graphs through real WASM and reports their contradictions. Incompatible or oversized graphs use the existing service fallback response.
Touches the init flow / npm-publish workflow / init corpus: no.