Skip to content

refactor(addie): co-locate cross-cut CTAs in one registry (strangler-fig) - #3382

Merged
bokelley merged 2 commits into
mainfrom
bokelley/strangler-profile-cta
Apr 28, 2026
Merged

bokelley merged 2 commits into
mainfrom
bokelley/strangler-profile-cta

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Why

`pickNudge` in `digest-nudge.ts` maintained its own parallel rule list with 7 priority-ordered CTAs. Three of them (cert continuation, find a WG, complete profile) duplicated logic in the suggested-prompts engine — adding a new CTA meant editing two files in sync, with drift risk on copy and eligibility.

What this changes

  • Cross-cut CTAs — three rules in `prompt-rules.ts` (`cert.continue_in_progress`, `wg.find_groups`, `profile.incomplete`) now have an optional `digest` facet alongside their existing `pull` fields. Each facet keeps its own `when` clause typed against the surface's native shape (`MemberContext` for pull, `DigestEmailRecipient` for digest). We share the catalog, not the eligibility logic — the alternative was a lossy shape adapter, and per-surface gates are more honest about each surface's constraints (e.g., the digest WG nudge gates on `has_slack` because joining a WG without Slack is harder; suggested-prompts doesn't, because the user is already in a chat surface).
  • Digest-only CTAs — three nudges with no pull-surface analog (member conversion, Slack onboarding, contributor cert) live in a new `DIGEST_ONLY_NUDGES` list.
  • pickNudge — now a 15-line wrapper that merges the two lists, filters by `digest.when`, returns the lowest-priority match. No behavior change — same 7 nudges, same priority order (1-6 + dynamic cert text), same copy.

Documented invariants

Added to `.agents/playbook.md`:

  1. `MemberContext` fields must surface to both the hydration path AND `formatMemberContextForPrompt` (closes the gap from PR feat(addie): surface CTA context blocks in Addie's system prompt #3377).
  2. Cross-cut CTAs co-locate in the rule registry; each surface keeps its own `when` clause.

Test plan

  • 14 new tests in `tests/unit/digest-nudge.test.ts` covering each rule's eligibility, priority ordering between cross-cut and digest-only CTAs, dynamic cert text grammar (singular/plural module count), null return for fully-engaged recipients
  • Existing 90 suggested-prompts tests + 35 member-context tests still pass (139 total in scope)
  • tsc clean

🤖 Generated with Claude Code

bokelley and others added 2 commits April 28, 2026 03:31
The digest-newsletter pickNudge maintained its own parallel rule list,
duplicating "Continue cert", "Find a WG", "Complete profile" with the
suggested-prompts engine. Adding a new CTA meant editing two files in
sync.

Co-locate the catalog: cross-cut rules in prompt-rules.ts now have an
optional `digest` facet alongside their `pull` fields. Each facet
keeps its own `when` clause typed against the surface's native shape
(MemberContext for pull, DigestEmailRecipient for digest) — we share
the catalog, not the eligibility logic. Lossy adapters between the
two shapes were the alternative; per-surface gates are honest.

Three digest-only CTAs (become member, join Slack, contributor cert)
live in a separate DIGEST_ONLY_NUDGES list since they have no
pull-surface analog. Adding more lists like this is the migration
path for future surfaces (push DM jobs, etc.).

pickNudge becomes a 15-line wrapper. No behavior change — same 7
nudges, same priority order (1-6 + the dynamic cert text), same
copy. 14 new digest-nudge tests covering each rule's eligibility,
priority ordering between cross-cut and digest-only CTAs, dynamic
cert text grammar.

Also documents two invariants in .agents/playbook.md:
- MemberContext fields must surface to both hydration and
  formatMemberContextForPrompt (the data-plane invariant from #3377)
- Cross-surface CTAs co-locate in the registry; each surface keeps
  its own when clause

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Code review:
- Extract RuleWithDigest type alias instead of inline `r is typeof r &
  { digest: DigestNudgeFacet }` narrowing
- Deterministic secondary sort key on `id` so ordering doesn't rely
  on V8's stable-sort guarantee implicitly
- New boundary test: zero-progress non-contributor must not receive
  the cert nudge (locks in cert facet's `> 0 && < total` gate)

DX-expert:
- Boot-time assertion in prompt-rules.ts: any rule with function-
  valued `prompt` must provide `matchClick`. Without it, click
  telemetry silently zeros for the new rule. Catching at module load
  is cheaper than discovering weeks later when CTR is empty.
- Playbook invariants now pair each rule with "what mistake this
  prevents" + a code-pointer (canonical example) so future contributors
  can pattern-match instead of inferring abstract intent.

Product expert: no blockers. The cert digest "Continue learning" vs
pull "Continue A1" copy mismatch is real but minor (different
surfaces, different attentional contexts). Defer.

140 unit tests total.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley merged commit ae43687 into main Apr 28, 2026
14 checks passed
@bokelley
bokelley deleted the bokelley/strangler-profile-cta branch April 28, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant