Skip to content

fix(sync,jobs): honor page caps, cache restoration, and account selectors in live sync and jobs - #257

Closed
saariuslystoned wants to merge 3 commits into
steipete:mainfrom
saariuslystoned:fix/jobs-and-live-sync-pagination-contracts
Closed

saariuslystoned wants to merge 3 commits into
steipete:mainfrom
saariuslystoned:fix/jobs-and-live-sync-pagination-contracts

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Preserve explicit --max-pages when --all is passed to jobs sync-bookmarks (instead of overwriting maxPages with undefined).
  • Normalize account selectors (@handle, handle, acct_*) in jobs sync-account before checking whether an account is the default account for bird-backed steps, while keeping the non-default account refusal boundary intact unless --allow-bird-account is passed.
  • Allow --limit 1..4 in sync authored when using bird transport (moving the 5..100 Xurl page-size preflight inside fetchViaXurl for sync authored).
  • Restore missing local SQLite rows, collection memberships (tweet_collections), and mention account edges (tweet_account_edges) on fresh collection-cache hits (sync likes / sync bookmarks via persistCached in runCachedLiveSyncEffect) and on fresh and offline-fallback mention cache hits (mentions export in src/lib/mentions-live.ts), while:
    1. Preserving newer stored tweet metrics (preserveExisting: true in upsertLiveTweetPayload),
    2. Checking options.preserveExisting in upsertLiveUser before calling reconcileCanonicalXProfileIdentity (and passing canReassignHandleCollision: () => false when options.preserveExisting is true so an older cached handle never displaces another profile currently owning that @handle or renames it to birdclaw_stale_*), and
    3. Skipping cache-restoration writes when isReadOnlyDeployment() (BIRDCLAW_DEPLOYMENT_READ_ONLY=1) is true so read-only cached archives remain readable without scheduling database writes.

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

1. Bookmark Job --all --max-pages 2 Cap & Bird Authored --limit 1 (Base vs Head)

=== 2. BOOKMARK JOB --all --max-pages 2 CAP & BIRD LIMIT 1 (BASE vs HEAD) ===
--- Base: jobs sync-bookmarks --all --max-pages 2 --mode xurl --refresh ---
{
  "ok": true,
  "maxPages": null,
  "pagesFetched": 4,
  "count": 4
}
--- Head: jobs sync-bookmarks --all --max-pages 2 --mode xurl --refresh ---
{
  "ok": true,
  "maxPages": 2,
  "pagesFetched": 2,
  "count": 2
}
--- Base: sync authored --mode bird --limit 1 ---
{"error":"--limit must be between 5 and 100"}
--- Head: sync authored --mode bird --limit 1 ---
{
  "ok": true,
  "source": "bird",
  "count": 1
}

2. jobs sync-account Default Account Alias (@steipete) vs Non-Default (@birdclaw_lab) Refusal Boundary

=== 3. JOB DISPATCH ACCOUNT ALIAS (@steipete) vs NON-DEFAULT ACCOUNT (@birdclaw_lab) REFUSAL ===
--- Base: jobs sync-account --account @steipete --steps likes --mode bird --refresh ---
{
  "ok": false,
  "account": null,
  "steps": [
    {
      "name": null,
      "ok": false,
      "error": "Bird-backed likes sync requires --allow-bird-account for non-default accounts; source matching cookies with --env-path first."
    }
  ]
}
--- Head (Default account alias @steipete): jobs sync-account --account @steipete --steps likes --mode bird --refresh ---
{
  "ok": true,
  "account": null,
  "steps": [
    {
      "name": null,
      "ok": true,
      "source": "bird"
    }
  ]
}
--- Head (Non-default account @birdclaw_lab without --allow-bird-account): preserves refusal boundary ---
{
  "ok": false,
  "account": null,
  "steps": [
    {
      "name": null,
      "ok": false,
      "error": "Bird-backed likes sync requires --allow-bird-account for non-default accounts; source matching cookies with --env-path first."
    }
  ]
}

3. Fresh Collection Cache & Fresh/Offline Mentions Cache Restoration + Handle-Ownership Preservation + Read-Only Cache Access (BIRDCLAW_DEPLOYMENT_READ_ONLY=1)

=== 4. COLLECTIONS & MENTIONS CACHE RESTORATION (FRESH & OFFLINE FALLBACK) + HANDLE-OWNERSHIP PRESERVATION ===
--- 4a. Likes cache replay after user 42 (@sam -> @alice) and user 43 (@sam) handle handoff ---
Base cache replay (fails to restore tweet_collections row 900):
{
  "source": "cache",
  "count": 1
}
0
Head cache replay (restores tweet_collections row 900 while preserving like_count=10, user 42 as @alice, and user 43 as @sam):
{
  "source": "cache",
  "count": 1
}
acct_primary|900|likes
900|10
profile_user_42|alice|New Sam|250
profile_user_43|sam|Current Sam|500
--- 4b. Mentions fresh cache restoration & offline-fallback restoration after handle handoff ---
Base mentions export fresh cache hit (fails to restore mention edge 910):
{
  "count": 0
}
0
Head mentions export fresh cache hit (restores mention edge 910 while preserving like_count=20, user 42 as @alice, and user 43 as @sam):
{
  "count": 1
}
acct_primary|910|mention
910|20
profile_user_42|alice|New Sam|250
profile_user_43|sam|Current Sam|500
Head mentions export offline-fallback cache hit (--cache-ttl 0 with xurl failing):
{
  "count": 1
}
acct_primary|910|mention
profile_user_42|alice|New Sam
profile_user_43|sam|Current Sam
Head read-only cached exports (BIRDCLAW_DEPLOYMENT_READ_ONLY=1):
{
  "count": 1
}
{
  "count": 1
}
{
  "source": "cache",
  "count": 1
}

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

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

