Skip to content

feat(ISSUE-47): add signature-lock gate#48

Open
abao-bot[bot] wants to merge 9 commits into
mainfrom
dev_type_signature_lock
Open

feat(ISSUE-47): add signature-lock gate#48
abao-bot[bot] wants to merge 9 commits into
mainfrom
dev_type_signature_lock

Conversation

@abao-bot

@abao-bot abao-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Adds a new module gate: signature-lock.

Each directory's MODULE.md may declare signature-lock entries of the
form 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.

  • New gate file src/gates/signature-gate.ts wired into the
    run-gates cascade between sealed and export.
  • Per-language signature-checkers under src/gates/signature-checkers/
    (TypeScript/JavaScript, Rust, Java, Go, Kotlin, Scala) — regex-based
    extraction; no AST dependency added.
  • The legacy src/gates/checkers/ directory has been renamed to
    src/gates/export-checkers/ to make room for the parallel
    signature-checkers; all import sites updated.
  • README documents the new syntax, semantics, and v1 limitations.
  • Closes type signature lock #47

cuzfrog added 9 commits June 28, 2026 16:33
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

type signature lock

1 participant