Repository navigation
Commit 45e4457
docs(adr-0162): anchor the showcase's three paid-invoice line hooks by file, not by symbol (#38936)
Fixes #38919
Refs #37771, PR #38917
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:用户无感;只是一份架构决策记录里两处「去哪看代码」的指向,从三段代码的名字改成它们所在的文件,句子的意思不变。
-
为什么做:替「示例应用的已付款发票改用关账状态」那项工作清路;它要删掉这三段手写代码,而记录按名字指着它们,不先改指向,那边的检查会变红、合不进去。
- 出错会怎样:最坏是读记录的人顺着指向只找到文件、找不到那三段代码;不影响任何运行中的功能,撤回这一个改动即可复原。
- 要你做什么:批准这个只改两行的改动(架构决策记录归你审)。
## What changes
One file, two lines, anchors only.
`docs/adr/0162-an-object-declares-its-closed-states-the-record-and-its-lines-are-closed-to-change.md`
cited the showcase's three hand-written paid-invoice line hooks by
symbol name in two places. Both now cite the file the hooks live in, as
a file-level anchor:
- line 77: Context, item 3, "Hand-written hooks";
- line 718: the showcase row of the Readings table taken at
`6c290d3af7`.
In both, the same three code spans become one:
```diff
-`examples/app-showcase/src/data/hooks/index.ts#GuardPaidInvoiceLineAddHook`, `#GuardPaidInvoiceLineMoveHook`, `#GuardPaidInvoiceLineRemoveHook`
+`examples/app-showcase/src/data/hooks/index.ts`
```
Why now. The record's own Execution item 3 has those three hooks deleted
when the showcase converts to a `closedStates` declaration. That
conversion is #37771 (draft PR #38917). A symbol anchor cannot outlive
the symbol it names, and an implementation card's file surface excludes
`docs/adr/**`, so the conversion would turn `check:adr-symbol-anchors`
red with no way to clear it from its own PR. The file itself stays (PR
#38917 changes it by +3/-121 and keeps it), so a file-level anchor holds
before and after.
The sentences keep their meaning. Each still says: three hooks, in that
file, the worked example at this record's writing. No word outside the
two anchor spans changed, and no `anchor-exempt` marker was added.
## Tests
No test is owed and none was added: the diff is one markdown record, it
touches no package, and nothing a test pins moved, so there is no
ablation either.
The proof the card asks for is the anchor gate, `node
scripts/check-adr-symbol-anchors.mjs`, run five ways. Runs B to E are on
head `422b3570`; run A is the same tree before the edit, base
`8338d070`.
| Run | ADR-0162 | the rest of the tree | exit | what the gate printed |
|---|---|---|---|---|
| A | base text, symbol anchors | as on `main` | 0 | 4642 anchors, 1759
symbol, 2831 file-level, 134 continuation |
| B | this PR | as on `main` | 0 | 4638 anchors, 1753 symbol, 2833
file-level, 130 continuation |
| C | this PR | `hooks/index.ts` at PR #38917's version, the three
symbols deleted | 0 | the same line as B |
| D, control | base text, symbol anchors | `hooks/index.ts` at PR
#38917's version | 1 | 6 `unresolved-symbol` findings: lines 77 and 718,
three each |
| E | this PR | this head merged with PR #38917's head, all 8 files that
PR changes | 0 | the same line as B |
A to B is exactly the edit: six symbol anchors out (four of them
continuations), two file-level anchors in. D is the negative control:
the deletion that leaves this PR green turns the record red when it is
not re-anchored, on those two lines and on nothing else in
`docs/adr/**`. E is the wider reading: the merge of this head with PR
#38917's head (`git merge-tree`, no conflict) is still green, so on this
gate this PR is all that #37771 is waiting for.
The mutation was the real one, not a hand deletion. For C and D,
`hooks/index.ts` was replaced on disk by its blob at PR #38917's head
`b50ff469`; that it landed was read from the disk: `git hash-object`
equal to that blob (`ba84ee2c`), and `grep -c` of each of the three
names reading 0 (2 each before). For E, the 8 merged blobs were written
and each checked the same way. Every file was then restored from `HEAD`,
and the restore was proven by blob hash, an empty `git diff HEAD` and a
clean `git status`. Nothing was staged or committed, and no ref was
written.
<details><summary>Runs A to E: exit codes and the gate's own
lines</summary>
```text
RUN A (base 8338d07, before the edit) :: exit 0
check-adr-symbol-anchors: 4642 anchors across 165 records resolve — 1759 symbol (1730 declaration, 29 literal), 2831 file-level, 52 cross-repo, 6 exempt, 134 continuation.
RUN B (head 422b357) :: exit 0
check-adr-symbol-anchors: 4638 anchors across 165 records resolve — 1753 symbol (1724 declaration, 29 literal), 2833 file-level, 52 cross-repo, 6 exempt, 130 continuation.
RUN C (head 422b357 + hooks/index.ts at PR 38917's blob ba84ee2) :: exit 0
check-adr-symbol-anchors: 4638 anchors across 165 records resolve — 1753 symbol (1724 declaration, 29 literal), 2833 file-level, 52 cross-repo, 6 exempt, 130 continuation.
RUN D (ADR-0162 at its base blob 7396a76 + hooks/index.ts at blob ba84ee2) :: exit 1
check-adr-symbol-anchors: 6 finding(s) across 165 records.
[unresolved-symbol] docs/adr/0162-…-closed-to-change.md:77 `examples/app-showcase/src/data/hooks/index.ts#GuardPaidInvoiceLineAddHook`
[unresolved-symbol] docs/adr/0162-…-closed-to-change.md:77 `#GuardPaidInvoiceLineMoveHook`
[unresolved-symbol] docs/adr/0162-…-closed-to-change.md:77 `#GuardPaidInvoiceLineRemoveHook`
[unresolved-symbol] docs/adr/0162-…-closed-to-change.md:718 `examples/app-showcase/src/data/hooks/index.ts#GuardPaidInvoiceLineAddHook`
[unresolved-symbol] docs/adr/0162-…-closed-to-change.md:718 `#GuardPaidInvoiceLineMoveHook`
[unresolved-symbol] docs/adr/0162-…-closed-to-change.md:718 `#GuardPaidInvoiceLineRemoveHook`
RESTORE: ADR blob 4fa103d == HEAD, hooks blob 74392b4 == HEAD, git diff HEAD empty, git status clean
RUN B2 (restored head 422b357) :: exit 0, the same line as RUN B
RUN E (head 422b357 merged with PR 38917's head b50ff46: merge-tree exit 0, tree 380232b5, 8 paths differ from this head) :: exit 0
check-adr-symbol-anchors: 4638 anchors across 165 records resolve — 1753 symbol (1724 declaration, 29 literal), 2833 file-level, 52 cross-repo, 6 exempt, 130 continuation.
RESTORE: all 8 paths' blobs == HEAD, git diff HEAD empty, git status clean
```
Each verdict line is quoted without its leading status mark and cut
after its counts; the gate goes on to print its standing caveat about
the path-less spellings it does not judge. The record's file name is
shortened in the findings.
</details>
<details><summary>What the gate's extractor reads on the two lines, base
against head</summary>
```text
base L77 : 4 anchors: symbol hooks/index.ts#GuardPaidInvoiceLineAddHook | file-level objects/invoice.object.ts | symbol (continuation) hooks/index.ts#GuardPaidInvoiceLineMoveHook | symbol (continuation) hooks/index.ts#GuardPaidInvoiceLineRemoveHook
base L718: 4 anchors: the same four
head L77 : 2 anchors: file-level hooks/index.ts | file-level objects/invoice.object.ts
head L718: 2 anchors: the same two
whole record, base: 223 anchors, 168 symbol, 55 file-level, 26 continuation
whole record, head: 219 anchors, 162 symbol, 57 file-level, 22 continuation
```
Read with the gate's own `extractAnchors` over `git show` of each
revision, in the order it returns them; the
`examples/app-showcase/src/data/` prefix is dropped here.
</details>
## Acceptance notes
- Done when, item by item. Lines 77 and 718 anchor the file and not the
three symbols: `grep -c GuardPaidInvoiceLine` on the record reads 0.
`check:adr-symbol-anchors` is green on this PR alone: run B, exit 0. No
other line of ADR-0162 changes: `git diff --numstat origin/main...HEAD`
reads `2 2` on that one file, at lines 77 and 718.
- What a file-level anchor is worth in this corpus, measured from the
resolver before relying on it: it is counted, not judged. `docs/adr/**`
registers its corpus with `checkBarePaths` off (the default of
`scripts/symbol-anchors.mjs#defineCorpus`; `#sweepCorpus` records why,
judging bare paths there was measured at 1,056 findings). So this gate
stays green on the two lines whatever happens to the file, and it will
not notice if the file is ever moved or removed. That the file exists
was therefore checked by hand: it is tracked at this head, and it is
present at PR #38917's head. The gate header's sentence that a symbol
anchor and a file-level anchor "both stay checked" is wider than what
this corpus does for the second. Noted, not filed.
- After #37771 lands, line 77 (Context, in the present tense) and line
718 (a reading dated `6c290d3af7`) describe the showcase as it stood at
the record's writing; the file they cite will no longer hold the three
hooks. The card rules that the sentences keep that meaning, and the
record's Execution item 3 already says the hooks are deleted. Noted, not
filed.
- No changeset: `docs/adr/**` ships in no package, so the PR carries
`skip-changeset`.
- `docs/adr/**` is a governed surface, Tier H. This PR stays a draft;
landing is not this run's act.
## Verification
Read first: the one changed file, two hunks. The hunk to look at is line
77. It sits inside a prose sentence, and the only thing that moved is
the content of one parenthesis. Line 718 is a table cell; the `;`
between the two cited files is kept.
Two-minute check, one command, on this head: `node
scripts/check-adr-symbol-anchors.mjs`. Expect exit 0 and a verdict line
carrying `4638 anchors across 165 records` and `2833 file-level`.
Local gates, all on head `422b3570`, each exit code captured before any
pipe: the 21 commands that `node scripts/pm/dispatch-gates.mjs
--commands` derives for this diff. Its `--ran` reconciliation reads `21
derived, 21 run, 0 NOT-MEASURED, 0 UNRUN`. The whole-root families, the
type-check lanes and the test lanes are CI's, on this head.
<details><summary>The 21 derived gates and their exit codes</summary>
```text
exit 0 node scripts/check-adr-links.mjs
exit 0 node scripts/check-adr-links.mjs --self-test
exit 0 node scripts/check-closing-keyword-parity.mjs
exit 0 node scripts/check-closing-keyword-parity.mjs --self-test
exit 0 node scripts/check-comment-mask-corpus.mjs
exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test
exit 0 pnpm --filter @objectstack/lint run check:doc-formula-expressions (first run: exit 3, see below)
exit 0 pnpm check:adr-anchors
exit 0 pnpm check:adr-index
exit 0 pnpm check:adr-symbol-anchors
exit 0 pnpm check:ci-filter-parity
exit 0 pnpm check:closed-ceremony-text
exit 0 pnpm check:cross-package-test-inputs
exit 0 pnpm check:doc-authoring
exit 0 pnpm check:driver-memory-census
exit 0 pnpm check:gitlink-declared
exit 0 pnpm check:nul-bytes
exit 0 pnpm check:pm-governed-merges
exit 0 pnpm check:pm-prior-rulings
exit 0 pnpm check:refd-timer-probe
exit 0 pnpm check:watch-hint-literal
```
`check:doc-formula-expressions` first answered exit 3, PREREQUISITE NOT
MET: `@objectstack/formula` and `@objectstack/lint` were not built in
this fresh worktree, so it measured nothing. After the build it names
(`turbo run build` filtered to those two, 5 tasks, under the shared
verify lock) it answered exit 0. The record handed to `--ran` carries
the second reading.
`node scripts/pm/overlap-check.mjs` before the push: `changes 1 file(s);
against origin/main (8338d07) and 0 PR head(s)`, `VERDICT clean exit
0`.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 7b68db9 commit 45e4457
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
715 | 715 | | |
716 | 716 | | |
717 | 717 | | |
718 | | - | |
| 718 | + | |
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
| |||
0 commit comments