Repository navigation
fix(analysis): validate CLI options before sync and honor read-only digest/profile contracts - #265
Conversation
…gest/profile contracts
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR validates analysis inputs before automatic updates, honors digest limits and account aliases, and serves cached analysis safely in read-only deployments. Example: Run birdclaw --json profile-analyze '@bad!handle' with stale automatic backup sync enabled.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes current analysis-command defects and resolves both previous findings; no remaining merge blockers were identified. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherAnalysis commands consume CLI options and account-scoped SQLite data, optionally fetch live context, and return cached or generated reports. flowchart TD
CLI[Analysis commands] --> Validation[Input validation]
Validation --> Backup[Automatic backup update]
Backup --> Domain[Digest and profile analysis]
Domain --> Archive[Account scoped archive]
Domain --> Guard[Read only guard]
Guard --> Generation[Live fetching and generation]
Archive --> Output[Cached report output]
Generation --> Output
Technical reviewBest possible solution: Land the focused repairs in the existing analysis owners while preserving pacing fallback and account-scoped cached reads. Do we have a high-confidence way to reproduce the issue? Current-main source exposes validation after automatic updates, enlarged digest caps, and unguarded read-only generation; supplied base/head CLI output corroborates those paths, and no target code was executed during this review. Is this the best way to solve the issue? The patch repairs the existing CLI and domain boundaries, preserves the shared report lifecycle and environment fallback, and completes the previously missing handle-validation and citation-hydration paths. AGENTS.md: not found in the target repository. Codex review notes: model internal, reasoning medium; reviewed against 9895445ba0a2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Preflight sourceSource 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
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 9, 2026, 2:48 AM ET / 07:48 UTC (Revision 2). |
…lias citations, and preserve pacing env fallback
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
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>
|
Thanks for the fixes. I reproduced the reported defects against v0.17.0 and consolidated analysis validation before automatic updates, canonical digest account scoping, and read-only cached report behavior 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. |
Summary
Fixes CLI input validation ordering, digest period/date/count/account-selector contracts, and read-only deployment isolation across
src/cli/register-analysis.ts,src/lib/period-digest.ts, andsrc/lib/profile-analysis.ts(touching zero files overlapped by #257–#264):autoUpdateBeforeRead(src/cli/register-analysis.ts):autoUpdateBeforeRead()intoday,digest,discuss,profile-analyze, andresearch, preventing invalid arguments from triggering automatic sync/backup mutations.normalizeProfileHandleinsidebuildProfileAnalysisOptionsso invalid handles (e.g.@bad!handle, blank,>15chars) fail withCliInputErrorbefore writableautoUpdateBeforeRead/maybeAutoUpdateBackupruns.digest [period]presets (period must be today, 24h, day, yesterday, week, or 7d) instead of silently coercing arbitrary strings to"today".digest --since/--untilwith Zod ISO date/datetime schemas (z.iso.date()/z.iso.datetime({ offset: true, local: true })) and enforcessince <= untilbefore sync.research --limitand--thread-depthviaparsePositiveIntegerOptioninstead of rawNumber(...).src/lib/period-digest.ts):2026-02-30), invalid hours (T24:00:00Z), trailing junk, and reversed windows (since > until) while preserving valid aliases (today,24h,day,yesterday,week,7d), leap days, equal instants, local ISO timestamps, and timezone offsets.maxTweetsandmaxLinks, honors0and small caps without clamping to20/3or issuing minimum-one read-model queries, and preserves exact cap values inlatestDigestCacheKey.id, username, case-insensitive@handle, surrounding whitespace) once viaresolveDigestAccountSelector(findOperationAccount(getReadDb(), trimmed)?.id ?? trimmed), storing the canonical account ID incontext.account,latestDigestCacheKey, andenrichContextWithCitedTweets(getTweetsByIds) so outside-window cited tweets belonging to the selected account hydrate for@handlealiases while other accounts stay isolated and unknown selectors stay empty.cacheLatestDigestwrites in read-only deployments (isReadOnlyDeployment()), while keeping existing cached digests readable.Effect.eithererror channel, and read-only safety (src/lib/profile-analysis.ts):^[A-Za-z0-9_]{1,15}$) while preserving URL/@normalization, rejects fractional/unsafe/negative integers on explicit positive count/page and non-negative pacing/retry options, preserves upstreama147813673cedefault fallback for malformedBIRDCLAW_PROFILE_ANALYSIS_*environment overrides (including during cached reads), and wraps synchronous validation +getNativeDb()intrySyncso defects surface cleanly throughEffect.eitherbefore live transport.Real Shipped-CLI Reproduction (
bin/birdclaw.mjs, Base9895445vs. Headfe99caa)Executed against an isolated
$BIRDCLAW_HOMESQLite store (npm run build:node):1. Input Validation & Read-Only Guard Table
9895445)fe99caa)birdclaw --json digest invalidpreset{"error":"Unknown account: default"}(coercedinvalidpresettotodayand entered live sync){"error":"period must be today, 24h, day, yesterday, week, or 7d"}(exit1before sync)birdclaw --json digest --since 2026-03-10 --until 2026-03-01{"error":"Unknown account: default"}(accepted reversed window){"error":"since must be before or equal to until"}(exit1before sync)birdclaw --json digest --since 2026-02-30{"error":"Unknown account: default"}(rolled impossible date over to March){"error":"--since must be a valid YYYY-MM-DD or ISO timestamp"}(exit1before sync)BIRDCLAW_DEPLOYMENT_READ_ONLY=1 OPENAI_API_KEY="" birdclaw --json digest --no-live-sync today{"error":"OPENAI_API_KEY is not set"}(attempted uncached generation in read-only mode){"error":"No cached digest is available in this read-only deployment"}(exit1, zero writes/requests)birdclaw --json profile-analyze "@bad!handle"(writable, stalebackup.autoSync: true)birdclaw backup auto-sync failed: ...then{"error":"spawn xurl ENOENT"}(attempted backup sync &xurlbefore handle check){"error":"Profile handle must contain 1 to 15 letters, digits, or underscores"}(exit1before backup sync or transport)birdclaw --json research --limit 0 topic0with empty brief (Number("0")bypassed positive-int check){"error":"--limit must be at least 1"}(exit1beforeautoUpdateBeforeRead)2. End-to-End
v0.17.0Upgrade, Cached Read-Only Reads, Alias Hydration, Small Caps & Storage Invariance (Head fe99caa)Seeded a disposable
v0.17.0archive (birdclaw --json init --demo+ cacheddigest&profile-analyzeseeded by base9895445bin/birdclaw.mjsagainst a loopback stub, plus outside-window cited tweet2065597531644744901onacct_primaryand2065597531644744902onacct_secondary, then closed the stub and removedOPENAI_API_KEYandxurl):Verification
tests.patchon9895445ba0a24134cc6e07c327502134e18a58ea):node scripts/run-vitest.mjs run src/lib/period-digest.test.ts src/lib/profile-analysis.test.ts src/cli/register-analysis.test.ts-> 53 failed, 48 passed (101total).fe99caaafa1b675588495dcb000854ea49bba2ec):src/cli/register-analysis.test.ts31,src/lib/profile-analysis.test.ts31,src/lib/period-digest.test.ts44,src/routes/api/profile-analysis.test.ts3,src/cli.test.ts133).npm run format:check(oxfmt),npm run lint(oxlint,0warnings,0errors),npm run typecheck(tsc --noEmit), andnpm run build:node: all pass (verified standalone and on cumulative rollupcd4f0a576c308f8e62ca38388e5f1c533283b7c0across fix(sync,jobs): honor page caps, cache restoration, and account selectors in live sync and jobs #257–fix(analysis): validate CLI options before sync and honor read-only digest/profile contracts #265).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.
☁️