Repository navigation
test(admin): an admin.condition that reads an undeclared field fails the unit lane - #1005
Conversation
…e lane A condition that reads a field its own level does not declare is always false, so the field it guards never renders and nothing fails. `wisdomStyle` read the legacy `position` for its whole life, and a docs rewrite found it (#989) — nothing in the repo's ~140 condition sites would have. The spec walks the real collections, globals and page blocks, builds a sibling scope per data level (hoisting `row`, `collapsible` and an unnamed tab, which hold no data), and checks every `siblingData` read against the level that owns it. `data` and `blockData` name no sibling, so neither is read. Source text is the only instrument a closure leaves, so three assertions bound what that cannot see: a floor on the conditions reached, a floor on those reading a sibling, and a requirement that the read goes through a parameter spelled `siblingData` rather than a renamed or destructured one. Closes #1003 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GTCuVUNoQX8D72jkMidXsM
`flattenTopLevelFields` already decides which names a data level declares — a `row`, a `collapsible` and an unnamed `group` or `tab` hoist; a named one contributes its own name. The hand-written walk was a second copy of that rule, and a copy that drifted would read as a green lane rather than a failure. Verified identical over all 40 config roots and every nested level before the swap. The vacuity case is per-site now: a condition that takes `siblingData` must yield a read this spec can see, which also refuses one that hands the parameter to a helper. Each site carries its reads, computed once. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GTCuVUNoQX8D72jkMidXsM
The guide explained what a false `admin.condition` does to `required` and said nothing about which names a condition may read. The spec added here also fixes the parameter's spelling, which nothing else states. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GTCuVUNoQX8D72jkMidXsM
sydevs-bot
left a comment
There was a problem hiding this comment.
1 question for the reviewer, one per thread.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the ticket and nothing else — one spec, one guide section, no product code. The instrument is right: a condition is a closure, so its own text is the only thing that can name what it reads, and the two floors plus the parameter case keep it from covering nothing. Reusing flattenTopLevelFields over a hand-rolled walk is the Payload-native choice, and the two agree.
Two things narrow it. The scope is built with keepPresentationalFields: true, which admits 30 ui names that never reach siblingData — so the spec would pass the very shape it refuses. And the guide explaining the rule lands only where two thirds of the condition sites live, not in the directory #989 came from.
KNOWN_UNDECLARED is already a question thread, so I left it there.
Findings
- should-fix —
keepPresentationalFields: truewidens every scope withuinames —tests/unit/admin-condition-fields.spec.ts:67 - should-fix — the guide never loads for
src/fields/orsrc/lib/richEditor/blocks/—src/collections/AGENTS.md:118 - consider — the guide says a renamed parameter fails;
_siblingDatais exempt —src/collections/AGENTS.md:129
What was checked
- #1003 against the diff: every acceptance criterion holds but "no allowlist", which the question thread owns.
- Ran the spec on this head: 3 passed, 3.9s. Re-ran without
keepPresentationalFields: 3 passed, so that fix costs nothing. - Walked the configs myself: 166 sites, 73 sibling reads — the body's figures. 30
uinames enter scopes only via that option, and 0 reads depend on one. - Read
flattenTopLevelFieldsandfieldHasSubFields: named group, named tab and blocks stay in scope; row, collapsible and unnamed hoist. - No contract surface touched; no
blockReferences, sofield.blocksreaches every block. - Preview 404s at 19:25Z — not up.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
…n-condition-fields
`keepPresentationalFields: true` admitted every `ui` field's name into the level's scope — 30 across the configs. A `ui` field holds no data, so it never reaches `siblingData`, and a condition reading one is always false: the exact shape this spec exists to refuse, passed green. Watched red with a `ui` read added to the Events tabs field, which the option made pass. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019NbcWCZzcpKBmjYaXVELi9
`src/collections/AGENTS.md` loads only under `src/collections/`, so the 17 condition sites in `src/fields/` and the 16 in `src/lib/richEditor/blocks/` — where #989 itself lived — never saw the rule. A pattern spanning directories belongs in `docs/rules/*.md` with `paths:` frontmatter, per AGENTS.md, and `admin-ui.md` already carries field-behaviour rules. Editing that existing rule keeps this out of `.claude/`: a new rule file would need a `.claude/rules/` symlink, a protected path. Removing the section also restores what "the rule above" names in the Events `title` section below it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019NbcWCZzcpKBmjYaXVELi9
The rule said renaming the parameter fails the spec. `_siblingData` does not: the spec exempts it, and `src/` spells it that way three times for a condition that deliberately reads no sibling. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019NbcWCZzcpKBmjYaXVELi9
`main`'s new `perf-figures-pinned.spec.ts` pins PERF.md's file and test counts to the tree and to its four consumer docs. This branch adds a spec, so the merge made every one of those counts false and the lane went red. 205 / 2656, and this session's own lane row beside the other three. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019NbcWCZzcpKBmjYaXVELi9
|
All three adversarial-review findings adopted, none rebutted.
Merged Gate green: 2656 tests across 205 files, 90s. Still open: the 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Both conflicts are the same shape: #1007 trimmed the guides while this branch only counted its new spec in the tier figures. Took the trimmed text and carried the branch's 205 / 2656 into it. AGENTS.md keeps #1007's single test:unit bullet, not the seven-command list it replaced. tests/AGENTS.md keeps #1007's Integration row, which adds seeds/**/*.test.ts and names vitest.config.mts. perf-figures-pinned.spec.ts is what holds the counts together, and it passes: the lane is 205 files / 2656 tests, stated the same in PERF.md and all four consumer docs. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XgogFLEgfauFDEdJD6HRRh
|
Merged Took #1007's trimmed text on both, carrying this branch's 205 / 2656 into it. So
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
All four conflicts are the same shape, and the same one the previous merge hit: main's event-import work moved the tier figures to 215 / 2783 while this branch's figures only counted its own new spec. Took main's text in every hunk, then measured the merged tree rather than adding the two sides together. The lane reports 216 files / 2786 tests, so that pair is now stated in PERF.md and in the three consumer docs that quote it. perf-figures-pinned.spec.ts is what holds them together, and it passes. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0133zCdZdx3KyA3PBQBh9XJi
|
Merged All four conflicts were the same pair of numbers: Lean gate green: lint, both typechecks, 216 files / 2786 tests in 50s. No integration spec — the conflicts were documentation, and 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
All four conflicts are the tier figures again, one line each: `main` moved to 217 / 2792 while this branch carried 216 / 2786. Took `main`'s text and wrote the merged tree's own 218 / 2795 into all five places, which is what perf-figures-pinned.spec.ts holds together. `KNOWN_UNDECLARED` is gone, not re-stated. #996 merged as 74e545b, so `wisdomStyle` now reads `imagePosition`, and the entry no longer named an offender — a dead allowlist line silences the next real one. The guard passes with no entry at all, which is what the open thread predicted. Lean gate green: 218 files / 2795 tests, 49 s for the lane, 112 s for the gate. PERF.md records that session rather than replacing a row. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Qd4PYdsMMP2p5eRKU87dUv
|
Merged One choice the diff cannot show:
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Three docs conflicted on the same axis: main re-measured the unit lane after #1005 added a spec, while this branch had reformatted the tables prettier now owns. Took main's figures — 218 files / 2795 tests, and the two session rows it added to tests/PERF.md — and re-ran the formatter over them, so neither side loses. AGENTS.md keeps this branch's `pnpm format:check` line beside main's repinned count. main's src/collections/Forms/fields.ts (#1002) arrived unformatted and would have failed the gate this branch adds, so prettier ran over it too. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SRTQ21Ydtb9NUo22SCXqMm
#1005 and this branch each updated the unit lane's recorded counts, which collide in `tests/PERF.md` and the two consumer docs quoting it. Neither side's figures fit the merged tree: it carries this branch's six new cases and #1005's new spec file, so the counts are 218 files and 2801 tests, measured on this merge rather than taken from either side. `perf-figures-pinned` pins the file count to the specs on disk but only cross-checks the case count between the docs, so main's 2795 would have passed CI while under-counting by six. Timings are left as recorded. PERF.md quotes the slowest median as an upper bound and tells a session to add its own row rather than replace one, so this run's faster single measurement is logged as a sixth row and changes no target. Co-authored-by: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sd8tccYS1RbEQcbZD33Khb
`main` #1005 added one unit spec and re-pinned the lane's counts; this branch had re-pinned them too, on the pre-#1005 tree. Both sides want the counts to be the merged tree's, so neither side's number survives: re-measured here at 219 files / 2804 tests, 62.1 s. `AGENTS.md` merged clean while still saying 218 files, which `perf-figures-pinned.spec.ts` counts off disk — updated with the other three. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FXf5AQFSd42iEwWjaBYCEf
Both sides re-pinned the unit lane's counts, so every conflict was the same figure stated four times: this branch at 219 / 2829, `main`'s #1005 at 218 / 2795. Neither is true of the merge, which carries both sides' new specs, so the pins are re-measured off the merged tree — 220 files, 2832 tests — rather than taken from either side. `vitest list` and the lane itself agree on both numbers. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JQgC5M3zpEo8AQzCQBymwD
Three conflicts, all the same figure: tests/PERF.md's unit-lane counts and the two docs quoting them. Both sides had refreshed that row for their own tree and both landed on 218 files — this branch added locale-scoped-writes.spec.ts, main added admin-condition-fields.spec.ts (#1005). Neither number describes the merge, and taking either reddens perf-figures-pinned.spec.ts, which pins the file count to what is on disk. Measured on the merged tree instead: 219 files / 2807 tests. AGENTS.md quoted 218 without conflicting, and that spec's consumer check covers it, so it moves too. Recorded as a sixth session row rather than replacing a measurement, as PERF.md asks. Every conflict block was byte-identical apart from the count, so no prose from either side is dropped. Main carried no src/ change to interact with this branch's access work. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R6HmSjyM2gHbFrZUwVEMSs
Clean merge: #997, #998 and #1005 touch none of this branch's seven files. - #998 reformatted 250 files under prettier 3.9.10. `pnpm format:check` passes on this branch's own files unchanged, so none needed reflowing. - #1005 added `tests/unit/admin-condition-fields.spec.ts`, which fails an `admin.condition` reading a field the collection never declares. The five readers of `destination` in `destinationFields()` all sit beside it, so localizing it declares nothing away — that spec passes. - Unit lane on the merge: 218 files, 2795 tests, which is what `perf-figures-pinned` reads. No migration landed on `main` since the last merge, so the snapshot parent is unchanged and `20261021_024228` still regenerates the current one. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NbxY7L3ATnBmYYXfrYrM2X
Summary
docs/rules/admin-ui.mdnow states which names a condition may read, so it loads forsrc/fields/andsrc/lib/richEditor/blocks/as well assrc/collections/, and the spec also fixes how the parameter is spelled.Change outline
The guard walks the real configs and reads each condition's own source text.
Preview
Nothing in the diff changes what a preview serves — it adds a spec and documentation. The link is only there to confirm the conditions this guards still render as they did.
Test results
pnpm lint,pnpm typecheck,pnpm typecheck:tests, 2795 unit tests across 218 files — 49s for the lane, 112s for the gatetests/unit/admin-condition-fields.spec.ts3 passedmain's newperf-figures-pinned.spec.tspinstests/PERF.md's file and test counts to the tree and to four consumer docs. This branch adds a spec, so each merge reddens the lane until the new count lands in all five — 218 / 2795 as of 74e545btests/PERF.mdnow records a 47–78s spread across sessions on one container spec. Alone the spec is 4.5s wall, of which 7ms is its test bodies — the rest is importing configs ~40 unit specs already importNotes for reviewer
No allowlist ships, and no question is open. The ticket's "passes with no allowlist" holds: the one condition in the repo reading an undeclared field was #989, whose fix merged as #996, and the one-entry
KNOWN_UNDECLAREDthis PR carried in the meantime is deleted. The guard was watched green against that fix before it landed, and is green against it merged.Routed elsewhere, not fixed here: #1004 — about 93 of the 166 sites read
dataorblockData, which this spec does not check, and Payload'sConditiongenerics could put the whole class intsc. It carries the injected-name problem that is the reason this one checkssiblingDataonly, and asks the annotation question.Dismissed findings:
tests/utils/— a spec-local walk is this repo's convention for config walks (json-field-schemas.spec.ts,meditation-transcript-tab-wiring.spec.tseach carry their own), and nothing undertests/utils/walks fields. Worth doing when a third guard wants the same semantics, not for one caller.Proxyinstead of reading its text — rejected on soundness. A&&chain over=== 'literal'never touches its second key whatever the proxy returns, and a condition that throws on a synthetic document records zero reads and passes green. Source text is path-insensitive, which is the correct side to err on for "this name exists nowhere".Detail
Measured 2026-10-20, over the real configs: 166 condition sites, 73 of them reading a sibling, and one offender —
wisdomStyle, which #996 has since fixed, so the guard now finds none. The floors are 140 and 60 — enough headroom for a deleted field, far above the vacuum a stopped walk would pass with.Why
flattenTopLevelFieldsrather than the walk the ticket describes.payload/sharedalready decides which names a data level declares, including the named-tab case, so a hand-written copy would drift silently and read as a green lane. The first commit here carried that copy; the second replaced it after checking both agree on every level of all 40 config roots — collections, globals and blocks — with zero differences.keepPresentationalFieldsstays off. It admitted 30uinames into the scopes. Auifield is declared but holds no data, so it never reachessiblingData, and a condition reading one is always false — the exact shape this spec refuses, passed green.Each assertion was watched red before it was kept:
blocks/textbox :: wisdomStyle :: positionand prints the level's own namessiblingData['titel']) and a nested read inside thepanelsarray (mediaX) → both named, with the array's own scope; meanwhile a read of a sibling declared outside an enclosingrow, and adataread of a name no level declares, stay unreporteduiname read on the Events tabs field → named, and it passed while the scope admitted one(_, sibling)), andsiblingDatahanded to a helper with no visible read → both namedWhat it cannot see, and the parameter case is what bounds it: a condition that computes a field name, or resolves one through a helper. Neither shape exists in
src/today. The text it reads is also post-transpile, so a TS assertion around the parameter is already erased —LayoutBlock.ts:81is authored(siblingData as { style?: string })?.styleand matches for that reason._siblingDatais the one parameter spelling the spec exempts, andsrc/uses it three times for a condition that deliberately reads no sibling.Closes #1003
Generated by Claude Code