Skip to content

fix(cli,moderation): resolve @handle/username selectors and honor default accounts across inbox, moderation, and compose - #259

Closed
saariuslystoned wants to merge 2 commits into
steipete:mainfrom
saariuslystoned:fix/inbox-moderation-compose-account-resolution
Closed

saariuslystoned wants to merge 2 commits into
steipete:mainfrom
saariuslystoned:fix/inbox-moderation-compose-account-resolution

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add --account <username> to birdclaw inbox (src/cli/register-inbox.ts) and pass options.account into both scoreInbox (--score) and listInboxItems, honoring the shared configureOperationAccountSelection explicit-over-config (accounts.default) rule while preserving an unscoped inbox when neither --account nor accounts.default is set.
  • Validate inbox --kind (mixed | mentions | dms) with CliInputError before reading or scoring.
  • Normalize account selectors (@handle, handle, acct_*) via resolveOperationAccount / findOperationAccount in src/lib/query-actions.ts (createPost, createTweetReply, createDmReply), src/lib/blocks.ts, and src/lib/moderation-state.ts, verifying transport identity against the resolved account before remote execution or SQLite writes while preserving acct_primary defaults when unselected.

Real Behavior Proof (dist/cli/birdclaw.js — Base v0.17.0 @ 9895445ba0a24134cc6e07c327502134e18a58ea vs Head @ 0923a80ff6891cfa900973fdb121f59e6f9be9b6)

1. Inbox --account Option, Configured-Default (config.json accounts.default) Scoping, Account-Scoped Scoring (--score), & --kind Validation (Base vs Head)

=== 2. INBOX ACCOUNT ALIAS, CONFIGURED-DEFAULT SCOPING, ACCOUNT-SCOPED SCORING (--score), & KIND VALIDATION ===
--- Base: inbox --account @birdclaw_lab --json ---
{"error":"error: unknown option '--account'"}
--- Head (Configured default @birdclaw_lab in config.json without --account): scopes inbox to acct_studio ---
{
  "count": 1,
  "accounts": [
    "acct_studio"
  ]
}
--- Head: inbox --account @birdclaw_lab --score --json ---
OpenAI-scored items: [{"entityKind":"mention","title":"Mention from Sam Altman"}]
{
  "items": [
    {
      "id": "mention:tweet_006",
      "entityId": "tweet_006",
      "entityKind": "mention",
      "accountId": "acct_studio",
      "accountHandle": "@birdclaw_lab",
      "title": "Mention from Sam Altman",
      "text": "Agents need retrieval surfaces with small, stable contracts. Big blobs are not a strategy.",
      "createdAt": "2026-03-08T10:43:00.000Z",
      "needsReply": true,
      "influenceScore": 156,
      "source": "openai",
      "score": 91,
      "summary": "Scoped studio score",
      "reasoning": "Targeted account inbox item"
    }
  ],
  "stats": {
    "total": 1,
    "openai": 1,
    "heuristic": 0
  }
}
Stored ai_scores rows in SQLite:
mention|tweet_006|91|Scoped studio score
--- Base vs Head: inbox --kind bogus --json ---
{
  "count": 4
}
{"error":"--kind must be mixed, mentions, or dms"}

2. Real Local Moderation Writes (blocks record & mutes record, No Fake Transport) on Upgraded v0.17.0 Archive With Preserved config.json ({"accounts":{"default":"@birdclaw_lab"}})

=== 3. REAL LOCAL MODERATION WRITES (NO FAKE TRANSPORT) ON PRESERVED v0.17.0 ARCHIVE ===
--- Head (Preserved config.json accounts.default=@birdclaw_lab, no --account): blocks record & mutes record ---
{
  "ok": true,
  "action": "record-block",
  "accountId": "acct_studio",
  "blockedAt": "2026-11-09T01:50:03.625Z"
}
{
  "ok": true,
  "action": "record-mute",
  "accountId": "acct_studio",
  "mutedAt": "2026-11-09T01:50:06.472Z"
}
--- Head (Explicit --account @steipete overrides config.json accounts.default=@birdclaw_lab): blocks record & mutes record ---
{
  "ok": true,
  "action": "record-block",
  "accountId": "acct_primary",
  "blockedAt": "2026-11-09T01:50:10.484Z"
}
{
  "ok": true,
  "action": "record-mute",
  "accountId": "acct_primary",
  "mutedAt": "2026-11-09T01:50:16.774Z"
}
blocks|acct_primary|profile_user_77|manual
blocks|acct_studio|profile_user_77|manual
mutes|acct_primary|profile_user_77|manual
mutes|acct_studio|profile_user_77|manual

