Skip to content

feat(addie): add canonical URL reference to Addie KB - #3390

Merged
bokelley merged 3 commits into
mainfrom
claude/issue-2564-canonical-url-reference
Apr 28, 2026
Merged

bokelley merged 3 commits into
mainfrom
claude/issue-2564-canonical-url-reference

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Closes #2564

Adds server/src/addie/rules/urls.md — a single source of truth for all owned-domain URLs Addie is permitted to cite. This is the last open acceptance criterion from #2564: the /terms redirect (http.ts:1881), the alerts.ts broken link fix, and the check-owned-links.js Addie-source scan were all already merged to main.

Non-breaking justification: adds an optional new rules file and a string entry to an existing array; no existing behavior removed or changed.


Changes

  • server/src/addie/rules/urls.md (new): Canonical URL catalog for Addie. Intro is written from Addie's perspective ("do not cite owned-domain URLs not on this list"). Covers all agenticadvertising.org and docs.adcontextprotocol.org pages referenced across existing rule files, plus a CRITICAL-flagged Deprecated section for testing.adcontextprotocol.org.
  • server/src/addie/rules/index.ts: Adds 'urls.md' to RULE_FILES_BEFORE_CONTEXT so the reference loads into Addie's system prompt on every request.
  • .changeset/addie-canonical-url-reference.md: Empty changeset — server-side Addie change, no protocol bump.

Pre-PR review

  • code-reviewer: approved — no type errors introduced; one noted issue: testing.adcontextprotocol.org hostname is not in check-owned-links.js's LINK_HOSTS set, so the deprecated entry is not CI-validated. Fixed by clarifying the header text ("live section only; deprecated entries are excluded from CI checks").
  • prompt-engineer: approved after fixes — intro rewritten from Addie's perspective; deprecated section upgraded to CRITICAL framing.

Reviewer decision needed: placement of urls.md

The prompt-engineer flagged RULE_FILES_BEFORE_CONTEXT vs RULE_FILES_AFTER_CONTEXT as a judgment call:

  • Current placement (BEFORE_CONTEXT, after knowledge.md): treats URL reference as factual grounding — Addie reads what URLs exist before it gets behavioral constraints. URLs are factual; knowing them early is defensible.
  • Prompt-engineer's recommendation (AFTER_CONTEXT, before constraints.md): treats URL reference as a constraint — matches the "do not cite X" pattern of constraints.md. Concern: dynamic current-context could introduce URLs before Addie has read the allowlist.

Both positions are architecturally coherent. The code works correctly either way. @bokelley, your call: keep in BEFORE_CONTEXT (no change needed) or move to top of AFTER_CONTEXT (one-line edit to index.ts).

Notes

  • Existing rules files (knowledge.md, constraints.md, behaviors.md) still hardcode some inline owned-domain URLs. urls.md is additive — it doesn't retroactively enforce itself on existing inline references. A follow-up sweep to replace inline URLs with a pointer to this file would complete the SSOT property, but is not required for this issue.

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num> →
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See #3121
for context.

Session: https://claude.ai/code/session_01SCrAt1cyzRGAAngzijPNzu


Generated by Claude Code

Add `server/src/addie/rules/urls.md` as the single source of truth for
owned-domain URLs Addie is permitted to cite. Closes #2564.

- New `urls.md` rule file lists all live agenticadvertising.org and
  docs.adcontextprotocol.org URLs with per-entry descriptions; includes
  a CRITICAL-flagged Deprecated section for retired URLs.
- `rules/index.ts`: add `urls.md` to `RULE_FILES_BEFORE_CONTEXT` so
  Addie's context includes the reference on every request.
- CI broken-link checker already scans `server/src/addie/rules/*.md`
  via glob — no script changes required for live URLs to be validated.

https://claude.ai/code/session_01SCrAt1cyzRGAAngzijPNzu
@bokelley bokelley added the claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage. label Apr 28, 2026
@bokelley

Copy link
Copy Markdown
Contributor Author

Prompt-engineer review:

Verdict: ship after adding a 'doesn't exist' subsection.

✅ Wiring is right — urls.md loaded into system prompt via RULE_FILES_BEFORE_CONTEXT in server/src/addie/rules/index.ts. 46 lines is negligible token cost. Right surface per the addie_rules_in_markdown pattern.