Verification

  • ./node_modules/.bin/oxfmt --check src/cli/register-jobs.ts src/lib/job-dispatch.ts src/lib/live-sync-engine.ts src/lib/mentions-live.ts src/lib/timeline-collections-live.ts src/lib/tweet-repository.ts src/lib/x-profile.ts src/lib/mentions-live.test.ts src/lib/timeline-collections-live.test.ts
  • ./node_modules/.bin/oxlint --deny-warnings src/cli/register-jobs.ts src/lib/job-dispatch.ts src/lib/live-sync-engine.ts src/lib/mentions-live.ts src/lib/timeline-collections-live.ts src/lib/tweet-repository.ts src/lib/x-profile.ts src/lib/mentions-live.test.ts src/lib/timeline-collections-live.test.ts
  • ./node_modules/.bin/tsc --noEmit
  • node ./scripts/run-vitest.mjs run src/lib/mentions-live.test.ts src/lib/timeline-collections-live.test.ts (115/115 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. 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 repairs pagination caps, account selector handling, Bird authored limits, and restoration of cached collections and mentions.

Example: Run jobs sync-bookmarks --all --max-pages 2 against four available pages.

  • Before: The explicit cap is lost and four pages are fetched.
  • After: The job preserves the cap and fetches two pages.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused repairs with supplied shipped-CLI evidence, existing-archive validation, and no remaining actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The supplied dist/cli/birdclaw.js traces exercise capped bookmark jobs, Bird authored limit 1, default-alias success and non-default refusal, fresh collection replay, fresh/offline mention replay, handle ownership preservation, and read-only cached access at the reviewed head; the downloaded Discuss screenshots belong to earlier transport work and add no proof for this change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Explicit sync bounds and default-account aliases behave inconsistently, while cached results can leave local collection or mention views missing data.
Reason: These are concrete failures of existing sync behavior, repaired without adding configuration or changing the account permission contract.

Merge readiness

✅ Ready for maintainer review

This PR fixes concrete sync defects still present on main; the earlier findings are resolved, and no actionable blocker remains.

Priority: P2
Reviewed head: 12b6487f205adfe70fd094793fc46ebb2ab9daf4

Before merge

None.

Findings

None.

Agent review details

How this fits together

CLI commands and scheduled jobs select an account and transport, fetch or reuse cached tweet payloads, and update SQLite tweets, profiles, memberships, edges, and search indexes.

flowchart TD
  A[CLI or scheduled job] --> B[Account and pagination policy]
  B --> C[Bird or Xurl transport]
  B --> D[Response cache]
  C --> E[Shared tweet ingestion]
  D --> E
  E --> F[SQLite and search indexes]
  F --> G[Sync result or mention export]
Loading

Technical review

Best possible solution:

Land the focused repairs using the existing account resolver, pagination engine, and shared persistence owners.

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

Main's source exposes the lost cap, alias comparison, transport-independent authored minimum, and missing cache persistence paths; the contributor's shipped-CLI traces show corresponding before/after failures and repairs.

Is this the best way to solve the issue?

The implementation fixes the existing owners, preserves live transport behavior and account guards, and restores cached data without replacing newer canonical rows.

AGENTS.md: not found in the target repository.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 17ef75f adds src/lib/live-sync-engine.ts:100 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 17ef75f11928; files: src/lib/live-sync-engine.ts)
  • Travis Fischer: Raw commit b22ced0 adds src/lib/authored-live.ts:499 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b22ced0110ce; files: src/lib/authored-live.ts)
  • Cavit Erginsoy: Raw commit 21faa1d adds src/lib/authored-live.ts:688 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 21faa1d17ec1; files: src/lib/authored-live.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
Production and test changes Production +164/-47 lines; tests +1155/-33 lines The production changes reuse existing owners; the larger test delta covers transport, pagination, cache freshness, filtering, identity, and persistence boundaries.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The repairs address bounded sync and cached-data consistency defects with limited blast radius and no demonstrated urgent outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • 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 (4 earlier review cycles)
  • reviewed 2026-11-08T21:07:50.658Z sha d9ca4f8 :: needs real behavior proof before merge. :: [P2] Preserve newer canonical data when restoring cached payloads
  • reviewed 2026-11-09T00:33:37.268Z sha ea4c995 :: needs real behavior proof before merge. :: [P2] Preserve cached profiles before reconciling handle ownership
  • reviewed 2026-11-09T01:16:17.580Z sha b207ab1 :: needs changes before merge. :: [P2] Preserve cached mention exports in read-only deployments | [P3] Restrict collection claims to the implemented behavior
  • reviewed 2026-11-09T01:40:59.096Z sha 12b6487 :: needs changes before merge. :: [P3] Describe only the implemented selector and cache behavior

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

@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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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

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. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. proof: sufficient Contributor real behavior proof is sufficient. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 9, 2026
@saariuslystoned
saariuslystoned force-pushed the fix/jobs-and-live-sync-pagination-contracts branch from b207ab1 to 12b6487 Compare November 9, 2026 01:35
@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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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
@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 status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 page caps, account aliases, Bird authored limits, and safe mention/collection cache restoration 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.

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