Skip to content

fix(research): scope thread ancestor and descendant collection flags to selected account - #260

Closed
saariuslystoned wants to merge 3 commits into
steipete:mainfrom
saariuslystoned:fix/research-account-scope-and-analysis-cli-validation
Closed

saariuslystoned wants to merge 3 commits into
steipete:mainfrom
saariuslystoned:fix/research-account-scope-and-analysis-cli-validation

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Resolve --account selectors (acct_*, @handle, handle) via findOperationAccount in runResearchModeEffect (src/lib/research.ts) and pass accountId into resolveSeedTimelineItems, collectAncestorChainEffect -> getTweetRowById, and getTweetDescendants.
  • Scope the bookmarked and liked EXISTS subqueries on tweet_collections to collection.account_id = ? whenever an account is selected (options.account && options.account !== "all"), preventing another account's bookmarks or likes from leaking onto thread ancestors and descendants while preserving limit and maxThreadDepth normalization from v0.17.0.

Real Behavior Proof (dist/cli/birdclaw.js — Base v0.17.0 @ 9895445ba0a2 vs Head @ 97ba78b4d1d4)

1. Multi-Account Thread Ancestor & Descendant Collection-Flag Scoping (research --account @steipete vs --account @birdclaw_lab)

=== 2. BASE (9895445ba0a2): research --account @steipete leaks acct_studio bookmark/like flags onto ancestor & descendant ===
{
  "seedTweetId": "tweet_r_focus",
  "threadRootId": "tweet_r_root",
  "thread": [
    {
      "id": "tweet_r_root",
      "threadDepth": 0,
      "bookmarked": true,
      "liked": false
    },
    {
      "id": "tweet_r_focus",
      "threadDepth": 1,
      "bookmarked": true,
      "liked": false
    },
    {
      "id": "tweet_r_child",
      "threadDepth": 2,
      "bookmarked": false,
      "liked": true
    }
  ]
}
=== 3. HEAD: research --account @steipete scopes ancestor & descendant flags to acct_primary (false) ===
{
  "seedTweetId": "tweet_r_focus",
  "threadRootId": "tweet_r_root",
  "thread": [
    {
      "id": "tweet_r_root",
      "threadDepth": 0,
      "bookmarked": false,
      "liked": false
    },
    {
      "id": "tweet_r_focus",
      "threadDepth": 1,
      "bookmarked": true,
      "liked": false
    },
    {
      "id": "tweet_r_child",
      "threadDepth": 2,
      "bookmarked": false,
      "liked": false
    }
  ]
}
=== 4. HEAD: research --account @birdclaw_lab returns acct_studio bookmark/like flags (true) ===
{
  "seedTweetId": "tweet_r_focus",
  "threadRootId": "tweet_r_root",
  "thread": [
    {
      "id": "tweet_r_root",
      "threadDepth": 0,
      "bookmarked": true,
      "liked": false
    },
    {
      "id": "tweet_r_focus",
      "threadDepth": 1,
      "bookmarked": true,
      "liked": false
    },
    {
      "id": "tweet_r_child",
      "threadDepth": 2,
      "bookmarked": false,
      "liked": true
    }
  ]
}

2. v0.17.0 Archive Upgrade & backup export / backup validate Compatibility

{
  "ok": true,
  "repoPath": "/private/tmp/bc-export-260",
  "counts": {
    "accounts": 2,
    "collections_bookmarks": 5,
    "collections_likes": 4,
    "dm_messages": 8,
    "dm_conversations": 4,
    "link_occurrences": 3,
    "url_expansions": 3,
    "profile_snapshots": 4,
    "profiles": 7,
    "timeline_edges_home": 4,
    "timeline_edges_mention": 2,
    "tweet_revisions": 2,
    "tweets": 9
  },
  "backupHash": "e2755f97e6e4d23c27cc34cb53fb52f2950e6312d425d9a15a8f08703940533c",
  "errors": []
}

Verification

  • ./node_modules/.bin/oxfmt --check src/lib/research.ts src/lib/research.test.ts
  • ./node_modules/.bin/oxlint --deny-warnings src/lib/research.ts src/lib/research.test.ts
  • ./node_modules/.bin/tsc --noEmit
  • node ./scripts/run-vitest.mjs run src/lib/research.test.ts (13/13 passed)

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.

☁️

@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. 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: needs maintainer review before merge.

What this changes

This PR scopes research thread bookmark and like flags to the selected account using the existing account resolver.

Example: Run research --account @steipete when only acct_studio bookmarked tweet_r_root and liked tweet_r_child.

  • Before: The root reports bookmarked=true and the child reports liked=true.
  • After: Both flags are false for @steipete and remain true for @birdclaw_lab.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused correction with shipped-CLI output and meaningful regression coverage; no remaining findings or owner-direction questions.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The contributor's terminal transcript exercises research through dist/cli/birdclaw.js against two stored accounts, showing unrelated ancestor bookmarks and descendant likes disappear for the selected account while remaining visible for their owning account.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Research reports attribute another stored account's bookmarks and likes to the selected account.