✅ Anti-hallucination shape is adequate — opening rule plus search_docs fallback.

⚠️ Coverage gap: doc enumerates real paths but doesn't call out hallucinations. Common Addie hallucinations Mary's escalations show:

  • /terms ✓ covered (canonical /legal/terms)
  • /privacy ✓ covered
  • /billing — implicit (/dashboard mentions billing) but not flagged as hallucination target
  • /membership — partial (/dashboard/membership listed) but /membership itself isn't flagged
  • /about, /faq, /contact, /help — not addressed. LLM extrapolating from the redirect pattern (/terms → /legal/terms) may invent /legal/about.

Add a 'Common hallucinations — these don't exist' subsection with each invented path and either the canonical substitute or 'doesn't exist, ask the user'. That hardens the anti-hallucination guard from soft ("do not cite URLs not on this list") to specific ("if you find yourself wanting to cite /about, stop — use search_docs or ask").

⚠️ Soft language: "When in doubt" is weaker than "If a URL is not listed here, do not emit it." Tighten.

⚠️ Verify scripts/check-owned-links.js actually scans rules/*.md (changeset claims it but diff doesn't touch the script). If true, link-rot fails CI; if false, this doc goes stale silently.

🔹 Inverse-coverage gap (low priority): no check that flags new site routes missing from urls.md. New nav entries get uncited silently. Worth a follow-up issue.

Recommend the routine apply the missing subsection + tighter language, then merge.

…er review

Tighten intro from "when in doubt" soft language to a hard "if not listed, do
not emit" rule, with an explicit warning against path extrapolation. Add
"Common hallucinations" table covering /billing, /membership, /about, /faq,
/contact, /help, /legal/about, and the /terms + /privacy redirect aliases.

https://claude.ai/code/session_01T2BtP4RrgRbGZccroBYYSt
@bokelley

Copy link
Copy Markdown
Contributor Author

Applied both substantive items from the prompt-engineer review (bfe5763):

Tightened language: "When in doubt" replaced with a hard rule — "If a URL is not listed here, do not emit it." Added an explicit warning against path extrapolation (e.g. /terms→/legal/terms does not imply /legal/about exists).

Common hallucinations table added: 9-row table covering /billing, /membership, /about, /faq, /contact, /help, /legal/about, and the /terms+/privacy redirect aliases — each with a canonical substitute or search_docs redirect.

check-owned-links.js claim verified: scripts/check-owned-links.js line 18 includes 'server/src/addie/rules/*.md' in the glob — the changeset claim is correct. Live URLs in urls.md will fail CI if they go stale. The hallucinations table uses bare paths (no https:// prefix) so the link checker won't attempt to validate them.

Low-priority inverse-coverage gap (no check that flags new site routes missing from urls.md) noted as a follow-up issue — not blocking this PR.

Session: https://claude.ai/code/session_01T2BtP4RrgRbGZccroBYYSt


Generated by Claude Code

@bokelley

Copy link
Copy Markdown
Contributor Author

On the broken-link check question — there's already scripts/check-owned-links.js (per the prompt-engineer review). The cleanest extension here is to wire it to scan server/src/addie/rules/urls.md and validate every URL on the list returns 200 (or known-redirect):

// scripts/check-owned-links.js or a new check-rules-urls.js
const RULE_URLS = [
  'server/src/addie/rules/urls.md',
];
// extract every URL on agenticadvertising.org / docs.adcontextprotocol.org / etc.
// fetch each, fail CI if any return 404 or unexpected redirect target

Two things would catch:

  1. Link rot: a URL on the list 404s after a site change → CI fails before Addie cites the dead link
  2. Redirect drift: /terms returns 301 → /legal/terms (good); but if the redirect target changes to /legal/terms-of-service and the doc still says /legal/terms, the cited URL is technically wrong. Easy to catch by following redirects and checking the final URL.

The inverse (new site routes missing from urls.md) is harder — would require knowing the site nav structure. Lower priority follow-up.

Recommend the routine extend check-owned-links.js to scan urls.md, OR file a separate issue if the URL doc is on a different cadence than the rest.

@bokelley

Copy link
Copy Markdown
Contributor Author

Good catch on the redirect drift case — worth tracking. Two notes:

Link rot is already wired. check-owned-links.js line 17 already has 'server/src/addie/rules/*.md' in getCandidateFiles(). Once this PR merges, urls.md is automatically in scope — no script extension needed. Every owned-domain URL in the live section gets a HEAD/GET check on every PR.

Redirect drift is not yet handled. The current script uses redirect: 'follow' and checks the final status, but doesn't compare the post-redirect URL against the documented canonical path. So if /legal/terms silently changed targets to /legal/terms-of-service, CI would pass (the redirect is still reachable) but urls.md would cite the wrong canonical. That's the real gap.

I'll file a follow-up issue for redirect drift detection — the fix is straightforward (use redirect: 'manual', capture the location header, compare against the documented URL) but it's a separate concern from this PR.


Generated by Claude Code

@bokelley

Copy link
Copy Markdown
Contributor Author

Issue #3458 proposes redirect-drift detection in check-owned-links.js for urls.md canonical paths — same surface as this PR; consider folding before merge or confirm follow-up.


Generated by Claude Code

@bokelley

Copy link
Copy Markdown
Contributor Author

Got it — redirect drift is now tracked as #3458 (triaged as blocked-on this PR). No action needed here; it'll resurface when #3390 merges.


Generated by Claude Code

@bokelley

Copy link
Copy Markdown
Contributor Author

Confirming #3458 as a follow-up, not a fold candidate here.

This PR is already past expert review with a clean 72-addition scope (Addie rules file + index.ts entry). Folding the redirect-drift detection in check-owned-links.js would add CI scripting changes to a different surface after the current open design decision (BEFORE_CONTEXT vs AFTER_CONTEXT) is still pending — materially expanding the diff mid-review. #3458 is self-contained and ships cleanly after this merges; the Blocked-on: #3390 linkage on that issue handles sequencing.


Generated by Claude Code


Generated by Claude Code

@bokelley

Copy link
Copy Markdown
Contributor Author

Acknowledged — #3458 confirmed as follow-up, not a fold candidate. The Blocked-on: #3390 linkage on that issue handles sequencing.

The BEFORE_CONTEXT vs AFTER_CONTEXT placement decision is still open on this PR whenever you're ready to call it. No code change needed here until then.


Generated by Claude Code


Generated by Claude Code

urls.md is primarily prohibitive ("do not cite URLs not on this list"),
making it a peer of constraints.md, not of knowledge.md. Placing it in
AFTER_CONTEXT ensures the allowlist binds after dynamic current-context
is loaded — the constraint lands as the final word on URL citation rather
than being read before content that could introduce new URLs.

https://claude.ai/code/session_019PkvZB6F9LrjYbsPu5Zq7Y
@bokelley

Copy link
Copy Markdown
Contributor Author

Placement decision: moved to AFTER_CONTEXT, top of the constraint layer.

urls.md's governing instruction is "if a URL is not listed here, do not emit it" — that's a prohibition, not factual knowledge. Factual grounding (identity, behaviors, knowledge) belongs in BEFORE_CONTEXT; prohibitive rules belong in AFTER_CONTEXT alongside constraints.md. The prompt-engineer's concern holds: placing the allowlist after dynamic current-context means the constraint lands as the final word on URL citation rather than being read before content that could introduce new URLs.

Pushed as a follow-up commit (71b7c41): urls.md moved from RULE_FILES_BEFORE_CONTEXT to the top of RULE_FILES_AFTER_CONTEXT; updated the inline comment to reflect that the constraint layer (not just response-style) is what binds after dynamic content loads.


Generated by Claude Code


Generated by Claude Code

@bokelley

Copy link
Copy Markdown
Contributor Author

Noted — placement decision looks right. A prohibition ("do not cite URLs not on this list") belongs in the constraint layer so it lands after dynamic context loads, not before. 71b7c41 looks correct.


Generated by Claude Code


Generated by Claude Code

@bokelley

Copy link
Copy Markdown
Contributor Author

Acknowledged — noted that 71b7c41 is good and the AFTER_CONTEXT placement is the right call. Ready for merge whenever you'd like to mark it ready.


Generated by Claude Code

@bokelley
bokelley marked this pull request as ready for review April 28, 2026 16:47
@bokelley
bokelley merged commit 76a0c92 into main Apr 28, 2026
14 checks passed
@bokelley
bokelley deleted the claude/issue-2564-canonical-url-reference branch April 28, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

website: fix /terms route and audit Addie-cited URLs

2 participants