Skip to content

feat(artifacts): compare inventories from Evidence sources - #7869

Merged
gensokyo-dev merged 6 commits into
mainfrom
feat/7678-artifact-comparison-sources
Oct 28, 2026
Merged

gensokyo-dev merged 6 commits into
mainfrom
feat/7678-artifact-comparison-sources

Conversation

@gensokyo-dev

@gensokyo-dev gensokyo-dev commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #7678. Compare artifact inventories using exact retained Evidence IDs or selected records in local Evidence files/bundles, while preserving existing inline Evidence. Adds rea compare-artifacts <inputJson> through the same application workflow as MCP.

Builds on Entrpi's prototype; its three commits retain their original author.

Problem and expected behavior

Agents currently resend complete inventories that REA already retains, and the CLI has no artifact-content comparison. The three source forms now produce identical comparison Evidence for the same resolved inputs.

A prototype edge case also failed: selecting a summary from a bundle lost access to its complete parent even when that parent was in the same file. CLI and a fresh MCP session now resolve that exact authenticated parent; a genuinely missing parent still fails and a subsequent valid request succeeds.

Change and scope

Shared source parsing and the existing Evidence-file owner handle admission, authentication and record selection. File-local related records are resolved while the authenticated read is in scope, then the session lookup is the fallback. Only selected complete inventories survive; there is no global file cache or additional file read to find the parent. The file owner now uses the existing immutable Evidence authentication proof, so downstream consumers reuse the authenticated value rather than cloning and hashing it again; each file request still reads and validates current bytes. Shared comparison/evidence construction replaces the server-only path. CLI resolves relative source paths from its working directory.

Ordinary existing local Evidence/artifact authority; additional maintainer scope decision is not applicable. Inputs and firmware are read statically.

Contract and boundary impact

  • Owner: Evidence references → EvidenceInputResolver / evidenceFileSource → ArtifactComparisonEvidence; CLI/MCP share the comparison and provenance.
  • Contract: additive retained/file forms, optional bundle evidence_id, additive CLI command. Legacy raw inline Evidence remains accepted, matching compare_functions; no second inline spelling added.
  • Evidence: summaries resolve exact complete parents, original identities/omissions remain intact, and every change cites both resolved inputs. No target/provider or runtime-analysis change.
  • Lifecycle: existing bounded JSON reader, cancellation and retained cleanup scope reused; file parsing/related-record lookup has one owner.
  • Generated catalogs/skills remain ignored outputs; no dependency, package or installation change.

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.

Evidence and regression coverage

  • Public CLI summary-bundle regression fails on the prototype (exit 1 instead of success). Fixed tests cover same-file parents in standalone CLI and fresh MCP, an absent parent followed by a valid request, source/mixed-form equality, foreign references, bundle selection errors and relative CLI paths.
  • Full and compact actual SDK/AJV contracts pass. Existing Evidence-file cancellation, failure-provenance, resource/headroom and analysis-view tests pass.
  • Two real corpus pairs: public esptool ESP32-C3 bootloader (17,744 bytes) and a Clang/LLD/esptool-produced 6,815,840-byte image containing real Python ELF data. One payload byte is modified independently, XOR/SHA recomputed and checked with esptool 5.6.0. Both implementations report only the expected member/root changes, with identical result digests and Evidence IDs.
  • Final real verification sessions check raw/reference/file/bundle MCP forms and eight compiled CLI comparisons, including summary selection from a bundle. Original/derived input hashes and owned temporary cleanup are verified. Fixtures/binaries remain outside Git.

Validation performed

  • Seven feature suites: 140 passed, including full/compact public CLI/MCP, file-source and domain Evidence authentication. The immutable-owner regression fails before the review fix and passes afterward; replacing a source file with tampered data is still rejected.
  • CI found two stale fault-injection cases that intercepted only the mutable parser after file reads moved to immutable authentication. The test now intercepts both owner entries, proves failure occurs on the parent, preserves unexpected-error/non-retention assertions, and guards both entries against reparsing retained parents. After this test-only update, both affected suites passed 14 tests, and typecheck/lint passed. The first CI run passed seven shards and all selected real-environment tasks; its eighth shard had only these two failures (2 failed / 2,306 passed / 12 skipped). A new CI run is required for the updated head.
  • npm run check:fast, npm run docs:check (9 README tests), architecture guards, formatting and bounded single-thread type-aware lint passed. Final touched-source typed lint has no warnings.
  • npm run knip:production completed its reachability report with 27 advisory candidates; this is separate from ordinary Knip.

Completed-task measurements

Main 64196b08c versus 8355ae9b3: 12 alternating fresh MCP sessions, three before/after pairs for each corpus. Each task discovers the catalog, inspects both files, compares once and closes. Both use compact input/output schemas and session/artifact families. All 17 JSON-RPC messages include initialization/instructions, catalog, requests and text/structured responses.

Corpus Comparison arguments, estimated tokens Whole wire, estimated tokens Elapsed before → after CPU before → after Sampled family RSS before → after
Public bootloader 6,442 → 60 58,326 → 52,012 4.09–4.12 → 4.04–4.61 s 5.55–5.67 → 5.43–5.71 s 429.9–431.7 → 429.8–437.6 MiB
Large generated image 7,376 → 60 61,422 → 54,174 4.35–5.08 → 4.44–4.82 s 5.91–6.55 → 5.83–6.17 s 480.7–483.2 → 481.1–484.0 MiB

