Skip to content

test(api): fail the lane when a collection read ships without an explicit limit - #284

Merged
sydevs-bot merged 7 commits into
mainfrom
claude/test-275-explicit-limit-inventory
Oct 12, 2026
Merged

sydevs-bot merged 7 commits into
mainfrom
claude/test-275-explicit-limit-inventory

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Change outline

Behaviour — what the gate decides, per call site

 every src/**/*.ts(x), parsed through the typescript API   src/config/api/reads.inventory.test.ts
   bind `sdk` / `requestJson` to a static import of config/api/client
+    a namespace import → FAIL          # it would hide every read in that file
+  sdk.find(…)                          # bound to the import, so Array#find never matches
+    no `limit`              → FAIL     # not a refusal: Payload defaults it to 10
+    `limit` unresolvable    → FAIL     # so `limit: whateverThisIs()` cannot satisfy it
+    `limit` 0, or over 2000 → FAIL     # 0 is the unbounded sentinel; 2000 is MAX_CLIENT_LIMIT
+    no `page`               → FAIL
+    `page` a fixed number   → FAIL     # the walk would re-read one page totalPages times
+    `pagination` present    → FAIL
+    outside readAllPages    → FAIL     # one page read and called the whole set
+    `sort` not walkSort(…)  → FAIL     # a LIMIT/OFFSET walk with no total order
   sdk.findByID / sdk.findGlobal                          # out of scope: neither takes a `limit`
