Skip to content

feat(addie): surface CTA context blocks in Addie's system prompt - #3377

Merged
bokelley merged 2 commits into
mainfrom
bokelley/addie-context-coverage
Apr 28, 2026
Merged

bokelley merged 2 commits into
mainfrom
bokelley/addie-context-coverage

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Why

When we built the suggested-prompts engine we hydrated five new `MemberContext` blocks (`certification`, `agent_testing`, `perspectives`, `next_event`, `adoption`) — but `formatMemberContextForPrompt` (the function that injects user context into Addie's system prompt) was never updated to read them.

Result: Addie has been blind to all this state when reasoning. A learner clicks "Continue A1" → Addie sees the message but her system prompt has no idea they have an in-progress A1 attempt. Best case: she calls a cert tool to find out. Common case: generic response.

What changed

`formatMemberContextForPrompt` now renders sections for all five blocks. Specific signals surfaced:

  • Certification: in-progress with module id + started-days, flagged stale past 45 days; passed/failed summarized
  • Agent Testing: last test age + outcome, stale flag past 14 days; "no tests on record" nudge for builders who haven't tested yet
  • Perspectives: zero-state writing nudge or count + last-published-days
  • Upcoming Event: registered title + days-until
  • Org Adoption: missing public company listing, low team WG coverage

Why this matters beyond this PR

This is a small fix but a meaningful invariant: any new MemberContext field must be surfaced to both the rules engine AND Addie's prompt. Otherwise we end up with two parallel data planes — one for picking prompts, one for reasoning about them — and they drift.

Test plan

  • 9 new tests covering each rendered section + negative case (adoption section omitted when nothing notable)
  • 125 unit tests pass total across member-context + suggested-prompts files
  • tsc clean

🤖 Generated with Claude Code

bokelley and others added 2 commits April 28, 2026 03:10
These five MemberContext blocks were hydrated for the suggested-prompts
engine but never plumbed through to Addie's system prompt:

- certification: in-progress attempts with module id and started-days,
  flagged as stale past 45 days; passed/failed states summarised
- agent_testing: last test age and outcome, stale flag past 14 days,
  no-tests-on-record nudge for never-tested users
- perspectives: zero-state writing nudge or count + last-published-days
- next_event: upcoming registered event with days-until
- adoption: missing public company listing, low team WG coverage

Closes the data-flow gap where Addie was forced into tool round-trips
(or worse, generic responses) for state we already had on context. The
suggested-prompts rules and Addie's reasoning now both read the same
hydrated context blocks.

Tests: 9 new cases covering each rendered section, plus the negative
case where adoption signals are healthy and the section is omitted.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
prompt-engineer review on #3377 flagged that lines like "gently
suggest", "if they discuss X, suggest tool Y", "be encouraging if
they want to retry" are response policy, not user context. Three
problems: (a) different users get different policy depending on
hydration, (b) the same nudge is restated in N places with drift
risk, (c) prompt-injection surface widens since user-controlled
fields rendered nearby could smuggle directives.

Keep the factual signals (cert in-progress with module id and age,
test staleness flag, perspectives count, etc.); strip the imperatives.
Response policy belongs in server/src/addie/rules/*.md, applied
uniformly when the corresponding signal is present.

35 unit tests still pass — assertions that checked "stale" and
"older than 45 days" still match the trimmed wording.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley merged commit 1d66fa7 into main Apr 28, 2026
14 checks passed
@bokelley
bokelley deleted the bokelley/addie-context-coverage branch April 28, 2026 07:18
bokelley added a commit that referenced this pull request Apr 28, 2026
…fig) (#3382)

* refactor(addie): co-locate cross-cut CTAs in one registry (strangler)

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]>

* fixup: apply expert review for #3382

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]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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