Catalog cost is included: 33,389 → 33,458 estimated tokens. Whole-wire estimates improve about 11%; time/CPU/memory overlap, so no acceleration or memory reduction is claimed. Tokenx counts describe serialized transport, not model billing/rendered context. Linux 10ms process-family RSS and wait4 plus sampler CPU include client/server/verifier. Node heaps capped at 2 GiB, family early-stop 1.5 GiB; no stop triggered. Runs had no concurrent local builds/tests. OS files were warm; runtime sessions were fresh, and retained records were populated by each task's inspections. Cold OS caches and producer/oracle preparation were not measured. Extra correctness sessions include CLI costs, but their wire counters cover MCP only and are not used in the paired table.

Review-fix measurements (8355ae9b3 → b815022a0): 16 alternating fresh MCP tasks, two pairs per corpus/source form, using independently CRC-verified ZIPs containing 5 actual TypeScript shim files and 192 actual Zod files. Selected Evidence is 11.6/212.4 KB; both standalone files and canonical shared bundles produce identical result digests and Evidence IDs before/after. For the 192-file bundle task, elapsed 3.16–3.22 → 3.09–3.11 s, CPU 4.87–4.92 → 4.75–4.78 s, family RSS 430.8–431.9 → 430.5–431.5 MiB; whole-wire estimate stays 36,448 tokens. Standalone large-file times were 2.92–3.06 → 3.07–3.12 s, so this small sample establishes no general speedup. Same resource limits, warm OS/fresh-session method and measurement caveats apply. Final-head retained-source tasks also reproduce both table token counts and result identities above.

Compatibility, safety, and release

No intended breaking change. One-shot CLI has no session ledger and reports missing retained references; use saved Evidence instead. Runtime verification is Linux x64 / Node 24.22.1; Windows/macOS execution remains unverified. No firmware execution, flashing, or deep-provider behavior is claimed.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

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.

Entrpi and others added 4 commits October 28, 2026 15:52
… CLI

compare_artifacts made agents send back the complete inventory Evidence
that REA already retains, and the CLI had no artifact comparison.

Each side of compare_artifacts now takes exactly one of: complete inline
Evidence (unchanged), {kind: "retained-evidence", evidence_id}, or
{kind: "evidence-file", path, evidence_id?}. The two references are the
sources inspect_analysis_view accepts; both tools now compose one
definition in evidenceReference.ts. A summary still resolves to its exact
retained parent, and every source form gives the same comparison Evidence.
An unresolvable retained reference is refused with a typed missing
reference error.

The application layer owns source resolution and the comparison Evidence,
so MCP and the new `rea compare-artifacts` command share one workflow.
readEvidenceFileSource reports bundle-selection refusals at the caller's
own field path.
…ctions

compare_functions, compare_wasm_interfaces and the JavaScript application
comparisons name each side with evidenceInputSchema and resolve it with
resolvePairedEvidenceRequest. compare_artifacts reached the same result
for inline and retained sides through its own dispatch.

evidenceSourceInputSchema now extends evidenceInputSchema with the
Evidence-file reference, and resolvePairedEvidenceSources sends inline and
retained sides to the same resolveEvidenceInput and file sides to the
shared Evidence file reader. compare_artifacts uses both, so the forms it
shares with compare_functions are parsed and resolved by one owner. The
advertised input schema is unchanged.
rea compare (compare_bundles) compares records by Evidence identity and
explicit pairs and never reads artifact contents, so two build
inventories stay unresolved there. Its help and the CLI guide now name
compare-artifacts for that comparison.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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 ✅ Completed 2026-10-28T18:21:12.208302Z f2714a6 New commits
ℹ️ 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 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge; no blocking code issue was found.

Summary

Adds artifact comparisons from retained Evidence and saved files through a shared CLI/MCP workflow.

  • Artifact comparisons accept retained IDs and saved Evidence files.
  • Operators can compare artifact inventories with a new CLI command.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[CLI or MCP] --> B{Evidence source}
  B --> C[Inline Evidence]
  B --> D[Retained record]
  B --> E[Authenticated file or bundle]
  C --> F[Resolve complete inventory]
  D --> F
  E --> F
  F --> G[Compare inventories]
  G --> H[Comparison Evidence citing both inputs]
Loading

Reviews (3) · Last reviewed commit: "test(evidence): inject failures at both ..." · Reviewed by Greptile

@gensokyo-dev
gensokyo-dev merged commit 37827af into main Oct 28, 2026
43 of 44 checks passed
@gensokyo-dev
gensokyo-dev deleted the feat/7678-artifact-comparison-sources branch October 28, 2026 19:12
Entrpi added a commit to Entrpi/rea that referenced this pull request Oct 29, 2026
…s-managed

Bring in current upstream main through the contract branch, which now
adopts morluto#7869's Evidence-file reader, proof reuse and bundle-local parents.
The member comparison service imports EvidenceFileReadOptions from that
reader's upstream location, src/application/analysisView/evidenceFileSource.ts.
Entrpi added a commit to Entrpi/rea that referenced this pull request Oct 29, 2026
…t-stacked-on-compare-sources)

This head merges upstream main 21b1927 with morluto#7869 and adopts morluto#7869's owners, so it also brings that main here.
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Let compare_artifacts take retained Evidence references, and compare artifacts from the CLI

3 participants