[PR #3563] [CLOSED] fix(comparison): keep unexamined Swift literals unknown #5828

Closed
opened 2026-10-31 01:09:44 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3563
Author: @XiaoBinGan
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: fix/function-comparison-swift-literal-coverage


📝 Commits (3)

  • a80c717 fix(comparison): keep unexamined Swift literals unknown
  • 4ce2f30 Merge remote-tracking branch 'origin/main' into fix/function-comparison-swift-literal-coverage
  • e9e7def Merge remote-tracking branch 'origin/main' into sweep/3563

📊 Changes

6 files changed (+94 additions, -24 deletions)

View changed files

📝 src/contracts/functionComparisonExample.ts (+1 -0)
📝 src/domain/functionComparison.test.ts (+64 -6)
📝 src/domain/functionComparisonDimensions.ts (+8 -13)
📝 src/domain/functionComparisonNormalization.ts (+17 -4)
📝 src/domain/reconstructionVerification.functionSources.test.ts (+1 -0)
📝 tests/boundary/mcp/ghidraEvidenceMcp.test.ts (+3 -1)

📄 Description

Summary

compare_functions reported a definite negative for a facet the provider never examined. When neither dossier recorded the Swift String literal facet, the strings_names dimension and the overall comparison status came back unchanged with unknown: 0, even though swift_string_literals is documented as "absent when the provider does not decode them for this target".

No issue is linked: this was found by auditing the producing boundary for the "unresolved facet silently becomes a negative result" class, not from a user report. It is the same class as the earlier fix(comparison): keep unsupported function facets unknown (#2450).

Base revision: 044fb9127ac77dbb4d9992410f7596fc49dc446e.

Problem and expected behavior

Smallest trigger: compare two function dossiers that both omit swift_string_literals.

Two places answered the same question differently:

  • The producing boundary, src/domain/functionComparisonNormalization.ts, computed complete = swift_string_literals !== undefined && omissions.length === 0, i.e. "undefined means never examined". Its consumer swiftLiteralSitesConflict() documents that a differing retained fact proves a change only when the opposite dossier is complete.
  • src/domain/functionComparisonDimensions.ts re-derived the answer locally: swiftLiteralCoverage() mapped undefined -> "absent", and complete = swiftLiteralCoverage(left) === swiftLiteralCoverage(right) && swiftLiteralCoverage(left) !== "partial". So absent === absent made complete true, both sides projected the missing facet as [], and the comparison returned unchanged without ever consulting the owner.

Violated invariant: an unresolved or unexamined facet must stay unknown rather than be treated as an observed absence.

Observed before, from a probe on this base revision:

{"status":"unchanged","strings_names":"unchanged","summary":{"unchanged":8,"changed":0,"unknown":0}}

Expected and observed after:

{"status":"unknown","strings_names":"unknown","summary":{"unchanged":7,"changed":0,"unknown":1}}

Change and scope

  • functionComparisonNormalization.ts is now the single owner. It exports swiftLiteralCoverage(snapshot): "absent" | "complete" | "partial"; swiftLiteralSites() derives its complete flag from that owner instead of recomputing it.
  • functionComparisonDimensions.ts deletes its private duplicate, imports the owner, and requires both sides to be "complete" before literals may decide equality. A third limitation string states that neither dossier examined the facet.
  • One directly related refactor was required and completed: the duplicated coverage rule is removed rather than left in place, so the two answers cannot drift again. No other dimension, schema, output field, or pipeline stage was touched.

Not included: no change to swiftLiteralSitesConflict semantics, no change to any other dimension, no new tool, no CLI change.

Visible behavior change worth reviewing: absent/absent was the only input whose result changes. Because most providers do not decode Swift literals, comparisons between two such dossiers now report the strings_names dimension and the overall status as unknown where they previously said unchanged. The alternative — deciding strings_names from referenced strings and names alone while disclosing the unexamined facet only as a limitation — was rejected because the existing one-sided case already reports unknown, and this change keeps the two symmetric.

Contract and boundary impact

  • Semantic owner and earliest changed stage: swiftLiteralCoverage() in src/domain/functionComparisonNormalization.ts; earliest changed stage is domain comparison normalization, before any CLI/MCP projection.
  • Contribution scope fit and linked maintainer decision: an ordinary fix inside existing boundaries; no scope decision required.
  • CLI and MCP/tool-catalog contract: no schema, field name, or tool-catalog change. compare_functions output shape is unchanged; only two status values (strings_names, overall status) can now be unknown in the case above, and the dimension gains a more accurate limitations entry for it.
  • Provider, bridge, target-format, or platform compatibility: none. No provider adapter changed.
  • Evidence, artifact, provenance, or reconstruction contract: none. Dossier schema is untouched; FUNCTION_COMPARISON_EXAMPLE now records an examined, empty literal facet so the canonical example still means "fully observed".
  • Target selection, authority, upstream behavior, and cleanup details: not applicable; the change is inert static comparison of already-captured dossiers.
  • Generated metadata / package / installation impact: none. npm run docs:check passes unchanged; no authored instructions were edited.

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.

Evidence and regression coverage

All evidence is executed source-level Vitest. There is no built runtime in the environment this was prepared in, so no CLI or built-runtime evidence and no real Hopper/Ghidra engine run — the provider behavior claims are derived from the dossier schema, fixtures and source.

Original failure, demonstrated on the base revision with a temporary probe test (run, recorded, then deleted — it is not in the diff):

BEFORE  PROBE_RESULT {"status":"unchanged","strings_names":"unchanged","summary":{"unchanged":8,"changed":0,"unknown":0}}
AFTER   PROBE_RESULT {"status":"unknown","strings_names":"unknown","summary":{"unchanged":7,"changed":0,"unknown":1}}

Regression coverage added in src/domain/functionComparison.test.ts:

  • keeps strings and names unknown when neither dossier examined Swift literals — asserts status: "unknown" and the exact new limitation string. This case had no coverage before, which is why the defect survived.
  • keeps the overall comparison unknown when neither dossier examined Swift literals — asserts the overall status is unknown.

Cases verified unchanged:

  • both sides examined and complete: differing literals still changed, identical literals still unchanged;
  • partial on one or both sides: still unknown;
  • exactly one side examined and one absent: still unknown, and the existing one-sided limitation string is byte-identical;
  • the per-site swiftLiteralSitesConflict path: behavior-identical for all four field combinations;
  • no other dimension's status changed.

Fixtures reconciled, because they encoded the defect by meaning "fully observed" while omitting the literal facet: a fullyObservedSwiftLiterals helper in functionComparison.test.ts, the base dossier in reconstructionVerification.functionSources.test.ts, and FUNCTION_COMPARISON_EXAMPLE. tests/boundary/mcp/ghidraEvidenceMcp.test.ts now expects strings_names: "unknown" for a fixture that records no literal decoding — the honest result under the new rule.

Checks actually run:

  • npx vitest run src/domain/functionComparison.test.ts src/domain/reconstructionVerification.functionSources.test.ts tests/boundary/mcp/ghidraEvidenceMcp.test.ts → 129 passed, re-run independently by the reviewer of this diff.
  • full --project domain → 3030 passed, 3 skipped.
  • every test file touching the changed example or modules → 267 passed, 3 skipped.
  • npm run check:fast → Tasks: 2 successful, 2 total (turbo typecheck + lint), exit 0.
  • npm run typecheck → exit 0. npm run lint → 0 errors, 1395 warnings. npm run verify:module-boundaries → ok.
  • npm run docs:check → Tasks: 6 successful, 6 total plus readmeConsistency 5 passed, exit 0.
  • npm run verify:test-discovery → Discovered all 1285 test files exactly once.
  • npx oxfmt on the six changed files → no reformat.

Unverified gaps: no CLI/MCP end-to-end run and no real-provider run, as stated above. npx vitest run --project mcp-boundary reports pre-existing environment failures in this clone caused by missing build artifacts (dist/, .cache/mcp-tool-catalog.json), unrelated to this change; every comparison-related file passes when run directly.

Residual related cleanup deliberately left: historical bodies in docs/releases/*.json still describe the older "absent on one side or partial" wording. Those are release history rather than current contracts, and release notes are not edited.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. No ! / BREAKING CHANGE: marker.
  • Real Hopper/Ghidra, browser, or OS coverage: none; not run. Reported as an unverified gap.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none applicable; static comparison of already-captured inert data, no target interaction.

Author readiness

Human owner: @XiaoBinGan

  • 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.

🔄 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/3563 **Author:** [@XiaoBinGan](https://github.com/XiaoBinGan) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/function-comparison-swift-literal-coverage` --- ### 📝 Commits (3) - [`a80c717`](https://github.com/morluto/rea/commit/a80c7173ec29deac0b97ad513775ff6568456829) fix(comparison): keep unexamined Swift literals unknown - [`4ce2f30`](https://github.com/morluto/rea/commit/4ce2f300db4c89574c316779aa07f54043efbaaf) Merge remote-tracking branch 'origin/main' into fix/function-comparison-swift-literal-coverage - [`e9e7def`](https://github.com/morluto/rea/commit/e9e7defbae352390824e28a9e648685078435c6d) Merge remote-tracking branch 'origin/main' into sweep/3563 ### 📊 Changes **6 files changed** (+94 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `src/contracts/functionComparisonExample.ts` (+1 -0) 📝 `src/domain/functionComparison.test.ts` (+64 -6) 📝 `src/domain/functionComparisonDimensions.ts` (+8 -13) 📝 `src/domain/functionComparisonNormalization.ts` (+17 -4) 📝 `src/domain/reconstructionVerification.functionSources.test.ts` (+1 -0) 📝 `tests/boundary/mcp/ghidraEvidenceMcp.test.ts` (+3 -1) </details> ### 📄 Description ## Summary `compare_functions` reported a **definite negative** for a facet the provider never examined. When neither dossier recorded the Swift String literal facet, the `strings_names` dimension and the overall comparison status came back `unchanged` with `unknown: 0`, even though `swift_string_literals` is documented as "absent when the provider does not decode them for this target". No issue is linked: this was found by auditing the producing boundary for the "unresolved facet silently becomes a negative result" class, not from a user report. It is the same class as the earlier `fix(comparison): keep unsupported function facets unknown (#2450)`. Base revision: `044fb9127ac77dbb4d9992410f7596fc49dc446e`. ## Problem and expected behavior Smallest trigger: compare two function dossiers that both omit `swift_string_literals`. Two places answered the same question differently: - The producing boundary, `src/domain/functionComparisonNormalization.ts`, computed `complete = swift_string_literals !== undefined && omissions.length === 0`, i.e. "undefined means never examined". Its consumer `swiftLiteralSitesConflict()` documents that a differing retained fact proves a change only when the opposite dossier is complete. - `src/domain/functionComparisonDimensions.ts` re-derived the answer locally: `swiftLiteralCoverage()` mapped `undefined -> "absent"`, and `complete = swiftLiteralCoverage(left) === swiftLiteralCoverage(right) && swiftLiteralCoverage(left) !== "partial"`. So `absent === absent` made `complete` true, both sides projected the missing facet as `[]`, and the comparison returned `unchanged` without ever consulting the owner. Violated invariant: an unresolved or unexamined facet must stay unknown rather than be treated as an observed absence. Observed before, from a probe on this base revision: ``` {"status":"unchanged","strings_names":"unchanged","summary":{"unchanged":8,"changed":0,"unknown":0}} ``` Expected and observed after: ``` {"status":"unknown","strings_names":"unknown","summary":{"unchanged":7,"changed":0,"unknown":1}} ``` ## Change and scope - `functionComparisonNormalization.ts` is now the single owner. It exports `swiftLiteralCoverage(snapshot): "absent" | "complete" | "partial"`; `swiftLiteralSites()` derives its `complete` flag from that owner instead of recomputing it. - `functionComparisonDimensions.ts` deletes its private duplicate, imports the owner, and requires **both** sides to be `"complete"` before literals may decide equality. A third limitation string states that neither dossier examined the facet. - One directly related refactor was required and completed: the duplicated coverage rule is removed rather than left in place, so the two answers cannot drift again. No other dimension, schema, output field, or pipeline stage was touched. Not included: no change to `swiftLiteralSitesConflict` semantics, no change to any other dimension, no new tool, no CLI change. **Visible behavior change worth reviewing:** `absent`/`absent` was the only input whose result changes. Because most providers do not decode Swift literals, comparisons between two such dossiers now report the `strings_names` dimension and the overall status as `unknown` where they previously said `unchanged`. The alternative — deciding `strings_names` from referenced strings and names alone while disclosing the unexamined facet only as a limitation — was rejected because the existing one-sided case already reports `unknown`, and this change keeps the two symmetric. ## Contract and boundary impact - Semantic owner and earliest changed stage: `swiftLiteralCoverage()` in `src/domain/functionComparisonNormalization.ts`; earliest changed stage is domain comparison normalization, before any CLI/MCP projection. - Contribution scope fit and linked maintainer decision: an ordinary fix inside existing boundaries; no scope decision required. - CLI and MCP/tool-catalog contract: no schema, field name, or tool-catalog change. `compare_functions` output shape is unchanged; only two status values (`strings_names`, overall `status`) can now be `unknown` in the case above, and the dimension gains a more accurate `limitations` entry for it. - Provider, bridge, target-format, or platform compatibility: none. No provider adapter changed. - Evidence, artifact, provenance, or reconstruction contract: none. Dossier schema is untouched; `FUNCTION_COMPARISON_EXAMPLE` now records an examined, empty literal facet so the canonical example still means "fully observed". - Target selection, authority, upstream behavior, and cleanup details: not applicable; the change is inert static comparison of already-captured dossiers. - Generated metadata / package / installation impact: none. `npm run docs:check` passes unchanged; no authored instructions were edited. Expected effects: - [x] 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. ## Evidence and regression coverage All evidence is executed source-level Vitest. There is no built runtime in the environment this was prepared in, so **no CLI or built-runtime evidence** and **no real Hopper/Ghidra engine run** — the provider behavior claims are derived from the dossier schema, fixtures and source. Original failure, demonstrated on the base revision with a temporary probe test (run, recorded, then deleted — it is not in the diff): ``` BEFORE PROBE_RESULT {"status":"unchanged","strings_names":"unchanged","summary":{"unchanged":8,"changed":0,"unknown":0}} AFTER PROBE_RESULT {"status":"unknown","strings_names":"unknown","summary":{"unchanged":7,"changed":0,"unknown":1}} ``` Regression coverage added in `src/domain/functionComparison.test.ts`: - `keeps strings and names unknown when neither dossier examined Swift literals` — asserts `status: "unknown"` and the exact new limitation string. This case had no coverage before, which is why the defect survived. - `keeps the overall comparison unknown when neither dossier examined Swift literals` — asserts the overall `status` is `unknown`. Cases verified unchanged: - both sides examined and complete: differing literals still `changed`, identical literals still `unchanged`; - `partial` on one or both sides: still `unknown`; - exactly one side examined and one absent: still `unknown`, and the existing one-sided limitation string is byte-identical; - the per-site `swiftLiteralSitesConflict` path: behavior-identical for all four field combinations; - no other dimension's status changed. Fixtures reconciled, because they encoded the defect by meaning "fully observed" while omitting the literal facet: a `fullyObservedSwiftLiterals` helper in `functionComparison.test.ts`, the base dossier in `reconstructionVerification.functionSources.test.ts`, and `FUNCTION_COMPARISON_EXAMPLE`. `tests/boundary/mcp/ghidraEvidenceMcp.test.ts` now expects `strings_names: "unknown"` for a fixture that records no literal decoding — the honest result under the new rule. Checks actually run: - `npx vitest run src/domain/functionComparison.test.ts src/domain/reconstructionVerification.functionSources.test.ts tests/boundary/mcp/ghidraEvidenceMcp.test.ts` → **129 passed**, re-run independently by the reviewer of this diff. - full `--project domain` → **3030 passed, 3 skipped**. - every test file touching the changed example or modules → **267 passed, 3 skipped**. - `npm run check:fast` → `Tasks: 2 successful, 2 total` (turbo typecheck + lint), exit 0. - `npm run typecheck` → exit 0. `npm run lint` → 0 errors, 1395 warnings. `npm run verify:module-boundaries` → ok. - `npm run docs:check` → `Tasks: 6 successful, 6 total` plus `readmeConsistency` 5 passed, exit 0. - `npm run verify:test-discovery` → `Discovered all 1285 test files exactly once.` - `npx oxfmt` on the six changed files → no reformat. Unverified gaps: no CLI/MCP end-to-end run and no real-provider run, as stated above. `npx vitest run --project mcp-boundary` reports pre-existing environment failures in this clone caused by missing build artifacts (`dist/`, `.cache/mcp-tool-catalog.json`), unrelated to this change; every comparison-related file passes when run directly. Residual related cleanup deliberately left: historical bodies in `docs/releases/*.json` still describe the older "absent on one side or partial" wording. Those are release history rather than current contracts, and release notes are not edited. ## Compatibility, safety, and release - Breaking changes or migration steps: none. No `!` / `BREAKING CHANGE:` marker. - Real Hopper/Ghidra, browser, or OS coverage: none; not run. Reported as an unverified gap. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none applicable; static comparison of already-captured inert data, no target interaction. ## Author readiness <!-- The human owner completes these declarations before requesting review. --> Human owner: @XiaoBinGan - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] 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. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:09:44 +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#5828
No description provided.