refactor: make invalid states unrepresentable - #282
Merged
Conversation
morluto
marked this pull request as ready for review
August 9, 2026 14:58
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replace permissive internal data bags with parsed, product-owned values so invalid combinations are rejected at acquisition, JSON, and persistence boundaries instead of being revalidated throughout the application.
The change applies four related rules across the codebase:
Owner/Reposhape explicitly preserved and backward-decoding covered by tests.The MCP follow-through keeps the official Go SDK responsible for typed tool decoding, JSON Schema validation, structured results, tool-error conversion, cancellation, prompt/resource registration, and stdio transport. GitContribute retains only domain schema refinements the SDK cannot infer: closed recovery unions, cross-field modes, bounds, defaults, and enums. The adapter now explicitly disables the SDK's historical default logging capability because the server does not implement a logging surface, and the redundant mutable schema cache/deep-clone machinery has been removed.
This also removes duplicate code-index metadata, narrows post-job follow-ups to read and poll actions, preserves known projections during partial observations, and keeps sparse archive observations unknown when they cannot form a valid thread projection.
The diff is cross-cutting because constructor and accessor changes propagate through their callers, tests, and adapters. The follow-up commits isolate the MCP SDK cleanup, recovery encoding fix, and CI test topology so each can be reviewed independently.
Testing
make verifypassesmake test-racepassesgit diff --checkpassesmake verifycovered uncached tests,go vet, repository-wide lint with zero issues, module tidiness, generated-output checks, and documentation validation.make test-racepassed acrossinternal/app,internal/corpus,internal/mcpserver, andinternal/workspace.Compatibility and scope
The durable repository JSON format remains flattened and backward compatible; no migration or new format version is needed. Malformed or contradictory durable records and MCP recovery payloads are now rejected intentionally. Corpus reads remain offline, and no GitHub mutation capability is introduced.
The recovery action wire shape is unchanged. Its encoder now uses a growable buffer instead of computing an allocation capacity from input lengths, removing the overflow path reported by CodeQL.
Diff size: 245 files, 5,680 insertions, 2,413 deletions.
Suggested review order
internal/domain,internal/evidence, andinternal/research.internal/corpus.internal/mcpcontractandinternal/mcpserver.internal/app, then adapter migrations anddocs/architecture.md.