Skip to content

feat(cli): capture terminal notes as candidates - #2801

Merged
Sinity merged 5 commits into
masterfrom
feature/fanout/terminal-note
Jul 13, 2026
Merged

Sinity merged 5 commits into
masterfrom
feature/fanout/terminal-note

Conversation

@Sinity

@Sinity Sinity commented Jul 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds zero-friction terminal memory capture: polylogue note and its write-role MCP twin create private, non-injected assertion candidates for later judgment.

Problem

Terminal observations had no one-line route into the candidate-to-judgment loop, so useful operational memory either interrupted work or vanished.

Solution

  • Register polylogue note at the root CLI with text/stdin input, bounded stdin, kind selection, session/last anchors, repo/topic scopes, and JSON/text receipts.
  • Add Polylogue.capture_assertion_candidate, which writes through the assertion chokepoint with status=candidate and inject:false.
  • Resolve last from the enclosing repository root and return clean errors for malformed, missing, or non-session anchors.
  • Expose the shared candidate payload schema through write-role MCP as capture_assertion_candidate; MCP requires an agent:<session> author reference while terminal CLI captures retain user:local attribution.
  • Keep terminal NOTE/CORRECTION candidates in the judgment queue; blackboard reads list only active, operator-approved note assertions.
  • Document an optional zsh prefill widget that preserves the prior status and safely quotes history text; regenerate the CLI reference.

Acceptance criteria

Criterion Status
Candidate NOTE write and no auto-judgment Satisfied
Session/last anchors, repo/topic scopes, unanchored flag Satisfied
note/claim/correction/lesson candidate kinds Satisfied (claim maps to the existing DECISION assertion kind)
Bounded stdin Satisfied
CLI/MCP candidate payload schema and queue semantics Satisfied; source attribution deliberately differs (user:local vs supplied agent session)
Optional zsh widget docs snippet Satisfied with an executable quoting/status regression

Verification

  • POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest devtools test tests/unit/mcp/test_candidate_capture_tool.py tests/unit/mcp/test_per_tool_contracts.py tests/unit/mcp/test_envelope_contracts.py tests/unit/cli/test_note.py — 231 passed.
  • POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest devtools verify --quick — all 15 steps successful.
  • The focused tests exercise root CLI capture, real CLI↔MCP writes into one candidate queue, MCP agent attribution in user.db, candidate exclusion from blackboard reads until acceptance, repository-root last resolution, strict anchors, bounded stdin, and the published zsh snippet against hostile history text.

Ref polylogue-dmp.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7729f108-7df5-4d3b-b091-5bb8770677af

📥 Commits

Reviewing files that changed from the base of the PR and between 5ff5b0e and f6b455c.

📒 Files selected for processing (16)
  • docs/cli-reference.md
  • docs/getting-started.md
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • polylogue/api/archive.py
  • polylogue/cli/click_command_registration.py
  • polylogue/cli/command_inventory.py
  • polylogue/cli/commands/note.py
  • polylogue/mcp/server_mutation_tools.py
  • polylogue/storage/sqlite/archive_tiers/user_write.py
  • tests/infra/mcp.py
  • tests/unit/cli/test_note.py
  • tests/unit/cli/test_note_widget_docs.py
  • tests/unit/mcp/test_candidate_capture_tool.py
  • tests/unit/mcp/test_envelope_contracts.py
  • tests/unit/mcp/test_per_tool_contracts.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fanout/terminal-note

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 01f1097ae2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/cli/commands/note.py Resolved
Comment thread polylogue/api/archive.py Outdated
Comment on lines +1156 to +1160
else:
resolved_refs.append(parsed.format())

normalized_scope_refs = [parse_public_ref(ref).format() for ref in scope_refs]
target_ref = resolved_refs[0] if resolved_refs else f"assertion:{assertion_id}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Convert evidence refs before using them as targets

When the first --ref is a raw evidence ref such as codex-session:abc or codex-session:abc::msg, this branch appends parsed.format() to resolved_refs, and line 1160 then passes that value as target_ref to upsert_assertion. upsert_assertion normalizes target_ref with normalize_object_ref_text, so raw evidence refs fail at runtime even though --ref is documented as accepting evidence refs; project the first EvidenceRef to an object ref for the target while keeping it in evidence_refs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Resolved by tightening the Bead-defined contract in e1af2db: --ref accepts only session refs or last, so raw evidence refs cannot become assertion targets.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial self-review — iteration 1

