Skip to content

fix(reconstruction): check every selected replay environment - #2971

Closed
555aaditya wants to merge 1 commit into
morluto:mainfrom
555aaditya:fix/2622-replay-environment-every-source
Closed

555aaditya wants to merge 1 commit into
morluto:mainfrom
555aaditya:fix/2622-replay-environment-every-source

Conversation

@555aaditya

@555aaditya 555aaditya commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #2622.

A behavioral reconstruction claim checked the controlled-replay environment of only the first left source and the first right source. A process comparison can select several observations per side (left_evidence_ids / right_evidence_ids, accepted by comparisonSourceEvidenceSides and reachable through import_evidence_bundle). So a later observation recorded in a different environment, or with none, did not stop the claim from reporting pass. That made an incomparable claim look verified.

After this change, every selected source must carry an environment and all of them must be identical. Otherwise the existing Controlled replay environments are unavailable or incompatible. limitation is added and the claim stays unknown. Single-pair comparisons, which are what the public compare_process_captures producer emits today, behave exactly as before.

Problem and expected behavior

Smallest trigger: a rea.process-comparison record with two observations per side, where one of the later observations was captured in a different (or missing) environment:

Side Observation 1 Observation 2
left env-a env-b
right env-a env-a
  • Before: verifyReconstruction returns pass.
  • Expected: unknown, with Controlled replay environments are unavailable or incompatible.

Violated invariant: a pass may only cover declared claims whose source observations are comparable (.agents/skills/reverse-engineer-anything/references/evidence-workflows.md). The environment check in src/domain/reconstructionVerification.ts looked up sides.left[0] and sides.right[0] only, so comparability was never established for the remaining sources.

Change and scope

authorityLimitations already receives sources, which is exactly the resolved, deduplicated union of both sides. Every id there has already been resolved, and a missing record throws earlier. The fix compares every source's environment against the first one, and flags null environments, in that same function. It removes the first-source-only lookup map instead of adding a second check next to it, so there is one owner for this rule.

The environment comparison still uses JSON.stringify, as before, so the only behavioural change is which sources are checked.

Not included: changing how environments are compared (canonical vs. serialized). That is unrelated to this bug.

Contribution scope: an ordinary correctness fix within an existing boundary, so a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/reconstructionVerification.ts, in authorityLimitations (domain, pure).
  • Contribution scope fit and linked maintainer decision: bug fix within the existing reconstruction-verification boundary; not applicable.
  • CLI and MCP/tool-catalog contract: none. No schema, tool, or catalog change. verify_reconstruction / verify-reconstruction can now return unknown where it previously returned pass, but only for multi-source comparisons with mismatched or missing environments.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: stricter. A behavioral pass now requires every selected observation to share one environment. The limitation text is unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

(The verifier only reads in-memory Evidence; it launches nothing.)

