feat(ISSUE-47): add signature-lock gate#48
Open
abao-bot[bot] wants to merge 9 commits into
Open
Conversation
Add SignatureLockEntry type and signatureLock field to ModuleContract. Add parseSignatureLockEntry to frontmatter-parser with case validation. Propagate signatureLock into contracts built by module-index-builder. Also fix pre-existing test infrastructure: - Update stale import paths from checkers/ to export-checkers/ in sealed-gate.test.ts, export-gate.test.ts, run-gates.test.ts, and test/skills/seal-all.test.ts. - Update validation.test.ts vi.mock target from checkers/ to export-checkers/ (Step 18 of the plan). - Add signatureLock: [] to all existing test contract literals to satisfy the new required ModuleContract field.
Add two cases to module-index-builder.test.ts: - Populates signatureLock entries from frontmatter via parseSignatureLockEntry. - Defaults signatureLock to empty array when frontmatter omits the key.
- registry.ts: SignatureChecker interface (extensions + getSignatures), register/getSignatureChecker exports. Differs from ExportChecker by returning name->signature text map; gate performs before/after diff. - typescript.ts: regex extraction for function, class head, interface body, and type alias RHS for TS/JS/MTS/CTS/MJS/CJS. - rust/java/go/kotlin/scala.ts: stub checkers returning empty Map for languages whose signature patterns are not yet implemented. - index.ts: aggregator that side-effect-imports all checkers and re-exports the registry. - MODULE.md: seals the public surface of the directory.
- signature-gate.ts: mirrors sealed-gate.ts. Walks ancestor contracts, resolves each signatureLock entry via matchesPattern against the edited file, and blocks when the locked symbol's extracted signature differs between before and after snapshots. - signature-gate.test.ts: 12 cases covering body-only edits, function param changes, interface body changes, type alias RHS changes, lock misses, ancestor-walk, no-checker extensions, sibling-file non-firing, and reason composition. - getAncestorContracts now also returns signatureLock so the gate can iterate lock entries; utils.test.ts updated to expect the new field.
16 co-located cases covering function signatures (sync/async/generic/default
param values), class heads (extends/implements, decorator stripping),
interface body capture, type alias RHS, declare modifier, generator
functions, indented declarations, value-binding exclusion (const), and
multi-signature files.
The typescript checker was also refined: capture starts after decorators,
results are trimmed of leading whitespace, and findTypeEnd bails on '{' or
'}' so type literals don't extend the captured text.
…dd cascade tests - run-gates.ts imports checkSignature and side-effect-registers the signature-checkers aggregator. The signature check runs after sealed and before exports, matching the plan's cascade order. - run-gates.test.ts: two new cases verifying the cascade: locked signature param change blocks with 'Signature rule', body-only edit on locked signature passes.
… update glossary - src/index.ts: side-effect-import the new signature-checkers aggregator alongside the export-checkers aggregator. - src/gates/MODULE.md: seal signature-gate.ts and signature-gate.test.ts to match the surrounding gate files. - system-prompt.template.md: add signature-lock glossary entry with the file$Name syntax and the body-remains-editable note.
- README.md: mention signature-lock in the contract list, add a new 'Signature gate' bullet in the How-it-works list, point to the new signature-checkers directory, and add a 'Type Signature Lock (signature-gate)' subsection with the file$Name syntax, body editable semantics, and v1 limitations. - doc/Development.md: replace stale gates/checkers/ tree references with gates/export-checkers/ and gates/signature-checkers/, and split the 'Adding a checker' instructions into export and signature variants.
- Rename gates/checkers/ to gates/export-checkers/ and update all import sites (export-gate, sealed-gate, validation, claude hook). - Replace TS/Java/Rust/Go/Kotlin/Scala signature checker stubs with full regex-based extractors covering fn/class/interface/type alias heads (plus enums and namespaces in TS, traits in Scala, etc.). - Cover each language with thorough unit tests: TS 84, Rust 55, Java 27, Go 44, Kotlin 73, Scala 63. - Seal the new .test.ts files in signature-checkers/MODULE.md. - Drop the 'stubs only for non-TS languages' caveat from README. - Bump version to 0.20.0.
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.
Adds a new module gate: signature-lock.
Each directory's MODULE.md may declare
signature-lockentries of theform
file$Name, locking the captured signature of the named symbol.The body of the declaration remains editable; only the captured head
(parameter list, return type, generics, class
extends/implements,interface body, or type alias RHS) must remain unchanged.
src/gates/signature-gate.tswired into therun-gates cascade between sealed and export.
src/gates/signature-checkers/(TypeScript/JavaScript, Rust, Java, Go, Kotlin, Scala) — regex-based
extraction; no AST dependency added.
src/gates/checkers/directory has been renamed tosrc/gates/export-checkers/to make room for the parallelsignature-checkers; all import sites updated.