Skip to content

test: cut change amplification in the unit lane - #1136

Merged
Ardnived merged 13 commits into
mainfrom
test/unit-lane-audit
Nov 12, 2026
Merged

Ardnived merged 13 commits into
mainfrom
test/unit-lane-audit

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The unit lane has little true redundancy. Its edit cost comes from specs that restate what the source already enumerates: counts, lists, email copy and URLs, and the prose of a hand-written OpenAPI document. Over the last 6 months those specs were edited in commits that never touched their subject. This PR removes or rewrites them, deletes one pair of dead modules, and moves three pure specs out of the integration lane.

Each commit is one category, so each can be reviewed alone:

Commit What Cases
test(perf) perf-figures-pinned stops pinning the file and test counts to the tree and to four docs. The docs point at tests/PERF.md; the two tier-target checks stay, and so does the doc-to-PERF.md lane-timing agreement, which only reddens on a re-measurement. All 28 commits touching PERF.md since 2026-10-20 bumped those counts. Reverses part of #990's design. −5
test(unit): derive… atlas-translations key count becomes a floor (7 of its 10 edits only bumped it); locale lists derive from LOCALES; notification default derives from buildDefaultNotificationPreferences() ±0
test(email) One renderHtml helper per email spec; fixture URLs are neutral; copy asserted once per template; registration labels come from the question config ±0
test(openapi) 28 per-endpoint path, parameter and prose cases replaced by structural checks, in both directions: every documented path is registered, every registered endpoint an API client can call is documented, and every $ref resolves. The config-reading cases live in sanitized-config-rules, so no new spec imports @/payload.config 51 → 18, +2 in openapi-endpoint-coverage (+5 in sanitized-config-rules)
test(int) 17 int cases testing Payload built-ins (CRUD, defaults, drafts) and 11 repeating a unit matrix. Each endpoint keeps "missing → 400" as its wiring proof −28 int
refactor(audiences) Deletes daytimeMatch.ts and scheduleMatch.ts (#348) and their specs: no consumer in src, scripts or seeds −28
test(unit): …one home each Helper cases duplicated in event-title.spec dropped; manager-signin-urls folded into reminder-button-url −4
test(transcripts) The mounted tab stops re-running the read-along and stall matrices that the pure specs own −3
test: move… storage-utils, cloudflare-stream-webhook and translations-field move from the int lane to the unit lane. None calls createTestEnvironment() 108 moved
docs(tests) Six rules in tests/AGENTS.md for keeping specs cheap to change —

Deliberately kept

  • login-plugin's exact WIRED_ROUTES, PUBLIC_CREATE_PATHS, and the job-schedules list: an extra entry is the bug.
  • The schedule-hooks DST cases.
  • The int auth-gate triplets, client-origin-enforcement, role-based-access, and usage-tracking-dedup.
  • cache-policy's literal list of cacheable globals: it is an allowlist of what reaches the edge cache.
  • event-feedback's mixed-verdict int case and user-submissions-create's rich-text scan: each is the only int proof of its wiring.

Review follow-ups

Three cuts went further than change amplification warranted, and are now restored or replaced:

  • perf-figures-pinned keeps the four docs' lane timing held to PERF.md's recorded figure.
  • event-verification-email's eventUrl: null case asserts the secondary button's own fill and border, so it can fail; the reworded version could not.
  • openapi-endpoint-coverage.spec.ts holds registered ⊆ documented, the direction the deleted per-path cases were about. It is its own file because buildConfig mutates the raw collection configs in place, so it cannot share a module graph with @/payload.config.

Test plan

  • Lean gate: lint, format, typecheck and typecheck:tests pass.
  • pnpm test:unit: 269 files, 3,629 tests passed, 53 s.
  • The 11 edited int specs ran together: 284 passed.
  • Each restored or added case watched failing against the real defect: README.md at 79 s, the eventUrl ? guard removed, the geojson path renamed, and setProject unregistered.
  • CI: full suite and smoke.

ics-builder.spec.ts fails locally outside UTC: it expects LAST-MODIFIED:20260801T100000 and gets …T030000 on MST. That spec comes from #1134 on main, and this PR does not touch it. CI runs in UTC.

🤖 Generated with Claude Code

Ardnived and others added 10 commits November 12, 2026 13:52
Every PR that added a spec had to bump the file and test counts in
tests/PERF.md and three or four consumer docs: all 28 commits touching
PERF.md since 2026-10-20 did. The docs now point at PERF.md for counts,
and perf-figures-pinned keeps only the two tier-target checks (#990).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing them

- atlas-translations-schema: the key and leaf-group counts become floors; 7
  of the case's 10 edits only bumped the exact numbers.
- locales, filterAvailableLocales: compare against LOCALES rather than a
  hand-written 19-code array and length.
- json-field-schemas: validate buildDefaultNotificationPreferences() rather
  than a copy of it.
- admin-locale-urls: drop the call-site count from the header comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…is the point

- One local renderHtml() per email spec, so a renderEmail return-shape
  change costs one line instead of ~40 call sites (fd18755).
- Sign-in and verify URLs passed in as fixtures are neutral
  (https://cloud.test/x?t=1), not real routes; manager-auth-urls pins the
  real shape. Those literals changed twice (4f0b06a, 8971cc1).
- Copy assertions are kept only where the wording is the contract;
  elsewhere the specs check the href, the locale, or the value present.
- Registration question labels come from EVENT_REGISTRATION_QUESTIONS and
  the key fallback from toWords, not restated strings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s prose

openapi-custom-endpoints had 24 edits since it was written, and all 11 that
changed existing lines came from renames, copy edits or deleted endpoints,
not from anything it imports. It drops 28 per-endpoint path, parameter and
description assertions (51 cases to 18) and gains structural checks:

- every documented method and path is one the sanitized config registers;
- every $ref resolves to a declared schema or a generated collection one;
- documented root endpoints stay visible in each project spec, and are
  hidden when not declared as root paths, read from the config.

The config-reading cases sit in sanitized-config-rules, which already pays
the ~6.5 s config import, so no new spec loads @/payload.config. Visibility
filtering, the calendar feed's security: [], the transcript hiding, and the
enums sourced from constants keep their cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…trix

- audiences, user-choices, pages, meditations: 17 cases asserting plain
  CRUD, required, field defaults or draft status on fields with no hook or
  validate of ours (tests/AGENTS.md: do not test Payload internals).
- meditation-lectures, lectures-for-audience, app-cards-for-audience: the
  empty / non-numeric / normalisation cases for ?audiences, which every
  handler parses with audiencesQueryParamSchema and
  unit/audiences-query-param covers. "missing -> 400" stays in each as the
  wiring proof.
- retention-jobs, event-imports, screen-submissions: one case each that
  repeats a pure unit case with no wiring added.

event-feedback's mixed-verdict case and user-submissions-create's
rich-text scan stay: each is the only int proof of its wiring.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
isEventInUserDaytime and isScheduleActiveNow (#348) have no consumer in
src, scripts or seeds; only their own specs imported them, and those specs
still cost edits in type sweeps (cf5e09e). The code and its 28 cases go
together.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… one home each

- event-title-cache: drop its three helper cases; event-title.spec holds
  the same inputs and outputs, and both were edited together twice.
- manager-signin-urls: its "one redeem route" case was already in
  reminder-button-url; the escaping case moves there and the file goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ices in the mounted tab

activeSegmentIndex's whole-second and pause cases live in
meditation-transcript-model.spec, and the stall bound in
transcript-phase.spec. The jsdom tab keeps one case per wiring: the mark
follows the playhead, sits on the focusable phrase, and the stall notice
appears while mounted (now also asserting the copy names no duration).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
storage-utils (57 cases), cloudflare-stream-webhook (25) and
translations-field (26) never call createTestEnvironment() and need no
.env; each paid the int lane's setup and a fork for pure functions.
tests/AGENTS.md already cited the first two as unit-lane examples.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Five rules aimed at the causes of most spec edits that changed no
behaviour: restated counts and lists, docs quoting lane counts, copy
pinned in many places, the same matrix in several specs, and a call
shape repeated across dozens of sites.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@railway-app

railway-app Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-1136 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Nov 12, 2026 at 9:32 pm UTC
1 service not affected by this PR
  • mailpit

@Ardnived

Copy link
Copy Markdown
Contributor Author

@sydevs-bot review

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot

sydevs-bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 21:12Z address-review · attempt 1 · session · done
  • 21:12Z address-review · attempt 1 · session
  • 21:05Z review-pr · attempt 1 · session · done
  • 21:05Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 12, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The PR does what its body says, and the spot checks hold: retention-jobs' deleted "declares no retention" case already exists at tests/unit/retention-discovery.spec.ts:111 with the same message, screen-submissions keeps seven verdict: 'ok' cases, and daytimeMatch/scheduleMatch have no consumer because the eventTime and schedule fields #348 read are gone from the collection. The OpenAPI commit is a net gain, not a cut: filterSpec visibility and the depth cap now derive from the sanitized config instead of a hand-listed path per endpoint. No product code rides along beyond the two dead modules the body names. Two cuts go further than change amplification warrants.

Findings

  • should-fix — the perf commit also drops the doc-to-PERF.md timing agreement, which only reddened on a re-measurement. tests/unit/perf-figures-pinned.spec.ts:56
  • should-fix — the reworded eventUrl: null case can no longer fail. tests/unit/event-verification-email.spec.ts:150
  • consider — the structural check covers documented ⊆ registered only, not the direction the deleted cases named. tests/unit/sanitized-config-rules.spec.ts:423

What was checked

Read whole on the branch: perf-figures-pinned, sanitized-config-rules, openapi-custom-endpoints, tests/PERF.md, tests/AGENTS.md, audiences/resolve.ts, Audiences.ts. Ladder: no new file, type or dependency; renderHtml and normalisePath are each local to one spec. 203 / 2643 is the second session's own row (PERF.md:68), not a rewritten figure. Grepped src scripts seeds tests docs for the deleted matchers: specs only. Confirmed rootEndpointPathsFrom and the maxDepth cap survive the OpenAPI cut, now config-derived. The three moved specs call no createTestEnvironment(). No preview link in the body; CI still running.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread tests/unit/perf-figures-pinned.spec.ts Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 12, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 12, 2026
The perf commit dropped the doc-to-PERF.md timing agreement along with the
count pins, but PERF.md still declares itself the single writer of every
timing the three-tier contract states. Nothing then held the four docs' 78 s
to the 77.9 s recorded here, which is the drift #990 was filed for — and
unlike the count pins, this case only reddens on a re-measurement, so it
costs no edit on a PR that adds a spec.

The count pins stay gone.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWHA66mbAPfDH65QWr
`baseProps` carries no `eventUrl`, so `not.toContain(EVENT_URL)` could not
fail however the template behaved — dropping the `eventUrl ?` guard left it
green. The secondary button's own fill and border is the fingerprint instead:
no label is restated, and the variant is only ever this one button.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWHA66mbAPfDH65QWr
The structural check held documented ⊆ registered only. The failure the
deleted per-path cases named is the other direction — an endpoint missing
from the hand-written shim is invisible in /api/docs with nothing going red —
and nothing covered it: renaming the geojson path left the lane green.

The rule is derived from the raw collection barrel, so adding an endpoint
needs no new case. Six manager-only endpoints are exempt by name, each
authenticating a manager and accepting no client API key; a second case reds
when an exemption outlives its endpoint.

It is its own file because `buildConfig` mutates those raw configs in place,
appending Payload's 440-odd REST routes, so this must not share a module
graph with `@/payload.config`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWHA66mbAPfDH65QWr
@sydevs-bot

Copy link
Copy Markdown
Contributor

All three review threads adopted. Pushed for relay as claude/relay-1136-c5eba37.

  • Lane timing — fb15a9a restores the it.each(CONSUMERS) case. PERF.md still declared itself the single writer of every timing, so its prose and the whole-lane capture came back too. Count pins stay gone.
  • eventUrl: null — 529864f keys on the secondary button's own fill and border, not its label, so no copy is restated twice.
  • Reverse direction — c5eba37 adds openapi-endpoint-coverage.spec.ts: registered ⊆ documented, derived from the raw @/collections barrel, six manager-only endpoints exempt by name.

Base was already current, so no merge. Lean gate green: 269 files, 3,629 tests. Each case was watched failing against the real defect. tests/AGENTS.md gains a sixth rule: a structural check covers only the direction it asserts.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 12, 2026
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1136 November 12, 2026 21:29 Destroyed
@sydevs-bot
sydevs-bot enabled auto-merge November 12, 2026 21:43
@Ardnived
Ardnived disabled auto-merge November 12, 2026 22:56
@Ardnived
Ardnived merged commit 152e502 into main Nov 12, 2026
10 checks passed
@Ardnived
Ardnived deleted the test/unit-lane-audit branch November 12, 2026 22:56
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 12, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 12, 2026
…w endpoint

#1136 stopped the docs quoting the unit lane's file and test counts, and
`perf-figures-pinned` no longer pins them. This branch's last two commits
existed only to re-pin those counts, so all four doc hunks take main's
side: the counts go, the PERF.md session table keeps this branch's own
measured rows.

#1136 also replaced `openapi-endpoint-coverage`'s per-endpoint assertions
with a structural check, which this branch's new
`POST /api/clients/:id/email-preview` then failed. It authenticates a
manager and takes no client API key, so it joins MANAGER_ONLY beside
`verify-embed`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXyxHTrvBwd12hmgi6
sydevs-bot pushed a commit that referenced this pull request Nov 12, 2026
Four doc conflicts, all the same one: #1136 stopped pinning the unit lane's
file and test counts anywhere but tests/PERF.md, and this branch had bumped
those counts in all four docs. Took main's side in each — the counts it
removed are the ones no doc may quote now.

tests/PERF.md keeps main's `Files / tests (second session)` row: that row is
the second session's record now, not the current tree's.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWVXimsbUmfehpBf19
sydevs-bot pushed a commit that referenced this pull request Nov 12, 2026
#1136 landed a check that every collection endpoint an API client can call is
in the hand-written OpenAPI document. This branch's two secret routes are not
callable by a client: both run requireActiveManager and refuse an API key, so
they belong in the same exemption list as the Registrations CSV download.

Recorded the merged tree's lane measurement in tests/PERF.md.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWVXimsbUmfehpBf19
sydevs-bot pushed a commit that referenced this pull request Nov 12, 2026
#1136 cut change amplification out of the unit lane: it took the file and
test counts out of every doc and spec that quoted them, leaving
`tests/PERF.md` as their one home. This branch had bumped those same
counts. Every doc hunk takes main's side — AGENTS.md, testing-reqs.md,
tests/AGENTS.md, and PERF.md's second-session metric row, which is a
measurement and not this branch's to replace.

`admin-locale-urls.spec.ts` is the same conflict in a docblock: main
stopped counting the call sites, this branch had counted a fifth. Main's
wording stays correct as sites are added, so it wins.

`meditation-transcript-tab.spec.ts` keeps both intents. Main deleted the
standalone stall case as redundant and moved its no-duration assertion
into the fake-timers case it kept; this branch's copy change — these
notices are titles, so no full stop — stays on every assertion.

One semantic consequence, fixed rather than merged: #1136's new
`openapi-endpoint-coverage.spec.ts` requires every client-callable
collection endpoint to be in the OpenAPI document, and this branch adds
`POST /api/files/:id/transcribe`. That endpoint gates on
`requireManagerPermission` and takes no client key, exactly like the
meditations twin already exempted there, so it joins `MANAGER_ONLY` with
its reason.

main added no migration since the merge base, so no snapshot repair.

Lean gate green on the merge: lint, format:check, typecheck,
typecheck:tests, test:unit (272 files, 3712 tests, 52.28 s).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX2b1oZam54PpdTewz
Ardnived added a commit that referenced this pull request Nov 12, 2026
… the type list

Main's #1136 keeps a matrix in one home. The mounted field needs only to show it
reads the stored type and the chosen file's, so the video rows go.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
sydevs-bot pushed a commit that referenced this pull request Nov 12, 2026
#1136 stopped pinning the unit lane's file and test counts to the tree, so
the four docs this branch had bumped quote no count at all now. Took main's
wording in each; kept this branch's own PERF.md session rows and the
`setLifecycleState` note, which #1136 leaves to a measurement.

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1136 — c5eba37a Deployed Nov 12, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants