Skip to content

feat(cli): aelf confirm — explicit user affirmation (#441) - #445

Merged
robotrocketscience merged 6 commits into
mainfrom
feat/issue-441-cli-confirm
May 5, 2026
Merged

feat(cli): aelf confirm — explicit user affirmation (#441)#445
robotrocketscience merged 6 commits into
mainfrom
feat/issue-441-cli-confirm

Conversation

@yoshi280

@yoshi280 yoshi280 commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #441.

Summary

Adds the CLI port of the shipped MCP aelf_confirm tool (#390). aelf confirm <belief-id> is an explicit user affirmation: it bumps the Beta-Bernoulli α by 1.0 with source="user_confirmed", distinguishable from the implicit feedback used signal in feedback_history queries.

5 atomic SSH-signed commits (all G):

9e49f95 docs(feature-aelf-confirm-cli): spec memo for #441
ceb00d1 feat(cli): add aelf confirm subcommand (#441)
dd2e0e8 test(cli): unit + integration tests for aelf confirm (#441)
f2703bb feat(slash_commands): add /aelf:confirm (#441)
332303c docs(COMMANDS): add aelf confirm to command reference (#441)

Reconciliation note (issue body acceptance #2)

#441's body says confirm "Writes a row to the belief_corroborations table (#190)." That's stale — the shipped MCP tool_confirm writes to feedback_history via apply_feedback, not to belief_corroborations. The belief_corroborations table tracks duplicate re-ingests (a structural dedup concern); confirm is an explicit user signal. The CLI follows the MCP. The spec memo (docs/feature-aelf-confirm-cli.md § "Reconciliation with issue #441 body") makes this explicit.

Verification

  • uv run pytest tests/test_cli_confirm.py — 9 passed
  • uv run pytest tests/test_cli.py tests/test_mcp_server.py tests/test_lock_management.py tests/test_corroborations.py — 137 passed
  • uv run aelf confirm --help — visible subcommand
  • All 5 commits SSH-signed (G)
  • Discretion grep clean

Files

  • docs/feature-aelf-confirm-cli.md (new, +113)
  • docs/COMMANDS.md (count bump 28→29 + row)
  • src/aelfrice/cli.py (+56: _cmd_confirm + argparse subparser + top-of-file help line)
  • src/aelfrice/slash_commands/confirm.md (new, +21)
  • tests/test_cli_confirm.py (new, +196: 9 tests covering happy path / unknown belief / --note / --source / posterior mean / non-write to belief_corroborations)

Summary by Sourcery

Add an explicit CLI and slash-command entry point for affirming beliefs via the existing confirmation feedback path.

New Features:

  • Introduce aelf confirm CLI subcommand to explicitly affirm a belief and update its Beta-Bernoulli posterior via feedback_history.
  • Add /aelf:confirm slash command that routes to the CLI confirmation behavior.

Enhancements:

  • Document the semantics and contract of the new aelf confirm CLI in a dedicated feature spec and update the commands reference.
  • Add focused unit and integration tests covering CLI confirmation behavior, feedback_history writes, and absence of belief_corroborations writes.

Documentation:

  • Add feature spec for the aelf confirm CLI behavior and its relationship to existing feedback and lock operations.
  • Update command reference to include the new confirm subcommand and its semantics.

Tests:

  • Add unit and integration tests for aelf confirm covering happy path, custom source and note handling, unknown beliefs, and storage behavior.
  • Update slash command tests to cover the new /aelf:confirm entry.

@sourcery-ai

sourcery-ai Bot commented May 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implements a new aelf confirm CLI subcommand (and matching slash command) that forwards to the existing MCP tool_confirm, emitting explicit user-affirmation feedback to feedback_history, along with docs and tests that clarify behavior and ensure it does not touch belief_corroborations.

Sequence diagram for the new aelf confirm CLI flow

sequenceDiagram
  actor User
  participant CLI as aelf_cli
  participant Store as belief_store
  participant MCP as mcp_server_tool_confirm
  participant DB as database

  User->>CLI: run aelf confirm belief_id [--source] [--note]
  CLI->>Store: _open_store()
  CLI->>MCP: tool_confirm(store, belief_id, source, note)
  MCP->>DB: apply_feedback(write row to feedback_history)
  DB-->>MCP: write_result
  MCP-->>CLI: result(prior_alpha, new_alpha, new_beta, note, kind)
  CLI->>Store: close()
  alt unknown_belief
    CLI->>User: stderr confirm error: unknown belief
    CLI-->User: exit code 1
  else success
    CLI->>User: stdout confirmed belief_id: alpha prior_alpha->new_alpha, mean posterior_mean
    CLI-->User: exit code 0
  end
Loading

Entity relationship diagram for feedback_history and belief_corroborations

erDiagram
  beliefs {
    int id
    string statement
  }

  feedback_history {
    int id
    int belief_id
    float valence
    string source
    string created_at
  }

  belief_corroborations {
    int id
    int belief_id
    string ingest_source
    string content_hash
    string created_at
  }

  beliefs ||--o{ feedback_history : has_feedback
  beliefs ||--o{ belief_corroborations : has_corroborations

  feedback_history ||..|| belief_corroborations : distinct_purposes
Loading

File-Level Changes

Change Details Files
Add aelf confirm CLI subcommand wired to MCP tool_confirm for explicit belief affirmation.
  • Introduce _cmd_confirm handler that opens a store, calls tool_confirm, handles unknown-belief errors, and prints alpha transition plus posterior mean.
  • Extend argparse parser with confirm subcommand, belief_id positional, --source (default user_confirmed), and --note (non-persisted annotation).
  • Update top-of-file CLI usage banner to advertise confirm with brief description.
src/aelfrice/cli.py
Document the new confirm command and its semantics relative to feedback, lock, and storage. docs/feature-aelf-confirm-cli.md
docs/COMMANDS.md
Add /aelf:confirm slash command that shells out to the new CLI subcommand.
  • Create slash command definition with objective, process, and guidance distinguishing it from aelf:lock.
  • Register confirm among available slash commands for tests.
src/aelfrice/slash_commands/confirm.md
tests/test_slash_commands.py
Introduce focused unit and integration tests for aelf confirm covering behavior, flags, and storage writes.
  • Add isolated-db fixture and helpers to seed beliefs via MemoryStore for CLI tests.
  • Cover happy-path output, alpha bump, posterior mean display, and exit code semantics for unknown beliefs.
  • Test --note printing without persistence, --source override propagation to feedback_history, and end-to-end feedback-history writes and absence of belief_corroborations writes.
tests/test_cli_confirm.py

Assessment against linked issues

Issue Objective Addressed Explanation
#441 Add an aelf confirm CLI subcommand that explicitly affirms an existing belief by bumping the Beta-Bernoulli posterior (α += 1.0) without locking it, handling unknown-belief errors appropriately.
#441 Record confirm events in the persistence layer in a way that matches the shipped MCP tool_confirm semantics and is clearly distinguished from both implicit feedback used events and lock/freezing behaviour.
#441 Provide user-facing documentation and a spec memo for aelf confirm (including how it differs from apply_feedback helped/implicit feedback and from lock), add an optional --note flag to capture the reason for confirmation, and cover the feature with unit/integration tests.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@robotrocketscience has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 24 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 570ddbb4-3d61-4264-8863-45f598045b0f

📥 Commits

Reviewing files that changed from the base of the PR and between 3be58be and cbcce36.

📒 Files selected for processing (6)
  • docs/COMMANDS.md
  • docs/feature-aelf-confirm-cli.md
  • src/aelfrice/cli.py
  • src/aelfrice/slash_commands/confirm.md
  • tests/test_cli_confirm.py
  • tests/test_slash_commands.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/issue-441-cli-confirm

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 and usage tips.

@yoshi280 yoshi280 added the attn:review Needs review (PR open, awaiting reviewer) label May 5, 2026

@sourcery-ai sourcery-ai 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.

Hey - I've left some high level feedback:

  • The CLI output currently only prints the new posterior mean (mean {posterior_mean:.3f}), but the feature spec shows a prior→new mean transition (e.g., mean 0.500->0.667); consider either updating the implementation to emit both values or aligning the docs/spec to the current behavior.
  • The integration test test_confirm_does_not_write_belief_corroborations reaches into MemoryStore._conn and runs raw SQL; if possible, it would be more robust to expose a small public helper on MemoryStore for this inspection rather than depending on a private attribute.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The CLI output currently only prints the new posterior mean (`mean {posterior_mean:.3f}`), but the feature spec shows a prior→new mean transition (e.g., `mean 0.500->0.667`); consider either updating the implementation to emit both values or aligning the docs/spec to the current behavior.
- The integration test `test_confirm_does_not_write_belief_corroborations` reaches into `MemoryStore._conn` and runs raw SQL; if possible, it would be more robust to expose a small public helper on `MemoryStore` for this inspection rather than depending on a private attribute.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-actions github-actions Bot added the attn:merge-conflict PR branch needs rebase label May 5, 2026
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

This PR is now behind main. Rebase locally so your commit signatures stay intact:

git fetch origin && git checkout 'feat/issue-441-cli-confirm' && git rebase origin/main
# resolve conflicts if any, then
git push --force-with-lease

Auto-rebase was removed because the bot has no signing key; rebasing as the bot strips author signatures and the required_signatures rule on main then blocks the merge. See #341.

@yoshi280

yoshi280 commented May 5, 2026

Copy link
Copy Markdown
Collaborator Author

[claim:review:Toug:2026-05-05T17:33:09Z]

@robotrocketscience
robotrocketscience force-pushed the feat/issue-441-cli-confirm branch from 6cba6bc to cbcce36 Compare May 5, 2026 17:35
@robotrocketscience
robotrocketscience merged commit cbcce36 into main May 5, 2026
20 checks passed
@robotrocketscience
robotrocketscience deleted the feat/issue-441-cli-confirm branch May 5, 2026 17:37
@yoshi280 yoshi280 removed attn:review Needs review (PR open, awaiting reviewer) attn:merge-conflict PR branch needs rebase labels May 5, 2026
@yoshi280

yoshi280 commented May 5, 2026

Copy link
Copy Markdown
Collaborator Author

[release:review:Toug:2026-05-05T17:37:36Z]

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.

[v2.0] aelf confirm CLI — explicit corroboration of an existing belief

2 participants