Skip to content

refactor(domain): replace production prose/regex limitation matching with typed discriminators - #14359

Merged
morluto merged 3 commits into
mainfrom
refactor/14347-typed-limitation-discriminators
Nov 24, 2026
Merged

morluto merged 3 commits into
mainfrom
refactor/14347-typed-limitation-discriminators

Conversation

@morluto

@morluto morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Closes #14347

Summary

Replaces production prose/regex limitation and error-message matching with typed discriminators across all five sites identified in #14347:

  1. KernelBuildConfigService (src/application/binaryDiagnostics/KernelBuildConfigService.ts): Removed the .includes("untrusted") prose scan in validReport; untrustedness is enforced via structured trust: "target-derived-untrusted" fields on banner and config.entries[*] alongside non-empty limitations.
  2. Ghidra Function Dossier (src/domain/native/functionDossier.ts, src/ghidra/GhidraFunctionValues.ts, bridge/ghidra/ReaGhidraBridge.java): Added typed functionDossierLimitationCodeSchema (unresolved_computed_or_indirect_flows, provider_specific_representations), emitted limitation_codes from ReaGhidraBridge.java, and replaced the /indirect|computed/u and /provider|Ghidra|Hopper/u regex checks in ghidraFunctionDossier with typed code validation.
  3. Relationship Coverage (src/domain/relationshipCoverage.ts, src/domain/functionCallCoverage.ts, producers): Made limited_directions required on partialRelationshipCoverageSchema and unknownRelationshipCoverageSchema, updated all producers (IdaOperationRunner, IdaCallGraph, CallPathTracing, EnhancedTools, AnalysisSnapshotCache, BinarySession), and removed the startsWith("Callers: ") / !includes("Callees: ") prose fallback from isCallerOnlyIncompleteCoverage.
  4. ELF Binary Diagnostics (src/domain/native/elfDebugLink.ts, src/native/elf/ElfDebugLink.ts, src/native/elf/ElfDebugLinkProvider.ts, src/application/binaryDiagnostics/ElfDebugLinkService.ts, src/domain/native/elfUnwindRanges.ts, src/native/elf/ElfUnwindTables.ts, src/application/binaryDiagnostics/ElfUnwindRangesService.ts): Added typed limitation_codes schemas and producer emissions, and replaced all production .includes(ELF_*_LIMITATION) prose checks in ElfDebugLinkService and ElfUnwindRangesService with typed code checks.
  5. Windows Owned Process (src/windows/WindowsOwnedProcess.ts): Removed the 27-sentence WINDOWS_CONTROL_SPAWN_CONSTRAINTS list and all cause.message.startsWith(...) fallbacks in isWindowsExecutableLaunchFailure and windowsNativeSpawnControlError, classifying spawn failures solely via structured constraint codes set at the N-API FFI boundary.

Fail-Closed Invariants Preserved

  • Missing, omitted, or unrecognized typed limitation codes in ghidraFunctionDossier, ElfDebugLinkService, and ElfUnwindRangesService are rejected at the schema/service boundary.
  • partial and unknown relationship coverage records without limited_directions are rejected by relationshipCoverageSchema.
  • KernelBuildConfigService.validReport still rejects empty limitations or non-"target-derived-untrusted" trust fields.
  • Native Windows spawn errors with absent, empty, or unrecognized constraint codes fail closed as host-control (WindowsNativeSpawnControlError) rather than being silently classified as target executable launch failures; ordinary non-Windows POSIX errors remain unaffected.

Validation

  • npm run typecheck && npm run lint && npm run verify:architecture-guards: passed (0 errors across 8,089 linted files, 4,770 module-boundary files, 3,088 architecture-guard files).
  • npm run test:local across 15 unit test files (503/503 passed) and 13 additional service/adapter test files (259/259 passed after updating AnalysisSnapshotCache.test.ts).
  • npx vitest run across 10 boundary, composition, and snapshot cache suites (elfDebugLink, elfUnwindRanges, kernelBuildConfig, functionComparisonCoverageMcp, enhancedTools.callPathsAndBatches, nativeObservationViewsMcp, workflowUnknownIdentityMcp, analysisViewMcp, reverseProviderLaunchErrors, AnalysisSnapshotCache): 185/185 passed.
  • Real-provider Ghidra/Windows native runtime verification was not executed in this macOS worktree environment.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-24T12:06:40.611987Z
We couldn’t complete this review. Comment @codex review to try again.
982d2e6 PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no actionable issue remains.

Summary

The PR replaces decisions based on limitation text with typed facts across binary diagnostics, Ghidra dossiers, relationship coverage, and Windows launch errors.

  • Ghidra function dossiers carry typed uncertainty codes.
  • Incomplete relationship coverage names the directions it limits.
  • ELF debug-link checks use typed limitation codes.
  • ELF unwind checks use typed limitation codes.
  • Kernel build-config reports keep trust checks separate from caveat text.
  • Windows process launches use structured constraints to classify spawn failures.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  P["Provider emits typed facts"] --> L["Live checks"]
  L --> E["Evidence"]
  S["Saved format-2 coverage"] --> H["Historical reader preserves omitted directions"]
  H --> E
  E --> G["Graph projection adds required directions"]
  G --> O["Strict graph output"]
Loading

Reviews (3) · Last reviewed commit: "test(mcp): align boundary coverage fixtu..." · Reviewed by Greptile

Comment thread src/domain/relationshipCoverage.ts Resolved
@morluto
morluto enabled auto-merge (squash) November 24, 2026 14:00
@morluto
morluto disabled auto-merge November 24, 2026 16:05
@morluto
morluto merged commit 72bdcad into main Nov 24, 2026
105 of 113 checks passed
@morluto
morluto deleted the refactor/14347-typed-limitation-discriminators branch November 24, 2026 16:05
@morluto morluto added the area: domain Domain logic, errors, and pure functions label Nov 26, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Design] Replace production prose/regex matching on limitations and error strings with typed discriminators

1 participant