Findings fixed in e1af2db5a:

  • Real gap: note_command was not registered at the root CLI and direct-command tests were vacuous. Registered it, added root help inventory, and moved behavioral tests through polylogue note.
  • Real gap: non-session refs could be accepted as anchors; raw evidence refs could not form valid assertion targets. The Bead defines --ref as session-or-last, so the implementation now rejects every other reference type.
  • Real gap: last only matched the exact cwd. It now locates the enclosing repository root before selecting the latest archived session; a nested-cwd regression test proves it.
  • Real gap: MCP parity and the optional zsh snippet were deferred without a durable reason. Added the write-role capture_assertion_candidate tool returning the same assertion payload and documented the opt-in zsh prefill.

What survived scrutiny: candidates still write through the production assertion gate as private/non-injected; NOTE/CORRECTION are visible to review but not active-context claim readers; claim remains the documented alias for the existing DECISION kind.

Verification: focused CLI/MCP contracts: 229 passed; devtools verify --quick: all 15 steps passed.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial self-review — iteration 2

Findings fixed in a32e57034:

  • Real gap: terminal NOTE candidates were included in ordinary blackboard reads before judgment. Blackboard listing now projects only active note assertions; a production-route test proves the candidate is visible in the review queue, absent from blackboard, then visible only after acceptance.
  • Real gap: the zsh snippet appended its precmd hook, so another hook could overwrite the previous command's exit status. It now installs first, after existing hook registration.
  • Real gap: the snippet manually double-quoted history, permitting shell syntax in historical commands to alter the prefilled input. It now uses zsh's ${(qq)...} quoting.
  • Real gap: MCP parity had only a mocked serialization check. The new test invokes the root CLI and registered MCP tool against one archive, compares semantic payload fields, and verifies both IDs enter the real pending queue.

What survived scrutiny: candidates remain private, non-injected, and candidate-statused; accepted candidates promote to active notes; strict session/last anchors, bounded stdin, root registration, and repository-root last behavior remain covered.

Verification: POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest devtools test tests/unit/cli/test_note.py tests/unit/cli/test_note_widget_docs.py tests/unit/mcp/test_candidate_capture_tool.py tests/unit/storage/test_blackboard_facade.py tests/unit/storage/test_archive_tiers_assertion_write_through.py — 36 passed. POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest devtools verify --quick — all 15 steps successful.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial self-review — iteration 3

Finding fixed in cc0fb9284:

  • Real gap: a syntactically valid but unknown --ref session:… let the storage resolver's KeyError escape the root CLI. Candidate capture now converts it into session ref not found: …; a root-command regression proves the nonzero error is actionable and has no traceback.

What survived scrutiny: a cold reviewer re-read every Bead criterion and note, the full branch diff, PR body/comments, root registration, candidate/judgment path, MCP registration/contracts, and zsh executable documentation test. It found no other substantive gap.

Verification: POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest devtools test tests/unit/cli/test_note.py tests/unit/mcp/test_candidate_capture_tool.py — 10 passed. The pre-push POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest devtools verify --quick baseline completed with all 15 steps successful.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial self-review — iteration 4

Finding fixed in 9f6a36d3d:

  • Real gap: MCP capture inherited the terminal CLI's user:local provenance, so agent-originated candidates were not auditable. MCP now requires an agent:<session> author reference, writes author_kind=agent, and the shared facade preserves terminal user:local attribution for the CLI.

What survived scrutiny: the real CLI/MCP parity test now asserts identical payload schema and candidate lifecycle while deliberately asserting their distinct source attribution; it reads the MCP assertion back from user.db to prove author, candidate status, and non-injected policy survived the full write route.

Verification: POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest devtools test tests/unit/mcp/test_candidate_capture_tool.py tests/unit/mcp/test_per_tool_contracts.py tests/unit/mcp/test_envelope_contracts.py tests/unit/cli/test_note.py — 231 passed. Pre-push POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest devtools verify --quick — all 15 steps successful.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial self-review — iteration 5 (zero findings)

A cold reviewer independently re-read polylogue-dmp (description, design, all six ACs, notes, and dependency context), fetched and reviewed the full origin/master...HEAD diff, and inspected the PR body, every top-level comment, and inline review thread.

It traced root CLI registration through the command, facade, user-tier assertion chokepoint, candidate queue/judgment/blackboard boundary; MCP registration, contracts, payload schema, and provenance; session/last resolution; stdin bounds; and the exact documented zsh widget under its executable hostile-history/status test. No new substantive finding remained. git diff --check origin/master...HEAD is clean.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Final acceptance-criteria matrix — polylogue-dmp

AC Status Evidence
1. Root terminal note creates exactly one candidate NOTE through user tier; no auto-judgment Satisfied Root-route CLI tests and production pending-candidate read prove candidate status, non-injected policy, and later explicit acceptance.
2. Session/last anchors, scope refs, and unanchored bare notes Satisfied Tests cover session anchors, nested-cwd repository-root last, repo/topic scopes, unanchored value flag, non-session rejection, and clean missing-session feedback.
3. Kind selection Satisfied Root CLI test covers note/claim/correction/lesson; claim maps to existing DECISION and every result is candidate-statused.
4. Bounded stdin Satisfied Root CLI test covers stdin capture and the actionable oversize rejection.
5. CLI/MCP candidate parity Satisfied Real CLI and registered MCP writes against one archive share payload schema, kind/status/value/evidence/scope semantics, and enter the same pending queue. Attribution deliberately differs: CLI is user:local; MCP requires and preserves agent:<session>/agent provenance in user.db, as required for auditability.
6. Optional zsh snippet Satisfied Documentation-only widget is covered by an executable zsh test proving previous-status preservation and inert quoting of hostile history text.

No criteria are deferred or misframed. Bead remains open as directed; PR is not merged.

Sinity and others added 5 commits July 13, 2026 02:18
Problem: terminal observations lacked a one-line capture path into the
existing judgment gate.

What changed: add the note command and a facade-owned candidate writer
with anchored, scoped, stdin, and bounded-input behavior. Extend the
candidate read model so captured notes and corrections reach review.

Compatibility/migration: no schema migration; candidates remain private
and non-injected until explicit judgment.

Ref polylogue-dmp.

Co-Authored-By: Codex <[email protected]>
Problem: the initial note implementation was unreachable from the root CLI,
accepted invalid non-session anchors, and omitted its MCP/documentation
parity paths.

What changed: register the command, constrain and resolve anchors at the
repository root, expose the shared writer over write-role MCP, and document
the optional zsh prefill widget.

Compatibility/migration: note remains candidate-only and non-injected;
claim continues to map to the existing decision assertion kind.

Ref polylogue-dmp.

Co-Authored-By: Codex <[email protected]>
Problem:
Terminal note candidates appeared in ordinary blackboard reads before an
operator judged them, while the documented zsh widget could lose the prior
command status or interpolate history as executable shell syntax.

What changed:
Restrict blackboard listing to active note assertions, harden the widget's
precmd ordering and zsh quoting, and add real CLI-to-MCP pending-queue parity
coverage.

Ref polylogue-dmp.

Co-Authored-By: Codex <[email protected]>
Problem:
A syntactically valid but unknown session ref reached the storage resolver and
leaked its KeyError through the root CLI.

What changed:
Translate missing session anchors at the capture facade and prove the real CLI
returns actionable feedback without a traceback.

Ref polylogue-dmp.

Co-Authored-By: Codex <[email protected]>
Problem:
The MCP candidate route inherited the terminal CLI's local-user attribution,
which erased the originating agent from durable assertion rows.

What changed:
Require an agent session reference for MCP candidate capture, preserve it with
agent authorship through the shared facade, and prove the real user tier keeps
that provenance while the CLI remains locally attributed.

Ref polylogue-dmp.

Co-Authored-By: Codex <[email protected]>
@Sinity
Sinity force-pushed the feature/fanout/terminal-note branch from 9f6a36d to f6b455c Compare July 13, 2026 00:19
@Sinity
Sinity merged commit 009658f into master Jul 13, 2026
3 of 15 checks passed
@Sinity
Sinity deleted the feature/fanout/terminal-note branch July 13, 2026 00:19
Sinity added a commit that referenced this pull request Jul 13, 2026
…807,2780,2790,2791,2795,2802,2806,2809

uwk3, jph5 (rigor-contracts #2783), bby.17 (web-cockpit #2793), dmp
(terminal-note #2801), ra3w (basetemp-fix #2807), r4no/bkff/r2kb
(extension-redesign #2780) fully satisfied — closed. nhjs (#2793), peo
(daemon-forensics #2802), 4g3n (#2780), 67ac/212.11 (demo-corpus #2795),
rsad (mcp-ergonomics #2790, real gaps remain per 5-iteration adversarial
cap), 9e5.8.4/jnj.7 (provider-origin #2806), mrxt/37t.12/p5g/rxdo.4
(annotation-judgment #2791), s7ae.8/20d.2 (live-performance-2 #2809)
partially satisfied — noted with disposition, left open.

Also discovered and documented the actual root cause of this session's
recurring bead-revert incidents: bd reimports the live database from
.beads/issues.jsonl on every CLI invocation, so a write not immediately
exported is lost the moment the next bd command runs. Every mutation in
this commit was individually export-verified against that behavior.

Co-Authored-By: Claude <[email protected]>
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 60.F026 / P1: fixed-already at the checked revision: polylogue/cli/click_command_registration.py:195 registers note in ROOT_COMMANDS, so the public root dispatcher resolves the note command rather than treating it as an unknown root.

Only the rows listed above are dispositioned. Held findings remain open.

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