Skip to content

Commit d93517f

Browse files
docs(mosaic): check parity with a proof file that Claude and Codex hooks can both read
1 parent 7317272 commit d93517f

10 files changed

Lines changed: 285 additions & 150 deletions

‎.claude/hooks/mosaic-hook-utils.mjs‎

Lines changed: 0 additions & 41 deletions
This file was deleted.

‎.claude/hooks/require-mosaic-legacy-read.mjs‎

Lines changed: 0 additions & 48 deletions
This file was deleted.

‎.claude/hooks/require-mosaic-parity-audit.mjs‎

Lines changed: 0 additions & 49 deletions
This file was deleted.

‎.claude/settings.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"hooks": [
4242
{
4343
"type": "command",
44-
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/require-mosaic-legacy-read.mjs\"",
44+
"command": "node \"$(git rev-parse --show-toplevel)/scripts/mosaic-parity-gate.mjs\" write",
4545
"timeout": 10
4646
}
4747
]
@@ -62,8 +62,8 @@
6262
},
6363
{
6464
"type": "command",
65-
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/require-mosaic-parity-audit.mjs\"",
66-
"timeout": 10
65+
"command": "node \"$(git rev-parse --show-toplevel)/scripts/mosaic-parity-gate.mjs\" stop",
66+
"timeout": 30
6767
}
6868
]
6969
}

‎.codex/hooks.json‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@
1212
"type": "command",
1313
"command": "cd \"$(git rev-parse --show-toplevel)\" && { git diff --name-only --diff-filter=d HEAD -- packages/swingset/src; git ls-files --others --exclude-standard -- packages/swingset/src; } | grep -E '\\.tsx?$' | xargs -r pnpm exec eslint --quiet --no-warn-ignored --rule 'import/no-unresolved: off' >&2 || exit 2",
1414
"timeout": 180
15+
},
16+
{
17+
"type": "command",
18+
"command": "node \"$(git rev-parse --show-toplevel)/scripts/mosaic-parity-gate.mjs\" stop",
19+
"timeout": 30
20+
}
21+
]
22+
}
23+
],
24+
"PreToolUse": [
25+
{
26+
"matcher": "apply_patch|Edit|Write",
27+
"hooks": [
28+
{
29+
"type": "command",
30+
"command": "node \"$(git rev-parse --show-toplevel)/scripts/mosaic-parity-gate.mjs\" write",
31+
"timeout": 10
1532
}
1633
]
1734
}

‎packages/mosaic/AGENTS.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ Read the guide for the task you are doing. Paths below are relative to this pack
2828

2929
Before you write a new feature, search `packages/react/src/components/` and `packages/ui/src/components/` for its counterpart. If one exists, the work is a [migration](docs/migration.md), including a headless port of a `@clerk/react` button framed as a new feature:
3030

31-
1. Read the counterpart and write the Phase 1 inventory before the model.
32-
2. Before you call the work done, review it, or open a PR, launch the Explore subagent with the prompt in [Parity audit](docs/parity-audit.md). Reading the doc is not running the audit.
31+
1. Read the counterpart and write the Phase 1 inventory to `tmp/mosaic-parity/<feature>.md` before the model. The file names the legacy path and has an `## Inventory` section.
32+
2. Before you call the work done, review it, or open a PR, run the [parity audit](docs/parity-audit.md) in a read-only subagent and put its table under `## Parity audit` in the same file. Reading the doc is not running the audit.
3333
3. List every **Deliberately changed** and **Deferred** row in the PR description. A difference that is not listed is a regression.
3434
4. Listing a difference does not make it acceptable. If one breaks a rule in this file or in `docs/`, such as a failure that nobody sees, fix it or ask the user before you finish. Do not label it deliberate.
3535

36+
`tmp/` is ignored by git, so the file stays out of the PR. Hooks in `.claude/settings.json` and `.codex/hooks.json` (`scripts/mosaic-parity-gate.mjs`) check it: one blocks writing a new feature's model until the inventory exists, and one blocks finishing until the audit is in.
37+
3638
## Layers in one paragraph
3739

3840
A flow lives in `src/features/<feature>/`. The **model** (`*.model.ts(x)`) is the only file that reads Clerk hooks or calls Clerk resources, and answers with plain data, plain callbacks and a `status`. The **controller** (`*.controller.ts(x)`) holds local state and wraps the model's callbacks for pending, errors and closing. The **view** (`*.view.tsx`) renders plain props. No Clerk resource reaches the controller and no machine snapshot reaches the view.

‎packages/mosaic/docs/migration.md‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ Turn the hits into a **behavior inventory** — one row per: effect, guard, erro
5454
path, empty/loading state, permission gate, revalidate, reset-on-close, derived
5555
label. This list is finite and is the contract the migration must satisfy.
5656

57+
Write it to `tmp/mosaic-parity/<feature>.md` (ignored by git) before the model:
58+
59+
```md
60+
# sign-out-button parity
61+
62+
Legacy: packages/react/src/components/SignOutButton.tsx
63+
64+
## Inventory
65+
66+
- `redirectUrl` defaults to `/`
67+
- …
68+
```
69+
5770
## Phase 2 — Design the split (map every row to a layer)
5871

5972
Assign each inventory row to exactly one layer. A row with no home is a behavior
@@ -104,7 +117,7 @@ empty states) each have one.
104117
Tests only cover branches you remembered to write. To catch the
105118
ones you didn't, run an automated diff of legacy against new.
106119

107-
Launch an **Explore subagent** with the prompt in `parity-audit.md`. Give it the
120+
Launch a read-only subagent (Explore in Claude Code) with the prompt in `parity-audit.md`. Give it the
108121
legacy file paths and the new model/controller/view paths. It returns a table
109122
classifying every legacy behavior as:
110123

@@ -116,9 +129,9 @@ classifying every legacy behavior as:
116129
how an earlier domains-section migration shipped three regressions (see
117130
`parity-audit.md`).
118131

119-
Every inventory row from Phase 1 must land in exactly one bucket. The table is
120-
**ephemeral**: it drives the work and the PR discussion, then is discarded. It is
121-
not committed.
132+
Every inventory row from Phase 1 must land in exactly one bucket. Put the table
133+
under `## Parity audit` in `tmp/mosaic-parity/<feature>.md`. It drives the work
134+
and the PR discussion, and is never committed.
122135

123136
## Phase 5 — Ship
124137

‎packages/mosaic/docs/parity-audit.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ legacy component against the new model/controller/view and classifies every
55
legacy behavior, so behavior that lived implicitly in the old blob can't be
66
silently dropped.
77

8-
Run it as an **Explore subagent** (read-only, returns a conclusion, not file
9-
dumps). It is **ephemeral** — the table guides the work and the PR discussion,
10-
then is discarded. Nothing is committed.
8+
Run it as a read-only subagent (Explore in Claude Code) that returns a
9+
conclusion, not file dumps. Put its table under `## Parity audit` in
10+
`tmp/mosaic-parity/<feature>.md`, next to the Phase 1 inventory. The table guides
11+
the work and the PR discussion. `tmp/` is ignored by git, so nothing is committed.
1112

1213
## The subagent prompt
1314

0 commit comments

Comments
 (0)