+  requestJson({ path, json? })          # an AST cannot tell a list read from a record read
+    a `json` or `file` body     → exempt, a write (mutate.ts's three POSTs)
+    path in PAGINATED_READS     → the nine checks above, against `args`
+    path in SINGLE_RECORD_READS → exempt, one record
+    neither, or not a literal   → FAIL, naming both lists and what to decide

The method decides nothing: the SDK sends args as the query string at any verb, so a
POST-as-GET is a read.

Files

 src/config/api/
 ├── client.ts        # unchanged
 ├── paginate.ts      # unchanged — this spec asserts its contract is reached
 ├── fetch.ts         # unchanged
 ├── fetch.test.ts    # unchanged: its three per-call-site assertions are a different claim
+└── reads.inventory.test.ts
 docs/rules/data-layer.md   # the rule now points at its enforcement
 docs/testing.md            # a stale lane measurement this ticket's checklist rested on

Preview

Test results

  • Lean gate: ✓ pnpm lint + pnpm typecheck + pnpm test:run (1701 passed, 139 files)
  • Targeted specs: 5 new in reads.inventory.test.ts
  • Build: N/A — no production code changed

Manual verification

  1. Nothing by hand. Every claim is asserted, and each assertion was watched red (table below).

Notes for reviewer

  • Two checks go past the ticket's criteria, which asked me to decide this: the call must sit
    inside a readAllPages callback and must sort through walkSort. Both are the claim the rule
    actually makes rather than a proxy for it, and both are visible from one call expression. A read
    sending limit: 2000, page: 1 and never walking satisfies the ticket's criteria exactly and
    still truncates silently at 2001 rows. One line removes either if you disagree.
  • A finding about refactor(api): paginate the three pagination: false SahajCloud reads #277's merged code, not this PR's, for you to judge. getGeojson sends
    sort: walkSort() where main sent no sort at all, so id ascending becomes the feed's
    primary order. byDistance returns 0 for two distance-less events and Array#sort is stable, so
    the online tail of the results list reorders — it inherits feed order, which was the server's
    default and is now id. The review's verdict was that the prior order was Payload's unspecified
    default and never a contract, so there is nothing to file; a chosen order for the online tail
    would be its own ticket. Say the word if you read it differently.
  • Two tickets came out of the review, neither of them this PR's: perf(test): give the unit lane a per-edit budget it is actually under #285 owns the unit lane's ~28s
    per-edit cost, and test(build): one source walker for the nine specs that inventory src/ #286 owns the nine specs that each roll their own readdirSync walk of
    src/ — this spec being the ninth.
  • This branch was built stacked on refactor(api): paginate the three pagination: false SahajCloud reads #277 and then rebased onto main. refactor(api): paginate the three pagination: false SahajCloud reads #277 merged at 19:38Z,
    four minutes into that session, and the spec cannot exist without its readAllPages / walkSort
    seam — on the main that existed at dispatch, the three reads still sent pagination: false and
    this spec would have been red on arrival. The rebase was clean: comm -12 over the two file
    lists found zero overlapping files, and the gate above ran after it.
  • /simplify did not run as a skill. While the branch was stacked, its diff range was refactor(api): paginate the three pagination: false SahajCloud reads #277's
    code, so it would have been reviewing and editing another PR's diff; by the time of the rebase
    the review pass was already done. /code-review high ran scoped to this branch's own files, and
    the /simplify lenses I applied by hand are in the Detail block.
  • The security pass found nothing, and the surface is why. src/config/api/ is on this repo's
    trigger paths, so it ran. The diff is one unit-test file and two Markdown files: no network,
    shell, eval or deserialization, and the only reads are of our own src/ tree from a
    readdirSync walk. ts.createSourceFile parses without executing, which href.test.ts already
    relies on.
  • comment-lint.mjs: clean.
Detail

Every assertion was watched red before it was kept, each defect reintroduced at the site that
would actually cause it:

Defect reintroduced What went red
A bare sdk.find in src/views/ all four checks, naming the file and line
limit commented out in getRegions the limit check, naming fetch.ts:177
limit: 0 the bound check
page: 1 hard-coded in getRegions the fixed-page check
pagination: false with everything else correct the pagination check alone
sort: 'name' and sort: undefined the walkSort check at both sdk.find sites
A requestJson GET to /regions/tree the inventory check, with the two lists named
A requestJson POST read of an unlisted path the inventory check (this round)
The same POST read at /events/geojson all four page checks (this round)
CLIENT_PAGE_LIMIT = 1000 + 1000 the resolver self-check, expected undefined to be 2000
A second raw sdk.request in client.ts the wrapper check, listing the site
import * as client from '@/config/api/client' the namespace check

Two cases were also watched green, because a check that fired on them would be a false
positive: the POST read once it carries a json body (a write), and CLIENT_PAGE_LIMIT = 1000 (a
tuning change, which used to fail under a walker-health label).

The commented-out limit is the case the ticket's ⚠ is about: a regex over raw text has to strip
comments first, and every cheap way of doing that has a false pass in it. The AST ignores the
comment correctly.

Why the glob is all of src/, measured rather than assumed. The ticket asked for this.
Scanning 255 files costs ~0.7s (28.5s → 29.2s over the whole lane). src/types/payload/ is
excluded: generated declarations, no call sites, and the slowest thing under src/ to parse. A
sdk.find added anywhere under src/ is caught — verified in both a .ts and a .tsx file.

limit resolves through one import hop. limit: CLIENT_PAGE_LIMIT is an identifier, so the
spec resolves it to a module-level numeric literal in its own file or the module it was imported
from. Keyed by file, not by name: src/loader/literals.ts duplicates values across the loader
seam on purpose, and a repo-wide name map collided immediately on IDLE_DEADLINE_MS at two values.
An unresolvable value fails rather than passes, which is what stops the check being satisfied by
anything opaque.

MAX_CLIENT_PAGE is deliberately not checked. A page must vary per call to pass at all, and
MAX_PAGE_WALK bounds the walk two orders of magnitude under that ceiling, so no assertion on it
could ever fail — the same reason 08b62da dropped CLIENT_MAX_PAGE from paginate.ts.

The first review's four findings. Three were real and are fixed in the third commit: a
hard-coded page: 1 passed (verified — it kept all four specs green); a namespace import hid every
read in its file, contradicting the file's own blind-spot note; and the wrapper-count message named
client.ts while the count came from every scanned file. The fourth was the getGeojson sort
question above.

The second review's three findings, all adopted, one commit each:

Finding Commit
A POST list read escaped both inventories, with no limit, page or walk eb81d3e
The walker self-check pinned CLIENT_PAGE_LIMIT's value, so a tuning change went red 2fc7c92
The lane budget was removed rather than replaced a7eb151

The first is why the inventory now reads a json or file body as the read/write mark instead of
filtering on method: 'GET': args is the query string at any verb, so the method classified
nothing, and a POST-as-GET is a shape data-layer.md names. 6be0e2f carries that into the rule.

Why docs/testing.md is in this diff. The ticket's verification checklist asked whether the
new spec keeps the lane "under ~5s", citing that file. Measuring it to answer found the premise
stale in both halves: the jsdom note has said "about 1s against the whole lane's ~1.5s" since there
were a handful of specs, and there are now 25 jsdom files among 133. Measured on 4 cores: 113
node-only files take ~16s, the 25 jsdom files add ~12s, ~28s in total. The per-file opt-in still
does the work the line credits it with, so only the numbers were wrong. #285 owns the total,
and the hook note cites that ticket rather than a bound this PR would have had to invent — a
figure nothing checks is how the old one went stale.

/simplify lenses applied by hand, on this branch's own file: the per-module constant
resolution replaced a repo-wide map; a redundant && bindings.requestJson conjunct went; the
unused MAX_CLIENT_PAGE went with the range check it served; and propertyOf / valueOf now take
undefined instead of each caller passing ?? ({} as never). The second review's first commit
dropped method from the Read type for the same reason — nothing branched on it any more.

Blind spots are stated in the file, since a guard that oversells itself is worse than none. A
re-export under another name and a dynamic import are both invisible; a namespace import was too,
until the first review found it, and now fails. select and populate are a different clause of
the same rule and are not checked here.

Closes #275

🤖 Generated with Claude Code

https://claude.ai/code/session_01GN284jC2KsJ2yCLRQJgx8g


Generated by Claude Code

…icit limit

#253 enforced the explicit-`limit` rule by example, with per-call-site
assertions in `fetch.test.ts`. Those pin what each of the three reads sends on
the wire, which is a different claim from "and nothing else reads any other
way" — they say nothing about the next read somebody adds, and the failure mode
is the quietest one in the rule: an absent `limit` is not a refusal, it is ten
rows, with lint, typecheck and the unit lane all green.

So the inventory is executable here instead, on the shape `href.test.ts`
already uses for the `isSafeHref` rule: walk `src/**` through the `typescript`
API and fail any `sdk.find` that sends no `limit` or `page`, sends `pagination`
or `limit: 0`, sits outside a `readAllPages` callback, or sorts without
`walkSort`. Parsed rather than grepped because commenting out a `limit` is
exactly the edit it has to catch, and a regex has to strip comments first.

`findByID`, `findGlobal` and `mutate.ts`'s POSTs are out by construction — none
takes a `limit`. A custom endpoint is the read an AST cannot classify, so the
GET paths are two named inventories and an unlisted one fails with the
instruction to decide which it is, rather than being guessed at. The same goes
for a `method` or a `path` that is not a literal: unreadable fails, so a read
cannot leave the inventory by being opaque.

Two checks go past the ticket's criteria, because both are the claim the rule
actually makes and both are visible from one call expression: a read sending
`limit: 2000, page: 1` and never walking truncates silently above one page, and
a walk sorted by a non-unique key repeats and drops rows at every boundary.

Refs #275

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GN284jC2KsJ2yCLRQJgx8g
This ticket's own verification checklist asked whether the new spec keeps the
lane "under ~5s", citing this file. Measuring it to answer that found the
premise stale in both halves: the jsdom note has said "about 1s against the
whole lane's ~1.5s" since there were a handful of specs, and there are now 25
jsdom files among 133.

Measured on 4 cores: 113 node-only files take ~16s, the 25 jsdom files add
~12s, for ~28s over 1698 tests. The per-file opt-in is still what keeps the
first number from becoming the second, so the structural point stands and only
the numbers were wrong.

The PostToolUse hook note carried the same figure as a target. A budget nobody
has been under for months reads as satisfied rather than as broken, so it now
says what the hook actually costs per edit and asks for a new spec's own cost
to stay small — which is the part a contributor controls.

Refs #275

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GN284jC2KsJ2yCLRQJgx8g
…tory

A fixed `page` passed. `page: 1` is present and in range, so the check waved
through the one shape that duplicates rows instead of paginating: the walk asks
for page one `totalPages` times and concatenates it. Only a value that varies
per call can be the page the walk is on, so a resolvable number is now the
defect rather than the pass.

A namespace import hid every read in its file, which contradicted this file's
own blind-spot note. It fails the lane now instead of being documented, and
`import { default as x }` binds like the default import it is.

The wrapper-count message named `client.ts` while the count came from every
scanned file, so an opaque `requestJson(opts)` added in `mutate.ts` would have
pointed at the wrong file with no site named. It lists the sites it found.

`MAX_CLIENT_PAGE` went with the `page` range check. No assertion on it could
fail: a page must vary to pass at all, and `MAX_PAGE_WALK` bounds the walk two
orders of magnitude under that ceiling — the same reason `paginate.ts` dropped
its own copy in 08b62da.

Refs #275

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GN284jC2KsJ2yCLRQJgx8g
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6be0e2f
Status: ✅  Deploy successful!
Preview URL: https://1abd9cf5.sahajatlas.pages.dev
Branch Preview URL: https://claude-test-275-explicit-lim.sahajatlas.pages.dev

View logs

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

sydevs-bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 20:25Z address-review · attempt 1 · session · done
  • 20:25Z address-review · attempt 1 · session
  • 20:15Z review-pr · attempt 1 · session · done
  • 20:15Z review-pr · attempt 1 · session

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

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🧐 Adversarial review

The diff matches the ticket: one spec, two doc edits, no production code. Its size is in proportion to the failure it catches, and the two checks past the criteria (readAllPages, walkSort) are the claim the rule actually makes, visible from the same call expression. No contract surface moves. One aggregate question is not this PR's to answer: src/ now holds nine specs that each roll their own readdirSync walk, this being the ninth. A shared test helper, or a no-restricted-syntax rule, is a ticket rather than a change here.

On the getGeojson sort you asked about — nothing to file. main sent no sort, so the prior order was Payload's unspecified default and never a contract; walkSort() makes it defined. If the online tail needs a chosen order, that is its own ticket, not a regression in #277.

Findings

  • should-fix — reads.inventory.test.ts:369: a POST list read escapes both inventories. Confirmed green against a probe.
  • should-fix — reads.inventory.test.ts:465: the walker self-check pins CLIENT_PAGE_LIMIT's value, so a tuning change goes red under the wrong message. Confirmed.
  • consider — docs/testing.md: the lane budget is removed rather than replaced.

What was checked. Read whole: the new spec, config/api/{client,paginate}.ts, fetch.ts's three walked reads and two custom GETs, href.test.ts's anchor inventory (the cited precedent), eslint.config.js. #275 against the diff — every criterion met, plus two. Ran the spec in a throwaway worktree: 5 passed, 1.33s. Probed two defects there: the POST read above stayed green, CLIENT_PAGE_LIMIT = 1000 went red. Counted the source walkers with grep -rln readdirSync src/. The SDK types method as a five-literal union, which is what closes the lowercase-method hole.

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


Generated by Claude Code

Comment thread src/config/api/reads.inventory.test.ts Resolved
Comment thread src/config/api/reads.inventory.test.ts Resolved
Comment thread docs/testing.md Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 11, 2026
The inventory kept only `method: 'GET'`, and a non-literal method was the only
other way out of it. So a `requestJson` list read sent as POST was in neither
set: it passed every spec with no `limit`, no `page` and no walk. `data-layer.md`
names POST-as-GET as a shape this API has, and the SDK sends `args` as the query
string whatever the verb, so the method never classified anything.

What separates a read from a write is the body. A `json` or `file` option is a
write — which is what keeps `mutate.ts`'s three POSTs out — and everything else
is a read, checked against the two path inventories.

Watched red at the causing site: a POST read of an unlisted path fails the
inventory check naming the file and line; the same read at `/events/geojson`
fails all four page checks; adding a `json` body to it goes green again.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TMw3HFBzr1ay1WnXPCQ9Jy
The walker self-check compared `fetch.ts`'s resolved `CLIENT_PAGE_LIMIT` against
`MAX_CLIENT_LIMIT`, so lowering the page size — a tuning choice `paginate.ts`
owns — failed with `expected 1000 to be 2000` under "the walk itself must not
silently break". The claim is that the resolver still follows the import hop to a
number, so compare against the imported constant.

Watched red at the causing site: `export const CLIENT_PAGE_LIMIT = 1000 + 1000`
fails with `expected undefined to be 2000`, while `= 1000` now stays green.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TMw3HFBzr1ay1WnXPCQ9Jy
Re-measuring the lane removed the only stated bound on it and left nobody owning
~28s per `src/**` edit. #285 owns the total now, and the hook note cites it
rather than restating a number nothing checks. The jsdom paragraph keeps the
warning and the measurement, and drops the account of how the old figure went
stale — its replacements will go the same way.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TMw3HFBzr1ay1WnXPCQ9Jy
The rule pointed at the spec's old GET filter. The spec classifies a custom call
by whether it carries a `json` or `file` body, so this records what actually puts
`mutate.ts`'s POSTs out of scope — and why the method could not do that job.

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

Copy link
Copy Markdown
Contributor Author

Adopted all three review findings, one commit each, plus the rule they changed.

Thread Commit
A POST list read escaped both inventories eb81d3e — a json or file body is the read/write mark now; the method classified nothing
The self-check pinned CLIENT_PAGE_LIMIT's value 2fc7c92 — compares against the imported constant
The lane budget was removed, not replaced a7eb151 — #285 owns the total, cited in place of a figure

6be0e2f carries the read/write mark into docs/rules/data-layer.md. Each fix was watched red at its causing site, and two false-positive cases watched green — the Detail block lists both.

Filed from the review body: #285 (lane cost) and #286 (nine specs, nine readdirSync walks). Gate green: 1701 tests, 139 files.

🤖 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 Oct 11, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 11, 2026 20:43
@sydevs-bot
sydevs-bot requested a review from Ardnived October 11, 2026 20:43
@sydevs-bot
sydevs-bot enabled auto-merge October 11, 2026 20:43
@sydevs-bot
sydevs-bot added this pull request to the merge queue Oct 12, 2026
@sydevs-bot sydevs-bot moved this from Revising to Approved in SYDevelopers Technical Roadmap Oct 12, 2026
Merged via the queue into main with commit 5001c2d Oct 12, 2026
62 of 65 checks passed
@sydevs-bot
sydevs-bot deleted the claude/test-275-explicit-limit-inventory branch October 12, 2026 16:55
sydevs-bot pushed a commit that referenced this pull request Oct 13, 2026
The jsdom trade quoted 114 node-only files and 1701 tests, both from before this
branch added `scripts/select-unit-specs.test.ts`. The lane is 140 files and 1714
tests, 25 of the files jsdom, so the node-only half is 115. Re-derived rather than
incremented — the old 114 was one short too.

The hook's scope line and the width figures also moved with this branch's `scripts/`
fix: 412 lane sources, 133 of them selecting the walker floor alone.

The project-split lever now names #293, which owns it. The paragraph handed the next
reader a measured 4.5s to 1.5s win with nothing behind it, which is how #285's own
figure went unowned until #284's review noticed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018P9kaAfuJERNv3GbQT1va4
Ardnived added a commit that referenced this pull request Nov 20, 2026
#442's doc commits re-counted the lane, re-timed the hook and re-measured the
bundle into prose, and copied lists the code already holds. Each would need
the same edit at the next change. Kept every ⚠ and its reason; dropped:
- figures: lane, spec and source counts, hook timings, KiB savings, budget
  percentages, advisory counts, the six FallbackKinds
- copied lists: the loader's parameters (docs/embedding.md owns them), the
  factory and wholesale-key lists, the zoom constants' values, the coverage
  excludes, another repo's action list, the _headers max-ages
- restatements: the zod-shape and eager-shell explanations their own homes hold
- the hook re-measurement chain, collapsed to its conclusion (drops #389)

Rule: sydevs/claude-workflow docs/documentation.md (#284, #289).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

test(api): fail the lane when a collection read ships without an explicit limit

3 participants