Repository navigation
docs(embedding): keep reporting every load, correct the 1 h collapse - #341
Conversation
Two guides published one hour. `EMBED_REPORT_REFRESH_MS` is `6 * 60 * 60 * 1000` (SahajCloud `src/lib/clients/embedMetadata.ts`), so a host sizing its traffic against the published figure was budgeting for six times the writes our server actually makes. The `reportEmbed` entry in `docs/rules/data-layer.md` now also records the decision that reporting on every page load stays, with the three reasons the cadence is cheap, each pinned to the SahajCloud file that shows it: the route is unmetered, a repeat costs no extra read, and an unchanged report collapses inside the window. The revisit trigger is named in the same place — Railway CPU spent on `POST /api/clients/report` — so the next reader finds the decision where they would look for the cadence, not in a closed thread. The changelog entry is not a documentation entry, which that file's own rule excludes. The number was published to hosts and was wrong, so the correction is host-observable. The `### Added` entry for #159 carried the same stale figure and is corrected in place: it sits in the same `[Unreleased]` section, and leaving it would have the file contradict itself. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYiUPhrVmQrbkoG99p
The same stale figure the guides carried. `mutate.ts` and both `embed-announce.ts` blocks told the next reader the server suppresses an unchanged report for an hour, and one of them derived a cost from it — "at most one write per mount per hour", wrong by six. `EMBED_REPORT_REFRESH_MS` is named where that derivation sits, as SahajCloud's, since the constant is theirs and a reader could take it for ours. Comment-only: `comment-fingerprint.mjs --base origin/main` reports both files codeHash identical, no comment moved. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYiUPhrVmQrbkoG99p
Three corrections from the branch review, each checked against SahajCloud.
`mutate.ts` had a second stale window 13 lines above the one already fixed —
"suppressed an unchanged report within the hour". The ticket's verification
greps (`an hour|hourly|by the hour`) do not match "within the hour", so a
wider `grep -ni hour` is what found it.
Both that comment and the `reportEmbed` bullet named the endpoint's two
unpinned response fields as `mount` and `stored: false`. `ClientEmbedReportResponse`
is `{ ok: true; mounts: number; updated: boolean }`
(`src/collections/Clients/endpoints/report.ts`). The "harmless CMS rename"
that bullet warns about as hypothetical had already happened, which is the
argument for not pinning them, intact.
`embed-announce.test.ts`'s fixture carried the same two wrong keys, so it
mocked a response the endpoint cannot send. It now mocks the real shape and
tests the same property — a suppressed duplicate resolves rather than throwing.
Coverage is unchanged, since the schema pins `ok` alone and tolerated either
shape; what changes is that the fixture is now true about the endpoint.
The unmetered-route breadcrumb pointed at `mergeMount`, which exists nowhere
in SahajCloud. The helper is `embedMergeSql`.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYiUPhrVmQrbkoG99p
Deploying sahajatlas with
|
| Latest commit: |
da75f85
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://dd21d0b2.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-docs-160-embed-report.sahajatlas.pages.dev |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
sahajatlas-design | da75f85 | Oct 28 2026, 04:58 PM |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The PR is the size of its problem. The ticket asked for three doc edits and the diff is six files, because criterion 2 is "no file in this repo", not "these two files" — the extra three are comment- or test-only, one commit each, joined rather than smuggled. The facts hold upstream: EMBED_REPORT_REFRESH_MS is 6 * 60 * 60 * 1000, ClientEmbedReportResponse is { ok, mounts, updated }, and the collapse really is per mount on an identical observation. No programmatic contract moved, and the window is server-side only, so neither in-tree consumer owes an edit.
What is left is register, where this repo's contract lives. One new sentence hands a host a sizing number that bounds nothing they can observe, and the correction leaves ten prose copies of one upstream constant standing.
⚠ Criterion 5 reads "No source file changes", and three changed. Disclosed in the body, but it wants a rewrite rather than a silent tick.
Findings
- should-fix
CHANGELOG.md:50— the sizing claim measures a host against our write window. - consider
docs/rules/data-layer.md:303— ten copies of a figure SahajCloud owns, nothing checking agreement.
What was checked
- SahajCloud read directly:
report.ts(embedMergeSql's docblock, thereq.userno-op path,updated: changed) andmergeEmbedReport'ssameObservation && isRecentlySeenguard. - Org-wide code search for
clients/reportand the hour wording beyond these two repos: zero hits, so no WeMeditateWeb or WordPress edit is owed. - Criteria 2 and 3 re-run on the branch: the only
one hourleft isCHANGELOG.md:49, inside the correction; noEMBED_REPORT_MIN_WRITE_INTERVAL_MS. - One
## [Unreleased]heading and no duplicate[#160], so the in-place### Addedfix rewrites nothing shipped. - Preview: nothing to open; the diff renders on no deployed page.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The entry offered 6 h as "the figure to size against if you were budgeting for our traffic". A host cannot observe it: every page load still posts one report and the response is 200 either way, so the window bounds writes on our side alone. As written it read as fewer requests. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjW5B1nNDxUFBZrA9Wp
Ten prose copies of one SahajCloud constant, with nothing checking agreement: eight of them said one hour, wrong from the day EMBED_REPORT_REFRESH_MS landed, and only a human reading caught it. At five of the six internal sites the duration carried no argument. A retry is pointless because the server collapses the repeat, whatever the window; a re-mount has nothing new to tell it either. Those drop the number and keep the reason. The one place the length is load-bearing names the constant instead, so a reader greps rather than trusts. Four copies remain, each where the figure is the point: the two host-facing changelog entries, the published figure in docs/embedding.md, and the cadence decision in data-layer.md, which already names the constant beside it. No gate can check agreement from here — the unit lane is node-only and cannot reach SahajCloud — so one number in one place is the fix. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjW5B1nNDxUFBZrA9Wp
|
Both critic threads adopted and resolved. Pushed should-fix — the sizing claim → consider — ten copies of one constant →
#160 gained three review lines. Two criteria could only be ticked by ignoring the diff — "no source file changes", and a three-file list. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
docs/rules/data-layer.mdnow records that reporting on every page load stays, with the revisit trigger.mutate.tscarried the same stale hour — criterion 2 is "no file in this repo", not "these two files".mutate.tsand thereportEmbedbullet named the endpoint's unpinned response fields asmount/stored; they aremounts/updated.embed-announce.test.ts's fixture mocked that same impossible response shape.Change outline
Contract —
docs/embedding.md§ The embed reportThe one host-facing number. A host sizing its traffic against the published figure was budgeting for six times the writes we make.
CHANGELOG.mdgains one### Changedentry for the window. The### Addedentry for #159 carried the same figure and is corrected in place — it sits in the same[Unreleased]section, so leaving it would have the file contradict itself.Contract — what the changelog entry claims about the window
A host cannot observe the collapse window. Every page load still posts one report and the response is
200either way, so the window bounds writes on our side alone. The first wording offered 6 h as "the figure to size against if you were budgeting for our traffic", which reads as fewer requests.Contract — the endpoint's response, as our docs and comments describe it
Not a change to what we send or parse.
EmbedReportResponseSchemastill pins{ ok: true }alone, deliberately. What changed is that the two keys we describe-but-never-read are now the keys SahajCloud actually returns.The "harmless CMS rename" that
data-layer.mdbullet warns about as hypothetical had already happened. That is the argument for not pinning the fields, intact — it just needed the real names.Behaviour — the decision recorded, not changed
docs/rules/data-layer.md'sreportEmbedentry gains the cadence decision, each reason pinned to the SahajCloud file that shows it rather than to a line number that rots across repos.One figure, one place
Correcting 1 h → 6 h left ten prose copies of one SahajCloud constant with nothing checking agreement — and all eight earlier copies had been wrong from the day
EMBED_REPORT_REFRESH_MSlanded. Five of the six internal sites carried the duration without an argument, so they drop it and keep the reason:Four copies remain, each where the figure is the point:
docs/embedding.md:314, the two host-facingCHANGELOG.mdentries, and the cadence decision indata-layer.md:302, which already names the constant beside it. No gate can check agreement from this repo — the unit lane is node-only and cannot reach SahajCloud — so one number in one place is the whole fix, not a step toward one.Files — the one spec touched
No product code changed.
comment-fingerprint.mjs --base origin/mainreportssrc/config/api/mutate.tsandsrc/lib/embed-announce.tscodeHash identical, no comment moved, every protected marker preserved. The cadence,IDLE_DEADLINE_MSand the module-scopereportedflag are untouched.Preview
Nothing to preview. The diff is Markdown and comments, and no deployed page renders
docs/,CHANGELOG.mdor a JSDoc block. No branch alias is read for that reason, rather than being pending.Test results
origin/main(6f91dd3) merged in clean, no conflict. It carried fix(deps): bump zod to 4.6.7 and @hookform/resolvers to 5.9.2 #339's zod bump and newmutate.test.tscases, so the gate below tests the merged result..claude/skills/pr-prep/check.sh— lint, typecheck,test:run(154 files, 1815 tests)src/config/api/mutate.tsmatchessecurityReview.triggerPatternon path, and the branch diff is now entirely Markdown, comments and one test fixture — no new code path, data flow or sink. No findings.pnpm sizeManual verification
EMBED_REPORT_REFRESH_MSis SahajCloud's, so our guide tracks their constant and cannot enforce it.### Changedchangelog entry's register. It tells a host the number they were given was wrong, which is a judgement about how much to say.Contract impact
docs/embedding.mdis the host-facing contract, so it changes here withCHANGELOG.mdas the rule requires. Nothing a consumer reads programmatically changed — no attribute, origin, CSP entry, URL shape or response field we parse — soWeMeditateWeb/lib/atlas-embed.tsand the WordPress plugin's templates need no edit. Neither repo is in this session's checkout; neither encodes the collapse window, which only the server applies.Notes for reviewer
comment-fingerprint.mjsassertion instead of a file list, and criterion 5 reads "no product code changes" rather than "no source file changes" — the old wording a reviewer could only tick by ignoring the diff.mutate.tsdefect.an hour|hourly|by the hourdoes not match "within the hour".grep -ni houris what found it, and the checklist now uses the wider pattern.grep -n 'an hour'has no hit left anywhere inCHANGELOG.md. An earlier draft of this body claimed one at line 49; the string there is "one hour", inside the correction saying what the guides had published, and that pattern never matched it.okalone — which is the property that test covers. What changes is that the fixture is now a response the endpoint could send./code-review highran on the first push; no toolkit plugin is installed here.comment-lint.mjsreports no banned comment added. No review finding was dismissed.Detail
Why file paths and not line numbers. The ticket asked for the three reasons "each checkable at a line" and cited
report.ts:26,:118,:154. The always-loadeddocs/rules/code-comments.mdforbids pointing at a moving target, and a line number in a sibling repo is the clearest case of one. The entry names the file plus the symbol or path to look for (embedMergeSql, the no-op path,EMBED_REPORT_REFRESH_MS), which survives their next refactor. Verified atsrc/collections/Clients/endpoints/report.ts(theembedMergeSqlcomment, thereq.userread, theupdated: changedbody) andsrc/lib/clients/embedMetadata.ts:84.Why the constant and not the number, given the constant was renamed once.
EMBED_REPORT_MIN_WRITE_INTERVAL_MS→EMBED_REPORT_REFRESH_MSis exactly the driftcode-comments.mdwarns about, so a name is not a free anchor. It wins here on the asymmetry: a renamed constant fails loudly —grepreturns nothing and the reader goes looking — while a stale number reads as true and stayed wrong for months at eight sites. Where the duration carried no argument at all, neither anchor is needed and the number simply goes.mergeMountdoes not exist. The breadcrumb I first wrote named it;grep -rn mergeMountover SahajCloud has zero hits. The helper isembedMergeSql.Whether this is a correction or a behaviour change.
git log -Lover SahajCloud'sEMBED_REPORT_REFRESH_MSshows the line was6 * 60 * 60 * 1000from the day it was introduced, so one hour was never right. That is why the changelog entry frames it as a published number being wrong rather than as the window moving. SahajCloud is a shallow clone here (50 commits), so this rests on the review pass'sgit log -Lread over the range available, not on full history.EMBED_REPORT_MIN_WRITE_INTERVAL_MSappears nowhere, per the ticket's ⚠.EMBED_REPORT_REFRESH_MSis named as SahajCloud's at both sites that name it.One cosmetic reflow. The corrected
### Addedline ran to 97 characters where its neighbours wrap near 88, and Prettier'sproseWrapispreserve, so nothing would reflow it.Closes #160
Generated by Claude Code