Skip to content

docs(embedding): keep reporting every load, correct the 1 h collapse #160

Closed

Description

@Ardnived

Summary

The widget POSTs an embed report on every page load (#153). That cadence stays. This ticket no
longer measures it or changes it: it records the decision where the next reader will look, and
corrects two places that still describe the server's collapse window as 1 h when the code
collapses at 6 h.

Decisions

  • Does reporting on every page load stay? → Yes. The route is unmetered, a repeat costs no
    extra read, and writes collapse within 6 h. Revisit only if Railway CPU spent on
    POST /api/clients/report becomes noticeable. (Ardnived, 2026-10-28)

Approach

Three doc edits and a changelog entry. No product code changes, so nothing here touches
src/lib/embed-announce.ts.

⚠ Edit docs/rules/data-layer.md, never .claude/rules/data-layer.md. The second is a
symlink to the first, and a write at a path under .claude/ is a protected path: the prompt
never fails, the run just waits until its lease expires having written nothing.

1. Record the decision beside the reportEmbed entry (docs/rules/data-layer.md:291),
with the three reasons it is cheap, each checkable at a line:

  • The route is unmetered. clients is excluded from the usage plugin, so no
    beforeOperation hook fires on it and nothing increments a usage counter
    (SahajCloud/src/collections/Clients/endpoints/report.ts:26).
  • A repeat costs no extra read. req.user is the full client doc, so the handler reads
    embedMetadata off it and answers updated: false with no query and no write
    (report.ts:118, report.ts:154).
  • Writes collapse within 6 h, per EMBED_REPORT_REFRESH_MS
    (SahajCloud/src/lib/clients/embedMetadata.ts:84).

Name the revisit trigger in the same paragraph: Railway CPU spent on /clients/report.

2. Correct docs/embedding.md:314 — "at most one write an hour" → 6 h. This is the
host-facing number, so keep the sentence's register: a host is being told how often a repeat
report turns into a write, not what a constant is called.

3. Correct docs/rules/data-layer.md:295 — "a write the server already collapses by the
hour" → the 6 h window.

⚠ Do not name EMBED_REPORT_MIN_WRITE_INTERVAL_MS. It no longer exists, having been
renamed EMBED_REPORT_REFRESH_MS. It is SahajCloud's constant, so name it as SahajCloud's
wherever a reader could take it for ours.

4. One ### Changed entry in CHANGELOG.md's [Unreleased], with its [#NNN] link
definition at the foot of the file. The changelog leaves documentation out by its own rule
(CHANGELOG.md:9), and this is not an exception to it: the published number was wrong, so a
host that read "one write an hour" and built on it was misinformed. Record the window, not the
edit.

Acceptance criteria

  • docs/rules/data-layer.md's reportEmbed entry states that reporting on every load
    stays, gives the three reasons above with their file references, and names the revisit
    trigger.
  • docs/embedding.md says 6 h, and no file in this repo describes the server collapsing
    an unchanged report hourly.
  • The 6 h figure is written out only where it is the point: docs/embedding.md, the two
    host-facing CHANGELOG.md entries, and the cadence decision in docs/rules/data-layer.md.
    Every other site names SahajCloud's EMBED_REPORT_REFRESH_MS with no number.
    (review, review-pr, 2026-10-28)
  • No file in this repo names EMBED_REPORT_MIN_WRITE_INTERVAL_MS.
  • CHANGELOG.md's [Unreleased] carries one ### Changed entry for the 6 h window, with
    a matching [#NNN] link definition. It says the window bounds writes on our side, not
    requests from the host's page. (review, review-pr, 2026-10-28)
  • No product code changes. A comment-only edit to a source file is in scope where that file
    carried the stale figure, proved by comment-fingerprint.mjs reporting codeHash identical.
    The cadence, IDLE_DEADLINE_MS and the module-scope reported flag are untouched, so
    src/lib/embed-announce.test.ts needs no new case. (review, review-pr, 2026-10-28)

Verification checklist

  • rg -ni hour docs/ CHANGELOG.md src/config/api/mutate.ts src/lib/embed-announce.ts — no
    hit describes the report collapse window as hourly. The narrower
    an hour|hourly|by the hour is what let "within the hour" survive in mutate.ts.
  • rg -n 'EMBED_REPORT_MIN_WRITE_INTERVAL_MS' --glob '!node_modules' — no hit.
  • rg -n '6 h' docs/embedding.md docs/rules/data-layer.md — at least one hit in each.
  • node <claude-workflow>/workflow/lib/comment-fingerprint.mjs --base origin/main reports
    src/config/api/mutate.ts and src/lib/embed-announce.ts codeHash identical, so the only
    non-doc change is src/lib/embed-announce.test.ts's fixture.
  • .claude/skills/pr-prep/check.sh passes.

Notes

Activity

  1. added theissue type on Aug 28, 2026
  2. Ardnived commented on Oct 28, 2026

    @Ardnived
    ContributorAuthor

    @sydevs-bot revise Re-scope to docs. Record in .claude/rules/data-layer.md, beside reportEmbed, that reporting on every load stays: the route is unmetered, adds no extra read, and writes collapse within 6 h (EMBED_REPORT_REFRESH_MS). Correct docs/embedding.md:314 and data-layer.md:294 from 1 h to 6 h, with a CHANGELOG line. Revisit only if Railway CPU spent on /clients/report becomes noticeable. Detached from #260, which excludes it.

  3. added
    bot:working
    on Oct 28, 2026
  4. sydevs-bot commented on Oct 28, 2026

    @sydevs-bot
    Contributor

    🤖 no session running
    approved by Ardnived

    recent dispatches
    • 16:22Z implement · attempt 1 · session · done
    • 16:22Z implement · attempt 1 · session
    • 16:13Z revise · attempt 1 · session · done
    • 16:13Z revise · attempt 1 · session

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

  5. changed the title [-]perf(widget): revisit the report-on-every-load cadence[/-] [+]docs(embedding): keep reporting every load, correct the 1 h collapse[/+] on Oct 28, 2026
  6. changed the issue type fromtoon Oct 28, 2026
  7. cleared
    Hold Until
    on Oct 28, 2026
  8. sydevs-bot commented on Oct 28, 2026

    @sydevs-bot
    Contributor

    Re-scoped to docs. The body now specifies two corrections, the decision record and a changelog
    line, and nothing else. Your three reasons are recorded under ## Decisions, each pinned to a
    line in SahajCloud.

    Three things the code changed under the old body:

    • EMBED_REPORT_MIN_WRITE_INTERVAL_MS no longer exists. It is EMBED_REPORT_REFRESH_MS, so
      the docs must not name the old one.
    • The edit goes to docs/rules/data-layer.md. .claude/rules/data-layer.md is a symlink to
      it, and a write at that path stalls an unattended run on the protected-path guard.
    • The changelog's own rule leaves documentation out. The entry still belongs: the published
      number was wrong, not merely undocumented.

    Changed the type from Task to Bug — a host-facing guide states a number the code
    contradicts. Priority stays Low. Cleared the Hold Until of 2026-12-18, since the cadence
    question it parked is now answered; say so if you want it held anyway.

    @sydevs-bot implement starts the work.

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


    Generated by Claude Code

  9. removed
    bot:working
    on Oct 28, 2026
  10. moved this from Working to Awaiting in SYDevelopers Technical Roadmapon Oct 28, 2026
  11. Ardnived commented on Oct 28, 2026

    @Ardnived
    ContributorAuthor

    @sydevs-bot implement

  12. added
    bot:working
    on Oct 28, 2026
  13. moved this from Awaiting to Working in SYDevelopers Technical Roadmapon Oct 28, 2026
  14. removed
    bot:working
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Low

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions