Skip to content

Knowledge notes: agents propose a sourced rules finding, a reviewer approves it, every account reads it - #358

Merged
cheyras merged 7 commits into
mainfrom
decke/knowledge-notes
Oct 26, 2026
Merged

cheyras merged 7 commits into
mainfrom
decke/knowledge-notes

Conversation

@cheyras

@cheyras cheyras commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Phase 6, part one: the shared knowledge base. The admin review screen comes in the next PR.

What it adds

  • Migrations
    • 089_knowledge_note.sql:
      • the knowledge_note table;
      • the knowledge.review permission, seeded to admin, super_admin and owner. The ceiling lets it be granted to a contributor role (tier 30).
      • knowledge_note_queue and knowledge_note_review (SECURITY DEFINER). These need a session. Each note is decided once (P0002 after that) and every decision is audited.
    • 090_knowledge_note_rls.sql (@supabase-only): an account sees approved notes plus its own, and inserts only its own pending note. Nobody can update or delete through the table.
  • API
    • POST /knowledge/notes: dry run by default; refuses personal data with a 422; 20 an hour; at most 20 pending; duplicates are not stored twice.
    • GET /knowledge/notes?cards=.
    • GET /admin/knowledge and POST /admin/knowledge/:id/review: browser session only.
    • Before 089 is applied, these routes answer 503 and log that once.
  • Tools
    • New propose_note (a write, destructiveHint: false on the wire).
    • get_card and rules_lookup print up to three approved notes, always quoted, under a header that says the source is the authority.
    • The rules playbook and the tool table mention it.
  • Budget
    • tools/list is 69,988 of 70,000. The save_deck and continue_token descriptions were trimmed with the same facts; the tests that pin their phrases pass.
    • Instructions are unchanged at 3,992.
  • Counts: 31 → 32 tools and 11 → 12 writes, in every doc, the landing copy and the link-preview card (re-rendered).

Verified

  • DB suite knowledgeNotes.mjs against real PG16 with every migration: 7/7.
  • agent-tools test:variants: 401/401.
  • mcp test:adapter: 24/24.
  • mcp test:cloud (docs counts): 48/48.
  • api test:pure: 349/349.
  • tsc is clean for agent-tools, api, mcp and web. decisions:check passes.

Before merge: apply 089/090 to production with the tsx runner.

🤖 Generated with Claude Code

https://claude.ai/code/session_015oYErNsTyzvYNppwoipzdY

…pproves it, every account reads it

Phase 6 of the skill-tests plan, part one (the admin screen is next).

- 089/090: knowledge_note, the knowledge.review permission (admin tiers;
  grantable to a contributor), queue + review functions, audited, RLS.
- /knowledge/notes (propose, dry run by default; read) and
  /admin/knowledge (queue, review) behind a browser session.
- propose_note tool; get_card and rules_lookup show approved notes,
  quoted as third-party text.
- Automatic checks refuse personal data and flag the rest for review.
- Counts 31 -> 32 tools (12 write) across docs and the preview card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015oYErNsTyzvYNppwoipzdY
@vercel

vercel Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
deckpal Ready Ready Preview Oct 26, 2026 8:22pm UTC

Request Review

github-actions[bot]
github-actions Bot previously approved these changes Oct 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved automatically: authored by the repository owner, from a branch in this repo. GitHub forbids self-approval, so this stands in for it (AGENTS.md B12). Required status checks still apply — this does not merge anything.

… names and links checked (Astra round 1)

- 089 turns RLS on with no policy, so a client role reaches nothing until
  090's policies exist (proven in the DB suite between the two files).
- knowledge_require_reviewer(): session, active account, knowledge.review;
  not admin.access, which a contributor can never hold. A contributor now
  lists and decides notes (tested).
- noteKey(): one normal form for storing and looking up card names;
  rules_lookup passes the names as given, not the punctuation-stripped form.
