Skip to content

docs(campaign): name the metric block's real writers, per site - #1690

Merged
os-steve merged 1 commit into
mainfrom
claude/issue-1668-retired-snapshot-hook-name
Sep 6, 2026
Merged

docs(campaign): name the metric block's real writers, per site#1690
os-steve merged 1 commit into
mainfrom
claude/issue-1668-retired-snapshot-hook-name

Conversation

@os-steve

@os-steve os-steve commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Closes #1668

campaign_snapshot_metrics was retired in #597. The campaign metric block is now owned by four refresh hooks — campaign_metrics_refresh, campaign_attribution_refresh, campaign_lead_conversion_refresh (campaign.hook.ts) and campaign_member_metrics_refresh (campaign_member.hook.ts); all four names re-verified as live name: declarations on origin/main.

The count first: nine occurrences, not four

The card listed 4 files. A full-tree grep (git grep -n, plus a raw grep -rn over the working dir including content/, docs/, scripts/ to catch anything untracked) finds nine occurrences across nine files. content/, docs/ and scripts/ are clean — every hit is in src/, test/ or .changeset/.

That is one more file than the dispatch's own count of 8: .changeset/six-readonly-notes-audited-per-writer.md landed with PR #1670 after that grep was taken.

Per-site decision

Read and decided per site, not renamed in bulk — several occurrences narrate what changed and are supposed to keep the old name.

# site verdict why
1 src/flows/campaign-completion.flow.ts:14 (a) name the real writer Said "the existing campaign_snapshot_metrics afterUpdate hook then snapshots into metrics" — a live claim, and false.
2 src/data/sales.seed.ts:929 (a) name the real writer "is what campaign_snapshot_metrics counts when a campaign completes" — present-tense data relationship.
3 test/seed-consistency.test.ts:24 (a) name the real writer A hook→field-block map entry, present tense, claims it is live.
4 test/seed-consistency.test.ts:274 (a) name the real writer describe block named for the retired hook.
5 test/campaign-member-lifecycle.test.ts:235 (b) past tense Deliberately historical, but opened with a bare hook name.
6 src/objects/campaign.hook.ts:93 (c) leave Already "The old campaign_snapshot_metrics fired on → completed and nothing else", followed by "Completion is now simply one of the transitions this catches."
7 src/objects/campaign_member.hook.ts:168 (c) leave Already "what the removed campaign_snapshot_metrics made everyone wait for."
8 src/objects/campaign.object.ts:169 (c) leave Corrected by PR #1670 — verified below. Not this card's territory.
9 .changeset/six-readonly-notes-audited-per-writer.md:36 (c) leave PR #1670's own changeset, recording a landed change; already says "a hook retired long ago". Rewriting it would rewrite the record of what that PR did.

What (a) resolved to

  • The flow: the nightly sweep flips in_progress → completed, which is a status transition, so campaign_metrics_refresh recomputes on it. The note now also says this is a refresh, not a snapshot — the block was already current before the sweep ran.
  • The seed: the writer that counts attributed opportunities is campaign_attribution_refresh (object: 'crm_opportunity', afterInsert/afterUpdate/afterDelete, computing num_opportunities / num_won_opportunities / summed actual_revenue) — on every opportunity write, not once at completion.
  • seed-consistency.test.ts: the map entry and the describe both name the refresh, and a comment above the block carries all four hook names.

One bounded in-place fix, declared

Inside the renamed describe, an it still explained its assertion as a completion-time snapshot ("The hook only fires on the transition INTO completed"). Renaming the block re-points that comment at the four refresh hooks, making it newly false — so it was corrected in the same edit. Same defect class as the card, prose + it name only, no new verification surface.

Verification of the card's own premises

Acceptance

After this change, a reader who greps campaign_snapshot_metrics gets six hits, and every one is past tense and self-identifying as history: "a hook retired long ago" · "The old …" · "the long-retired … : [all four names]" · "the removed …" · "The RETIRED … gone since #597, replaced by the four refresh hooks" · "used to sit here alone … it was replaced by". Three of the six name the replacement hooks outright. No hit reads as live.

Constraints honoured

  • Zero assertion changes. The diff contains no expect( line at all, added or removed — including the message arguments. Only comments, one describe name and one it name.
  • ⛔ No new gate, no new test (AGENTS.md §3). ⛔ content/docs/releases/ untouched.
  • One changeset (patch). The token ratchet is comment-stripped and excludes test/, so the prose is not chargeable: business semantics ~85,032 · interaction layer ~37,963 · authored total ~137,336, all unchanged and clean.

Tests

pnpm verify fully green, exit 0, at 4050ba00 — all eight stages ran (validate, typecheck, lint, lint:i18n-gate, hygiene, hygiene:tokens, build, test):

✓ source token ratchet clean
 Test Files  161 passed (161)
      Tests  3414 passed | 1 skipped (3415)
   Duration  133.43s

🤖 Generated with Claude Code

https://claude.ai/code/session_018xtjdpZFjgWh4Ad9Wcx68J


Generated by Claude Code

`campaign_snapshot_metrics` was retired in #597 and the campaign metric block is
now owned by four refresh hooks — `campaign_metrics_refresh`,
`campaign_attribution_refresh`, `campaign_lead_conversion_refresh` in
`campaign.hook.ts`, and `campaign_member_metrics_refresh` in
`campaign_member.hook.ts`. Several live comments still named the retired hook as
the current writer.

A tree-wide grep found nine occurrences over seven files, not the four the audit
listed. Each was read on its own terms rather than renamed in bulk, because
several of them narrate what changed and are meant to keep the old name.

Named the real writer where the comment claimed the hook was live:

- `campaign-completion.flow.ts` called it "the existing `campaign_snapshot_metrics`
  afterUpdate hook" that "then snapshots into metrics". The nightly flip is a
  `status` transition, so `campaign_metrics_refresh` recomputes on it — and the
  block was already current before the sweep ran, so the note says refresh
  rather than snapshot.
- `sales.seed.ts` described the opportunity `crm_campaign` link as what the
  retired hook "counts when a campaign completes". `campaign_attribution_refresh`
  is what counts attributed opportunities, on every insert, update and delete.
- `seed-consistency.test.ts` listed the retired hook in its hook-to-field map and
  named a `describe` block after it. Both now name the refresh, and the block
  carries the four hook names. The `it` inside that still explained its assertion
  as a completion-time snapshot was corrected as well: the renamed block would
  otherwise have attributed completion-only firing to the four refresh hooks.

Marked as history where the mention is deliberate:

- `campaign-member-lifecycle.test.ts` needs the old name to explain why a
  completion-time assertion cannot prove the acceptance criterion. It now opens
  "The RETIRED `campaign_snapshot_metrics` — gone since #597" instead of leading
  with a bare hook name in the past tense.

Left alone, already self-evidently historical: `campaign.hook.ts` ("The old …"),
`campaign_member.hook.ts` ("the removed …"), `campaign.object.ts` ("the
long-retired …", corrected by #1670) and that PR's changeset ("a hook retired
long ago").

No assertion changed: comment, block-name and prose only. `pnpm verify` green.

Co-authored-by: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
hotcrm Ignored Ignored Sep 6, 2026 10:52am UTC

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Server-side behaviour — hooks, flows, actions ci/cd CI plumbing and the verification pipeline metadata Declarative metadata — schema, security posture, UI surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[finding] campaign_snapshot_metrics was retired, but four live files still name it as the writer of the campaign metric block

2 participants