Skip to content

Commit d0f95e6

Browse files
committed
chore(sync): cascade fleet template@00f7718
Auto-applied by socket-wheelhouse sync-scaffolding into socket-registry. 18 file(s) touched: - .claude/hooks/lock-step-ref-guard/README.md - .claude/hooks/lock-step-ref-guard/index.mts - .claude/hooks/lock-step-ref-guard/package.json - .claude/hooks/lock-step-ref-guard/test/index.test.mts - .claude/hooks/lock-step-ref-guard/tsconfig.json - .claude/hooks/no-file-scope-oxlint-disable-guard/README.md - .claude/hooks/no-file-scope-oxlint-disable-guard/index.mts - .claude/hooks/no-file-scope-oxlint-disable-guard/package.json - .claude/hooks/no-file-scope-oxlint-disable-guard/tsconfig.json - .config/oxlint-plugin/index.mts - .config/oxlint-plugin/rules/no-cached-for-on-iterable.mts - .config/oxlint-plugin/rules/no-file-scope-oxlint-disable.mts - .config/oxlint-plugin/test/no-cached-for-on-iterable.test.mts - docs/claude.md/fleet/parser-comments.md - scripts/check-lock-step-header.mts - scripts/check-lock-step-refs.mts - scripts/test/check-lock-step-header.test.mts - scripts/test/check-lock-step-refs.test.mts
1 parent 2108f48 commit d0f95e6

18 files changed

Lines changed: 2210 additions & 60 deletions
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# lock-step-ref-guard
2+
3+
PreToolUse hook (informational; never blocks) that flags malformed and stale `Lock-step` comments at the moment they land in a file.
4+
5+
## Why
6+
7+
Per CLAUDE.md's _Code style → Cross-port files_ rule, files that ship in multiple language implementations use a `Lock-step` comment convention to cross-reference the canonical impl. The full forms live in [`docs/claude.md/fleet/parser-comments.md`](../../../docs/claude.md/fleet/parser-comments.md) §5–6.
8+
9+
The CI gate (`scripts/check-lock-step-refs.mts`) catches stale `<path>` references at commit time, but two classes of bugs slip past it:
10+
11+
1. **Typos in the `Lock-step` shape itself**`lockstep`, `Lock step`, `Lock-step Rust:` (missing `with`/`from`), `Lock-step with: <path>` (missing `<Lang>`). The CI regex doesn't match these, so they silently rot forever as illegitimate comments.
12+
2. **Same-keystroke staleness** — a porter typing `// Lock-step with Rust: crates/parser-stmt/src/foo.rs` after `parser-stmt/` was renamed last week. The CI gate catches it at commit; the hook catches it at the keystroke so the porter sees the breadcrumb before committing.
13+
14+
## What it catches
15+
16+
**Malformed:**
17+
18+
```rust
19+
// lockstep with Go: parser.go:42 // wrong: hyphen missing
20+
// Lock step with Go: parser.go:42 // wrong: hyphen missing
21+
// Lock-step Rust: src/foo.rs // wrong: missing with/from
22+
// Lock-step with: src/foo.rs // wrong: missing <Lang>
23+
// Lock-step with Go, parser.go // wrong: comma instead of colon
24+
```
25+
26+
**Stale (when `.config/lock-step-refs.json` is present):**
27+
28+
```rust
29+
// Lock-step with Rust: crates/parser-stmt/src/foo.rs // crate doesn't exist
30+
//! Lock-step from Go: src/parser-old/class.go // dir was renamed
31+
```
32+
33+
**Accepted:**
34+
35+
```rust
36+
//! Lock-step with Go: src/parser/class.go
37+
//! Lock-step from Rust: crates/parser/src/class.rs
38+
// Lock-step with Go: parser.go:6450-6457
39+
// Lock-step note: reshaped for borrowck — Zig's `defer s.restore()` ...
40+
```
41+
42+
## Scope
43+
44+
- Source-file extensions: `.rs`, `.go`, `.cpp`, `.hpp`, `.h`, `.ts`, `.mts`, `.cts`, `.tsx`, `.py`, `.zig`, `.js`, `.mjs`, `.cjs`, `.jsx`.
45+
- Skips `test/` directories and `*.test.*` files — illustrative example refs are common in tests and don't represent real port-tracking claims.
46+
- Stale-path checking is **opt-in per repo**: requires `.config/lock-step-refs.json` to declare `<Lang>` → impl-root mappings. Without the config, only malformed-shape detection runs.
47+
- Malformed-shape detection always runs, regardless of opt-in. Typos are typos.
48+
49+
## Behavior
50+
51+
- Exit code 0 in all cases. Hook is informational; the next turn sees the stderr breadcrumb and can fix.
52+
- The blocking layer is the CI gate `scripts/check-lock-step-refs.mts`, run by `pnpm check`.
53+
54+
## Bypass
55+
56+
- Type `Allow lock-step bypass` in a recent user message (also accepts `Allow lockstep bypass` / `Allow lock step bypass`), or
57+
- Set `SOCKET_LOCK_STEP_REF_GUARD_DISABLED=1`.
58+
59+
## Test
60+
61+
```sh
62+
pnpm test
63+
```

0 commit comments

Comments
 (0)