- The source link is checked for an email (as typed and percent-decoded) and
  user:password; a long number in it is flagged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015oYErNsTyzvYNppwoipzdY
github-actions[bot]
github-actions Bot previously approved these changes Oct 19, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved automatically: authored by the repository owner, from a branch in this repo. GitHub forbids self-approval, so this stands in for it (AGENTS.md B12). Required status checks still apply — this does not merge anything.

… review (Astra round 2)

- knowledge_note_propose() is the only way a note is stored: no INSERT
  policy, so a client calling Supabase directly cannot skip the limits
  (20 waiting, 20 an hour), duplicate check or personal-data refusal,
  which the function enforces itself. Session or token may propose.
- The checks column is gone: reviewer flags are computed from the stored
  note when the queue is read, so a proposer cannot supply an empty list.
- The link is decoded escape by escape, so a malformed escape elsewhere no
  longer hides an encoded email (regression test).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015oYErNsTyzvYNppwoipzdY
github-actions[bot]
github-actions Bot previously approved these changes Oct 19, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved automatically: authored by the repository owner, from a branch in this repo. GitHub forbids self-approval, so this stands in for it (AGENTS.md B12). Required status checks still apply — this does not merge anything.

…database decodes links fully (Astra round 3)

- /knowledge joins the self-host request-transaction paths (now the named
  SELF_HOST_REQUEST_TX in db.ts, tested), so knowledge_note_propose() sees
  who is asking instead of answering 403.
- knowledge_url_decode(): every %XX escape decoded on its own and
  repeatedly, so %25%34%30 is caught as @; card names are checked for phone
  numbers too. DB suite: a self-host identity proposes, and both bypasses
  are refused (12/12 on PG16).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015oYErNsTyzvYNppwoipzdY
github-actions[bot]
github-actions Bot previously approved these changes Oct 19, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved automatically: authored by the repository owner, from a branch in this repo. GitHub forbids self-approval, so this stands in for it (AGENTS.md B12). Required status checks still apply — this does not merge anything.

…at it leaves no page stale

CI's approvalPhrases and writeRefresh tests require every write tool in
Deck-E's tables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015oYErNsTyzvYNppwoipzdY
github-actions[bot]
github-actions Bot previously approved these changes Oct 26, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved automatically: authored by the repository owner, from a branch in this repo. GitHub forbids self-approval, so this stands in for it (AGENTS.md B12). Required status checks still apply — this does not merge anything.

…is dated recently, not 2026-09-28

- copy.ts: propose_note in the "Catalog, prices and rules" group of
  llms.txt and /connect; the Read-and-change line says it can propose a
  rules note. landingCopy test: 32 tools (20 read, 12 write).
- improvement.mjs: validLeg shares a turn with legs recorded at real time,
  and a turn's latency is integer milliseconds, so the fixed 2026-09-28 leg
  overflowed it (22003, masked as "Invalid improvement leg numeric field")
  from 2026-10-23 on every branch. The leg is now a minute old, and the
  day-filter check asserts what the filter keeps rather than a fixture
  count that depended on the run date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015oYErNsTyzvYNppwoipzdY
github-actions[bot]
github-actions Bot previously approved these changes Oct 26, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved automatically: authored by the repository owner, from a branch in this repo. GitHub forbids self-approval, so this stands in for it (AGENTS.md B12). Required status checks still apply — this does not merge anything.

…ion routers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015oYErNsTyzvYNppwoipzdY

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved automatically: authored by the repository owner, from a branch in this repo. GitHub forbids self-approval, so this stands in for it (AGENTS.md B12). Required status checks still apply — this does not merge anything.

@cheyras
cheyras merged commit e3c2269 into main Oct 26, 2026
22 of 25 checks passed
@cheyras
cheyras deleted the decke/knowledge-notes branch October 26, 2026 20:46

This branch was successfully deployed

1 active deployment
Preview — 151236b2 Deployed Oct 26, 2026 by vercel[bot]
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