Reason: Selected-account collection flags should match the existing account-selection contract; the patch now excludes unrelated validation changes and adds no option or default.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current account-scoping bug with a focused patch and no actionable findings; the earlier numeric-validation concern is resolved.

Priority: P2
Reviewed head: 97ba78b4d1d44ef5fa61c389720407679b9b782a

Before merge

None.

Findings

None.

Agent review details

How this fits together

The research CLI selects bookmarked tweets from SQLite, expands their ancestors and descendants, and returns JSON or a markdown brief.

flowchart TD
  A[Research CLI] --> B[Account selector resolution]
  B --> C[Bookmark seed query]
  C --> D[Ancestor and descendant queries]
  E[SQLite collection records] --> D
  D --> F[JSON or markdown report]
Loading

Technical review

Best possible solution:

Land the focused account-scoping correction while retaining existing defaults, thread expansion, and numeric normalization.

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

Current-main SQL aggregates collection flags across accounts, directly establishing the failure path; the contributor also supplies contrasting CLI output, but this review did not execute target code.

Is this the best way to solve the issue?

The patch fixes the two research-owned queries at their source, reuses the existing account resolver, and preserves unselected behavior without adding machinery.

AGENTS.md: not found in the target repository.

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

Provenance checked

  • Research collection-state queries changes intended behavior with a stated reason (0ff0317: The data-runtime consolidation replaced tweet-level flags with EXISTS queries over collection records; no recorded requirement makes selected-account flags aggregate other accounts.)
  • Account-selector resolution keeps the original intent (feat: add per-operation account selection #105: Per-operation selection supports usernames and stored account IDs without changing persisted identity or defaults.)
  • Effect execution and numeric normalization keeps the original intent (refactor: migrate core IO to Effect #35: The Effect migration preserved Promise-compatible wrappers and existing runtime behavior; this PR retains those boundaries and normalization.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Focused introduced patch: The pinned diff changes account resolution and four collection-state predicates, with matching SQL parameter ordering; released numeric normalization is unchanged. (src/lib/research.ts:578, 97ba78b4d1d4)
  • Current-main defect and provenance: Current main tests collection membership without account predicates in both thread queries. Commit 0ff0317 introduced these EXISTS expressions while consolidating data runtimes. (src/lib/research.ts:209, 9895445ba0a2)
  • Existing account-selection contract: feat: add per-operation account selection #105 established username and stored-ID selection. The CLI preAction hook already resolves handles before invoking research, supporting the transcript's baseline invocation. (src/cli/command-context.ts:79, 97ba78b4d1d4)
  • Contributor CLI proof: The complete current body identifies dist/cli/birdclaw.js, base v0.17.0, and the reviewed head, and supplies contrasting JSON for two selected accounts plus successful archive backup validation; the supplied sourceRevision is 10b970a346f9506f898073c869a4164929c979c5c3bfec66ab02a4b5cf2b366c. (97ba78b4d1d4)
  • Regression coverage: Added tests exercise ancestor and descendant flags through runResearchMode with stored IDs, handle variants, omitted selection, all-account selection, and an unknown selector. (src/lib/research.test.ts:169, 97ba78b4d1d4)
  • Policy and history limits: No AGENTS.md, maintainer notes, or pr-simplify skill exists in this checkout. Some historical blobs and the earlier reviewed head are unavailable locally; current source, readable historical diffs, GitHub records, and the pinned introduced diff settle this review. (97ba78b4d1d4)

Likely related people:

  • Anupam Chugh: Raw commit e2c48f1 adds src/lib/research.ts:198 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e2c48f1f846d; files: src/lib/research.ts)

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
Patch size Production +29/-6 lines; tests +53/-0 lines The change stays within the existing research owner and adds focused multi-account regression coverage.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: Incorrect bookmark and like flags affect multi-account research reports, with limited scope and no demonstrated data mutation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (3 earlier review cycles)
  • reviewed 2026-11-08T21:08:09.612Z sha 552f833 :: needs real behavior proof before merge. :: [P2] Preserve supported Number-compatible numeric arguments
  • reviewed 2026-11-09T00:21:23.025Z sha 7b32571 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-09T01:05:30.776Z sha dda6381 :: needs real behavior proof before merge. :: none

Reviewed November 8, 2026, 8:43 PM ET / November 9, 2026, 01:43 UTC (Revision 4).

@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
saariuslystoned force-pushed the fix/research-account-scope-and-analysis-cli-validation branch from 7b32571 to dda6381 Compare November 9, 2026 00:57
@saariuslystoned saariuslystoned changed the title fix(research,cli): scope research collection flags by account and validate digest, mentions, and graph CLI options fix(research): scope thread ancestor and descendant collection flags to selected account 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. 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 9, 2026
@saariuslystoned
saariuslystoned force-pushed the fix/research-account-scope-and-analysis-cli-validation branch from dda6381 to 97ba78b Compare November 9, 2026 01:39
@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 status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 9, 2026
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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-scoped collection flags for research ancestors and descendants 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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants