Repository navigation
feat: Phase 2 traceability and output stability for diff and enforce - #5
Merged
Merged
Conversation
- Add stableId, contractRef, ruleRef to diff and enforce JSON output - Shared computeStableId helper with normalized inputs for cross-OS determinism - contractRef overclaim fix: omit path when rule is contract.surface-missing - Consolidate traceability field definitions in API.md with backwards compat note - Add traceability.test.mjs and traceability fixture - Extend validator types and output schemas with optional traceability fields Ref: docs/plans/phase-2-traceability-output-stability.md Co-authored-by: Cursor <cursoragent@cursor.com>
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.
PR Description: Phase 2 Traceability and Output Stability
Use this content when opening the PR. Reference: docs/plans/phase-2-traceability-output-stability.md.
Title
feat: Phase 2 traceability and output stability for diff and enforce
Strategy check
What changed
stableId,contractRef(path, surfaceId, sectionId, constraintId when derivable), andruleRef(id). Added sharedcomputeStableIdhelper with normalized inputs for cross-OS determinism.stableId,contractRef, andruleRefwhen deterministically derivable.ContractRef,RuleRef; extendedDiffEntry,FixEntry,FixErrorwith traceability fields. Output schemas updated to allow new optional properties.traceability.test.mjsverifies output shape, stableId presence, contractRef/ruleRef, and stableId determinism across runs. Newtraceabilityfixture for diff/enforce integration.Why it matters
Downstream tools can correlate diff entries and enforce findings across runs. stableId enables deduplication and change tracking. contractRef and ruleRef support debugging and mapping back to contract structure.
Contract and enforcement notes
Phase 2 Acceptance Criteria (from docs/plans/phase-2-traceability-output-stability.md)
diff --format jsonemitsstableIdfor every entry.diffentries includecontractRef.pathfor all cases where a contract node is unambiguous.enforce --format jsonemitsstableIdfor applied and skipped actions.enforceoutput includescontractRefandruleRefwhen deterministically derivable.Tests
test/traceability.test.mjs: 6 tests for diff/enforce output shape, stableId, contractRef, ruleRef, determinism.test/fixtures/traceability/: New fixture with contract that produces diffs; policy that produces applied fixes.test/fixtures/examples/diff.json: Updated with traceability fields.ensureRelativePathsfix: observed.root no longer empty when workspace equals observed root (schema minLength).Phase 2 Pre-Merge Verification (completed)
Phase 2 Review Checklist