[PR #468] [MERGED] refactor(mcp): make analysis states unrepresentable #2014

Closed
opened 2026-10-16 21:13:22 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/468
Author: @morluto
Created: 8/9/2026
Status: ✅ Merged
Merged: 8/9/2026
Merged by: @morluto

Base: main ← Head: agent/make-invalid-states-unrepresentable


📝 Commits (10+)

  • 79cc9df refactor(config): parse capability settings into exact states
  • 63b0b1c refactor(runtime): encode replay and process outcomes exactly
  • 2150109 refactor: make analysis states unrepresentable
  • ade56a6 refactor(mcp): register canonical schemas with SDK
  • 04c198e fix: preserve capability and catalog invariants
  • ba7327d fix(build): remove stale compiled modules
  • 20dba84 fix(replay): update real verifier policy dependency
  • 85d27fb fix(package): verify the complete MCP catalog
  • 7b00579 fix(test): supply complete replay reload policy
  • 33a0f62 refactor(contracts): centralize output schema lookup

📊 Changes

271 files changed (+5946 additions, -5675 deletions)

View changed files

📝 docs/product-catalog.json (+2 -2)
📝 docs/verification/managed-conformance-manifest.json (+2 -2)
📝 package.json (+1 -1)
➕ scripts/clean-build-output.mjs (+10 -0)
📝 scripts/generate-mcp-tool-catalog.mjs (+35 -14)
📝 scripts/lib/verify-package-core.mjs (+4 -7)
📝 scripts/verify-managed-conformance.mjs (+3 -3)
📝 scripts/verify-package-mcp.mjs (+21 -13)
📝 scripts/verify-real-browser.mjs (+1 -0)
📝 scripts/verify-real-javascript-replay.mjs (+24 -10)
📝 scripts/verify-windows-package.mjs (+2 -2)
📝 skills/reverse-engineer-anything/SKILL.md (+1 -1)
📝 src/application/ApplicationWorkflowEvidenceResolver.ts (+33 -28)
➕ src/application/ArtifactInventory/policy.ts (+41 -0)
📝 src/application/ArtifactInventory/reader.ts (+2 -10)
📝 src/application/ArtifactInventory/scanCanonical.ts (+0 -8)
📝 src/application/ArtifactInventory/scanReader.ts (+12 -12)
📝 src/application/ArtifactInventory/types.ts (+12 -17)
📝 src/application/BinarySession.ts (+16 -20)
📝 src/application/BinarySessionStatus.ts (+13 -7)

...and 80 more files

📄 Description

Description

Replace permissive intermediate states with boundary-parsed, discriminated values across configuration, provider selection, binary targets, replay/process outcomes, managed workflows, browser capture, and native API evidence. Contradictory states are rejected as inputs instead of surviving into application logic.

MCP registration now gives the canonical Zod input and output contracts directly to the 2.0 SDK. The SDK owns request parsing, output validation, registered-tool advertisement, per-request client metadata, connection lifetime, and list-change behavior. The generated catalog is captured through a real SDK client/server connection, so it cannot drift from tools/list. This removes the parallel input parser, manual JSON Schema override layer, server-global metadata fallbacks, and transport-level live-server bookkeeping.

The contract cleanup also closes three concrete invalid states found while reviewing the SDK projection:

  • web capture comparison is an exact passive-or-scenario union;
  • browser script-source capture requires a separate explicit approval and records that approval in Evidence;
  • Node characterization plans and native ABI return/parameter records use field-specific effect and role variants.

No tool names or provider authorities are added or removed. Setup behavior and provider mutation boundaries are unchanged.

Suggested review order:

  1. Configuration and runtime state parsing (79cc9df3, 63b0b1c1).
  2. Provider, target, workflow, and integrity unions (21501091).
  3. SDK-owned MCP registration and deleted parallel catalog machinery (ade56a6e, 04c198e7, 410569f0).
  4. Exact build and package verification (ba7327d9, 20dba840, 85d27fb7, 7b00579e).
  5. Centralized contract drift boundary (33a0f627).

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Refactoring (no functional change)
  • Tool contract change (MCP schema modification)

Testing Performed

  • Unit tests added or updated
  • TypeScript typecheck passes (npm run typecheck)
  • Linting passes (npm run lint)
  • Full test suite passes (npm test)
  • Real Hopper verification performed (npm run verify:hopper)
  • Linux real Hopper verification performed (npm run verify:hopper:linux) or unavailability explained
  • Real browser verification performed (npm run verify:browser) or unavailability explained
  • Package verification performed (npm run verify:package)

Validation performed on the final local tree:

  • npm run check:pr — 329 test files and 1,697 tests passed; typecheck, lint, formatting, Knip, metadata, SDK-derived catalog, generated docs, documentation facts, and error-schema checks passed.
  • Focused MCP/browser/native regression suites — 21 tests passed, covering SDK output validation, catalog identity, modern request metadata, incomplete browser comparisons, explicit source approval, Evidence provenance, Node effect narrowing, and native ABI roles.

Real Hopper, Linux Hopper, Ghidra, browser, and package verification were not run locally. Provider execution and bridge semantics are unchanged; the PR workflows remain the source of cross-platform and real-provider evidence.

Tool Contract Impact

The canonical 116-tool inventory remains complete and stable. Tool schemas now come from the same registered SDK contracts that parse calls and validate successful structured output. The caller-visible changes reject incomplete browser comparison pairs, unapproved browser source capture, invalid Node characterization effects, and mismatched native ABI roles.

Generated product, skill, Evidence manifest, and MCP catalog metadata were regenerated and verified.

No linked issue.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/468 **Author:** [@morluto](https://github.com/morluto) **Created:** 8/9/2026 **Status:** ✅ Merged **Merged:** 8/9/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `agent/make-invalid-states-unrepresentable` --- ### 📝 Commits (10+) - [`79cc9df`](https://github.com/morluto/rea/commit/79cc9df3700d7ab33e66ce3273c475d01cfbdc96) refactor(config): parse capability settings into exact states - [`63b0b1c`](https://github.com/morluto/rea/commit/63b0b1c12bf4ff88907a3833426c403c0d699202) refactor(runtime): encode replay and process outcomes exactly - [`2150109`](https://github.com/morluto/rea/commit/21501091cfc817ab2ab91396f5bdfdc6384c381b) refactor: make analysis states unrepresentable - [`ade56a6`](https://github.com/morluto/rea/commit/ade56a6e01d0a61c5a247e7314f1a6dbe72709f0) refactor(mcp): register canonical schemas with SDK - [`04c198e`](https://github.com/morluto/rea/commit/04c198e76f4fb2165dc2f547b9473dc445ff4ea2) fix: preserve capability and catalog invariants - [`ba7327d`](https://github.com/morluto/rea/commit/ba7327d926368e25733f7ad8c6f2ad00076c61b7) fix(build): remove stale compiled modules - [`20dba84`](https://github.com/morluto/rea/commit/20dba84056ab49a0058297d26765d2b0889c92b8) fix(replay): update real verifier policy dependency - [`85d27fb`](https://github.com/morluto/rea/commit/85d27fb72407876c926805a91f0ce2bd21d41755) fix(package): verify the complete MCP catalog - [`7b00579`](https://github.com/morluto/rea/commit/7b00579e9851138dee380b7c9e5436c10ac29706) fix(test): supply complete replay reload policy - [`33a0f62`](https://github.com/morluto/rea/commit/33a0f627056e6e9a0f6a5d4325e2fe65c31a545e) refactor(contracts): centralize output schema lookup ### 📊 Changes **271 files changed** (+5946 additions, -5675 deletions) <details> <summary>View changed files</summary> 📝 `docs/product-catalog.json` (+2 -2) 📝 `docs/verification/managed-conformance-manifest.json` (+2 -2) 📝 `package.json` (+1 -1) ➕ `scripts/clean-build-output.mjs` (+10 -0) 📝 `scripts/generate-mcp-tool-catalog.mjs` (+35 -14) 📝 `scripts/lib/verify-package-core.mjs` (+4 -7) 📝 `scripts/verify-managed-conformance.mjs` (+3 -3) 📝 `scripts/verify-package-mcp.mjs` (+21 -13) 📝 `scripts/verify-real-browser.mjs` (+1 -0) 📝 `scripts/verify-real-javascript-replay.mjs` (+24 -10) 📝 `scripts/verify-windows-package.mjs` (+2 -2) 📝 `skills/reverse-engineer-anything/SKILL.md` (+1 -1) 📝 `src/application/ApplicationWorkflowEvidenceResolver.ts` (+33 -28) ➕ `src/application/ArtifactInventory/policy.ts` (+41 -0) 📝 `src/application/ArtifactInventory/reader.ts` (+2 -10) 📝 `src/application/ArtifactInventory/scanCanonical.ts` (+0 -8) 📝 `src/application/ArtifactInventory/scanReader.ts` (+12 -12) 📝 `src/application/ArtifactInventory/types.ts` (+12 -17) 📝 `src/application/BinarySession.ts` (+16 -20) 📝 `src/application/BinarySessionStatus.ts` (+13 -7) _...and 80 more files_ </details> ### 📄 Description ## Description Replace permissive intermediate states with boundary-parsed, discriminated values across configuration, provider selection, binary targets, replay/process outcomes, managed workflows, browser capture, and native API evidence. Contradictory states are rejected as inputs instead of surviving into application logic. MCP registration now gives the canonical Zod input and output contracts directly to the 2.0 SDK. The SDK owns request parsing, output validation, registered-tool advertisement, per-request client metadata, connection lifetime, and list-change behavior. The generated catalog is captured through a real SDK client/server connection, so it cannot drift from `tools/list`. This removes the parallel input parser, manual JSON Schema override layer, server-global metadata fallbacks, and transport-level live-server bookkeeping. The contract cleanup also closes three concrete invalid states found while reviewing the SDK projection: - web capture comparison is an exact passive-or-scenario union; - browser script-source capture requires a separate explicit approval and records that approval in Evidence; - Node characterization plans and native ABI return/parameter records use field-specific effect and role variants. No tool names or provider authorities are added or removed. Setup behavior and provider mutation boundaries are unchanged. Suggested review order: 1. Configuration and runtime state parsing (`79cc9df3`, `63b0b1c1`). 2. Provider, target, workflow, and integrity unions (`21501091`). 3. SDK-owned MCP registration and deleted parallel catalog machinery (`ade56a6e`, `04c198e7`, `410569f0`). 4. Exact build and package verification (`ba7327d9`, `20dba840`, `85d27fb7`, `7b00579e`). 5. Centralized contract drift boundary (`33a0f627`). ## Type of Change - [x] Bug fix - [ ] New feature - [ ] Documentation update - [ ] Performance improvement - [x] Refactoring (no functional change) - [x] Tool contract change (MCP schema modification) ## Testing Performed - [x] Unit tests added or updated - [x] TypeScript typecheck passes (`npm run typecheck`) - [x] Linting passes (`npm run lint`) - [x] Full test suite passes (`npm test`) - [ ] Real Hopper verification performed (`npm run verify:hopper`) - [ ] Linux real Hopper verification performed (`npm run verify:hopper:linux`) or unavailability explained - [ ] Real browser verification performed (`npm run verify:browser`) or unavailability explained - [ ] Package verification performed (`npm run verify:package`) Validation performed on the final local tree: - `npm run check:pr` — 329 test files and 1,697 tests passed; typecheck, lint, formatting, Knip, metadata, SDK-derived catalog, generated docs, documentation facts, and error-schema checks passed. - Focused MCP/browser/native regression suites — 21 tests passed, covering SDK output validation, catalog identity, modern request metadata, incomplete browser comparisons, explicit source approval, Evidence provenance, Node effect narrowing, and native ABI roles. Real Hopper, Linux Hopper, Ghidra, browser, and package verification were not run locally. Provider execution and bridge semantics are unchanged; the PR workflows remain the source of cross-platform and real-provider evidence. ## Tool Contract Impact The canonical 116-tool inventory remains complete and stable. Tool schemas now come from the same registered SDK contracts that parse calls and validate successful structured output. The caller-visible changes reject incomplete browser comparison pairs, unapproved browser source capture, invalid Node characterization effects, and mismatched native ABI roles. Generated product, skill, Evidence manifest, and MCP catalog metadata were regenerated and verified. ## Related Issues No linked issue. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:13:22 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2014
No description provided.