3. Remote Compose & Moderation Identity Verification via Real @xdevplatform/xurl v1.3.4 Binary (API_BASE_URL Local HTTP Endpoint)

=== REAL @xdevplatform/xurl v1.3.4 BINARY VERSION & AUTH STATUS ===
xurl version 1.3.4
▸ default  [client_id: demo-id…]
      redirect_uri: http://localhost:8080/callback  [built-in default]
    ▸ oauth2: birdclaw_lab
      oauth2: steipete
      oauth1: –
      bearer: –
=== MISMATCHED IDENTITY VIA REAL xurl v1.3.4 BINARY (whoami returns @steipete / 25401953 for --account @birdclaw_lab) ===
{"error":"xurl is authenticated as @steipete, not @birdclaw_lab"}
{
  "ok": false,
  "action": "block",
  "accountId": "acct_studio",
  "transport": {
    "ok": false,
    "output": "xurl is authenticated as user 25401953, not account acct_studio",
    "transport": "xurl"
  }
}
HTTP requests received from real xurl v1.3.4 during mismatch:
[
  {
    "method": "GET",
    "url": "/2/users/by/username/birdclaw_lab?user.fields=created_at,description,public_metrics,verified,verified_type,subscription_type,profile_image_url",
    "auth": "Bearer token-studio",
    "body": ""
  },
  {
    "method": "GET",
    "url": "/2/users/by/username/birdclaw_lab?user.fields=created_at,description,public_metrics,verified,verified_type,subscription_type,profile_image_url",
    "auth": "Bearer token-studio",
    "body": ""
  }
]
=== MATCHING IDENTITY VIA REAL xurl v1.3.4 BINARY (whoami returns @birdclaw_lab / 990042 for --account @birdclaw_lab) ===
{
  "ok": true,
  "transport": {
    "ok": true,
    "output": "{\n  \"data\":{\n    \"id\":\"post_990042_real\",\n    \"text\":\"Studio launch update\"\n  }\n}\n"
  },
  "tweetId": "tweet_e5a40c27-a3cd-4b83-944e-d5bb64a8bab5"
}
{
  "ok": true,
  "action": "block",
  "accountId": "acct_studio",
  "blockedAt": "2026-11-09T02:12:50.542Z",
  "transport": {
    "ok": true,
    "output": "{\n  \"data\":{\n    \"blocking\":true\n  }\n}\n\nverified blocking=true",
    "transport": "xurl"
  }
}
HTTP requests received from real xurl v1.3.4 during match:
[
  {
    "method": "GET",
    "url": "/2/users/by/username/birdclaw_lab?user.fields=created_at,description,public_metrics,verified,verified_type,subscription_type,profile_image_url",
    "auth": "Bearer token-studio",
    "body": ""
  },
  {
    "method": "POST",
    "url": "/2/tweets",
    "auth": "Bearer token-studio",
    "body": "{\"text\":\"Studio launch update\"}"
  },
  {
    "method": "GET",
    "url": "/2/users/by/username/birdclaw_lab?user.fields=created_at,description,public_metrics,verified,verified_type,subscription_type,profile_image_url",
    "auth": "Bearer token-studio",
    "body": ""
  },
  {
    "method": "POST",
    "url": "/2/users/990042/blocking",
    "auth": "Bearer token-studio",
    "body": "{\"target_user_id\":\"77\"}"
  }
]
SQLite rows written for acct_studio after real xurl v1.3.4 match:
acct_studio|profile_user_77
acct_studio|Studio launch update

4. v0.17.0 Archive Upgrade & backup export / backup validate Compatibility With Preserved config.json

{
  "accounts": {
    "default": "@birdclaw_lab"
  }
}
{
  "ok": true,
  "repoPath": "/private/tmp/bc-export-259",
  "counts": {
    "accounts": 2,
    "tweet_actions": 1,
    "ai_scores": 1,
    "collections_bookmarks": 2,
    "collections_likes": 3,
    "dm_messages": 8,
    "dm_conversations": 4,
    "link_occurrences": 3,
    "url_expansions": 3,
    "blocks": 2,
    "mutes": 2,
    "profiles": 7,
    "timeline_edges_home": 5,
    "timeline_edges_mention": 3,
    "tweets": 7
  },
  "backupHash": "79fa95a9910d7e6daee5727997145f4b6a97c61a110b3531f1925f9cde64de6e",
  "errors": []
}

5. Regression Suite Base-Fail (9895445ba0a2) vs Head-Pass (0923a80ff689) (src/cli/account-scope.test.ts + src/cli.test.ts)

  • Base (9895445ba0a24134cc6e07c327502134e18a58ea): node ./scripts/run-vitest.mjs run src/cli/account-scope.test.ts fails 86/87 tests (error: unknown option '--account' on inbox, Unknown account: @birdclaw_lab on blocks/mutes/compose, and unvalidated --kind bogus).
  • Head (0923a80ff6891cfa900973fdb121f59e6f9be9b6): node ./scripts/run-vitest.mjs run src/cli/account-scope.test.ts src/cli.test.ts passes 220/220 tests (87/87 in src/cli/account-scope.test.ts and 133/133 in src/cli.test.ts).

Known gaps

GitHub Actions CI has not run on this head. The workflow is waiting for a maintainer to approve it. The verification above is local: unit tests and the shipped CLI against a local archive, not a live X account.

☁️

…ault accounts across inbox, moderation, and compose
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codex review: ready, awaiting a maintainer decision.

What this changes

This PR normalizes compose and moderation account selectors, adds inbox account selection, and rejects invalid inbox kinds.

Example: Run birdclaw inbox with accounts.default set to @birdclaw_lab.

  • Before: The inbox includes items from multiple accounts.
  • After: Listing and scoring include only acct_studio items.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Shipped-entry-point and upgrade evidence resolve the earlier proof blocker; readiness remains capped by the inbox product decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Reviewed-head dist/cli/birdclaw.js output exercises inbox filtering and scoring, invalid-kind rejection, and local account-scoped writes; real xurl v1.3.4 against a local HTTP endpoint records allowed compose/moderation requests and rejects a mismatched identity before mutation.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Handle selectors fail or miss account-scoped records at library boundaries, and inbox cannot explicitly select an account.
Reason: Selector normalization restores the shared account contract, but adding inbox --account also changes how an existing accounts.default setting affects output and scoring.

Merge readiness

⏳ Ready, awaiting maintainer decision

This PR provides useful account-selector repairs with no definite introduced bug; owner direction remains necessary for making configured defaults narrow the formerly combined inbox.

Priority: P2
Reviewed head: 0923a80ff6891cfa900973fdb121f59e6f9be9b6
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should inbox gain --account and honor accounts.default, making an existing configured default narrow its previously combined output and scoring?
  • Recommendation: Approve inbox account selection: Accept the demonstrated explicit-over-config behavior while preserving combined output when neither selector is present.
  • Why: The existing shared selection contract supports this direction, but the new inbox flag changes established output for users with accounts.default and has no recorded owner approval on this PR.

Before merge

None.

Findings

None.

Agent review details

How this fits together

CLI commands resolve account selectors before inbox queries, transport identity checks, remote actions, and account-scoped SQLite writes.

flowchart TD
  A[CLI arguments and config] --> B[Shared account selection]
  B --> C[Inbox listing and scoring]
  B --> D[Compose and moderation]
  D --> E[Transport identity checks]
  E --> F[Xurl or Bird actions]
  F --> G[SQLite account state]
Loading

Technical review

Best possible solution:

Retain the shared selector repairs and obtain the account-selection owner's decision on configured-default inbox scoping.

Do we have a high-confidence way to reproduce the issue?

Current-main source shows raw account-ID handling at the affected library boundaries and no inbox --account option; supplied base/head CLI traces demonstrate the differences without this review executing target code.

Is this the best way to solve the issue?

Reusing the existing resolver is the smallest coherent repair, while extending configured-default selection to inbox is a separate owner-controlled behavior choice.

AGENTS.md: not found in the target repository.

Codex review notes: model internal, reasoning medium; reviewed against 9895445ba0a2.