Evidence and regression coverage

  • Tests added or updated: src/domain/reconstructionVerification.test.ts, test limits behavioral claims by every selected replay environment. It covers the restoration checks listed in the issue:

    • a later left source with a different environment → unknown + limitation;
    • a later right source with a different environment → unknown + limitation (so the result can't depend on source order);
    • a later source with a missing (null) environment → unknown + limitation;
    • a mismatch in the first source → unknown + limitation (existing behaviour kept);
    • all four sources compatible → pass, without the environment limitation.

    To support this, the source fixture takes an options object { captureResult?, replayEnvironment? } in place of its trailing captureResult parameter, which keeps it within max-params. A multiSourceProcessComparison helper builds left_evidence_ids / right_evidence_ids comparisons. The one existing caller that passed captureResult positionally is updated.

  • Base reproduction: with only the source change reverted, the new test fails (1 failed | 9 passed). Base returns pass for the later-mismatch cases. With the change, all 10 tests in the file pass.

  • User-visible CLI/MCP output: no new fields. Affected multi-source claims report status: "unknown" and include the existing environment limitation.

  • Remaining proof gaps: I didn't run an end-to-end import_evidence_bundle → verify_reconstruction MCP session with a hand-built multi-source bundle. The domain function changed here is the one those adapters call.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

All run on macOS (arm64), Node 26.5.0, npm 11.17.0, with locked dependencies, rebased on origin/main at 7a6defab1:

  • npx vitest run --project domain src/domain/reconstructionVerification.test.ts: 10 passed. With the source fix reverted: 1 failed (the new test), 9 passed.
  • npx vitest run --project domain src/domain/reconstructionVerification.test.ts src/domain/reconstructionVerification.functionSources.test.ts: 78 passed.
  • npx vitest run --project domain: 162 files, 2503 passed, 3 skipped.
  • npx vitest run tests/boundary/mcp/reconstructionCoverageMcp.test.ts tests/boundary/mcp/reconstructionObligationLedgerMcp.test.ts tests/boundary/mcp/processEvidenceIdentityMcp.test.ts: passed.
  • npm run test:focused -- tests/boundary/cli/reconstructionObligationLedgerCli.test.ts src/domain/reconstructionVerification.test.ts: 11 passed.
  • npm run check:fast (typecheck + lint + module boundaries): passed, also via the pre-push hook.
  • npx oxfmt --check and npx oxlint on both changed files: clean.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. The verifier is stricter only for multi-source behavioral comparisons whose environments differ or are missing, which were previously false passes.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (pure domain logic, no provider).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no process, filesystem, or network interaction.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Behavioral reconstruction claims compared the environment of only the
first left and first right source observation. A comparison that selects
several observations per side through left_evidence_ids/right_evidence_ids
could therefore pass even when a later observation ran in a different or
missing controlled-replay environment.

Require every selected source to carry an environment and all of them to
match before a behavioral claim can pass; otherwise the existing
"Controlled replay environments are unavailable or incompatible."
limitation keeps the claim unknown. Single-pair comparisons behave as
before.

Fixes morluto#2622
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-13T18:27:23.956048Z acb8e74 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; it closes the unchecked-source gap without changing unrelated claim checks.

Summary

Behavioral reconstruction claims now check the replay environment of every selected observation, rather than only the first observation on each side.

  • Behavioral claims now check every selected replay environment.

Reviews (1) · Last reviewed commit: "fix(reconstruction): check every selecte..." · Reviewed by Greptile

@555aaditya

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@555aaditya

Copy link
Copy Markdown
Contributor Author

Hi @morluto 👋 I'm a first-time contributor here and have opened three small fixes, each with a regression test that fails on base:

CI is waiting on workflow approval. Could you approve the runs when you get a chance? Happy to make any changes. Thanks!

@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Oct 14, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Preserve XML and Interface Builder identity at their parsing boundary, retain usable Objective-C slots with precise coverage, and keep native trace failures distinct from absence. Add caller-selected Interface Builder summaries backed by complete retained Evidence, and preserve comparison limitations.

Reviewed fixes: #1969, #2088, #2108, #2513, #2639, #2684, #2731, #2759, #2875, #2888, #2889, #2970, #2971, #3002.

Validation: relevant native/domain focused lane passed 142 tests; earlier Interface Builder/MCP checks passed 24 tests. Real native UI and Ghidra producer coverage was not repeated.
@555aaditya

Copy link
Copy Markdown
Contributor Author

Closing as superseded: this fix and its regression coverage landed on main in 55dd21a. Thanks for integrating it!

@555aaditya 555aaditya closed this Oct 14, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thanks @555aaditya for finding that behavioral reconstruction compared only the first selected replay environment on each side. Main now checks every selected environment and keeps missing or differing environment facts from being treated as aligned (main).

@morluto morluto added the area: evidence Evidence, artifacts, and reconstruction label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions area: evidence Evidence, artifacts, and reconstruction bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(reconstruction): later replay environments do not limit a multi-source claim

2 participants