Provenance checked

  • Shared selector normalization and account identity keeps the original intent (4dc0c90: The owner-authored account-selection change established explicit-over-config routing, preserved unselected defaults, and required identity verification before mutations.)
  • Reuse of the canonical account resolver keeps the original intent (15f831b: The account-seam consolidation centralized resolution across CLI, API, and library callers; GitHub commit patches verified the resolver contract after local historical blob reads failed.)
  • Inbox configured-default scoping and invalid-kind handling changes intended behavior with a stated reason (unknown: The registration split carried combined inbox behavior and mixed-kind fallback forward; current documentation enumerates the supported kinds, but unavailable historical blobs prevented establishing the original reason for the fallback.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced changes and preserved defaults: The pinned diff reuses the existing account resolver, carries resolved IDs through compose writes, preserves conversation ownership checks, and adds account filtering to both inbox listing and scoring. (src/cli/register-inbox.ts:16, 0923a80ff689)
  • Existing account-selection direction: The owner-authored feat: add per-operation account selection #105 established explicit-over-config selection and identity verification; refactor: remove duplicate query and account seams #128 centralized account resolution. Neither records approval of this PR's change from a combined inbox to configured-default scoping. (src/cli/command-context.ts:98, 4dc0c90f6390)
  • Updated shipped behavior and upgrade proof: The complete current body supplies reviewed-head CLI output for inbox filtering, scoring, invalid kinds, local moderation writes, preserved v0.17.0 settings, and backup validation. Real xurl v1.3.4 traces show matching-account POST requests and mismatch rejection without mutation requests, resolving the preceding review's transport-proof gap. Captured body sourceRevision: 2a5c30870e4ac41b4d0dee1c0d99774da7385d7c24599270bd5bef3f6fb7f1fd. (0923a80ff689)
  • Current validation state: The exact head has one successful GitGuardian check; no failing check was reported. The contributor supplies focused suite results, which this read-only review did not execute. (0923a80ff689)
  • Policy and history limits: No AGENTS.md, maintainer-notes directory, or pr-simplify skill exists in the checkout. Scoped history identifies the account-selection owner; some historical git show and blame operations encountered unavailable old blobs, so their introduction details were recovered through GitHub commit patches where needed. (0923a80ff689)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production and test changes Production +53/-19 lines; tests +547/-1 lines The production repair is focused; the larger test addition covers selector forms, command boundaries, stored account attribution, and rejection paths.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • remove status: 📣 needs proof: Current PR status label is status: ⏳ waiting on maintainer.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: Account-selector consistency and scoped inbox behavior are useful improvements with limited blast radius and no demonstrated urgent regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Have the account-selection owner decide whether inbox should honor accounts.default.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-11-08T21:07:24.895Z sha 1bba8b4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-09T01:00:00.018Z sha 0923a80 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-09T01:04:36.623Z sha 0923a80 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-09T01:58:42.648Z sha 0923a80 :: needs real behavior proof before merge. :: none

Reviewed November 8, 2026, 9:17 PM ET / November 9, 2026, 02:17 UTC (Revision 5).

@saariuslystoned
saariuslystoned force-pushed the fix/inbox-moderation-compose-account-resolution branch from f7f71bb to 0923a80 Compare November 9, 2026 00:50
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 9, 2026
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 9, 2026
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 9, 2026
steipete added a commit that referenced this pull request Nov 14, 2026
Consolidate verified fixes from #257, #258, #259, #260, #261, #262, #263, #264, and #265. Repair account selection, cache restoration, search bounds, input validation, and read-only analysis while preserving existing account and data-safety contracts. Also reject unsafe Git indexes before backup publication and keep recovery snapshots private.

Co-authored-by: Bobby Bones <saariuscrypto@gmail.com>
Co-authored-by: sm0ky <smokyproductcompany@gmail.com>
@steipete

Copy link
Copy Markdown
Owner

Thanks for the fixes. I reproduced the reported defects against v0.17.0 and consolidated account selection in Inbox, composition, and moderation into #266, now landed. The overlapping cache ingestion changes from #257 and #261 are included once.

The consolidation preserves contributor credit in the changelog and squash commit. Synthetic regressions, independent P0–P2 review, and exact-head CI cover the result; no paid X requests were used. Closing this PR as superseded by the landed consolidation.

@steipete steipete closed this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants