Skip to content

feat(review): deliver Claw & Order automation review with Krill case evaluation - #48

Open
jason-allen-oneal wants to merge 7 commits into
openclaw:mainfrom
jason-allen-oneal:feat/ai-detection-krill
Open

jason-allen-oneal wants to merge 7 commits into
openclaw:mainfrom
jason-allen-oneal:feat/ai-detection-krill

Conversation

@jason-allen-oneal

@jason-allen-oneal jason-allen-oneal commented Sep 17, 2026

Copy link
Copy Markdown

What Problem This Solves

High-volume public community channels face automated bot and AI agent activity that evades simple filters, live message observation writes overload transactional databases (Cloudflare D1), and unhardened escalation delivery risks duplicate cards, foreign bot receipt spoofing, or stale staff actions during worker interruptions.

User Impact

User impact: Community Team and Maintainers can inspect suspicious accounts via /review user:<target> [krill:boolean] with model estimates from Krill (gpt-6-astra low-thinking), while high-confidence agent activity automatically escalates review cards to #ct-general with actionable Carbon buttons (Dismiss, Watchlist 7d, Confirm Bot).

Operators can configure DISCRAWL_EXPORT_PATH on the forwarder host or DISCRAWL_EXPORT_URL on the Worker to serve message observation features and timing telemetry directly from Discrawl exports, eliminating live D1 observation writes. Shared review cards in #ct-general automatically synchronize when staff take action from ephemeral cards, and delivery recovery guarantees exact-bot receipt verification without duplicate sends or lost escalations.

Why This Change Was Made

  1. Discrawl Export Backend & Worker Bridge (src/services/discrawl.ts, forwarder/src/discrawlServer.ts, forwarder/src/index.ts):
    • Ingests channel export files (.json, .jsonl, or multi-channel directories) indexed by authorId using file modification times (mtime).
    • Solves the Worker runtime boundary: Forwarder host runs a lightweight authenticated HTTP service (startDiscrawlServer) exposing /api/discrawl/observations and /api/discrawl/count with Bearer token authentication (DISCRAWL_SECRET || DEPLOY_SECRET). The Cloudflare Worker queries this bridge via DISCRAWL_EXPORT_URL, with filesystem fallback for Node/Bun local runtimes.
    • Eliminates live write load: Message intake (reviewIngestMessageCreate.ts) and recordObservation (src/data/review.ts) skip live D1 writes entirely when export mode is enabled.
  2. Hardened Delivery Reconciliation & Foreign Bot Rejection (src/services/reviewNotifier.ts, src/data/review.ts):
    • Strictly enforces bot identity: findExistingReviewCard requires message.author?.id === botId && message.author?.bot === true using process.env.DISCORD_CLIENT_ID AND requires case-specific marker caseId=${caseId}, rejecting foreign bot messages in #ct-general.
    • Preserves uncertainty across atomic claims: claimReviewCaseDelivery records previous_delivery_status atomically in D1. Empty or inconclusive history lookups preserve uncertain and suppress duplicate sends. Stale claims (>120s) are treated conservatively as uncertain.
    • Deterministic delivery nonces: Computes SHA-256 nonce keyed by review-escalate:${caseId}:${cardRevision} with enforce_nonce: true on Discord POST to prevent gateway double-delivery.
    • Late decision guard: Pre-send status check against D1 aborts immediately if staff dismissed or watchlisted the case during lookup.
  3. Monotonic Card Revision Tracking & Stale Write Rejection (src/data/review.ts, src/components/reviewButtons.ts, src/services/reviewNotifier.ts):
    • recordReviewCaseDecision persists the staff decision and increments cardRevision atomically in D1 before any Discord I/O occurs, guaranteeing cardRevision > syncedCardRevision exists durably in D1 to allow maintenance recovery to discover and heal dropped interactions.
    • markReviewCardSynced(caseId, revision) enforces optimistic concurrency with WHERE case_id = ? AND card_revision = ? (identical to Hermit's nomination sync pattern in src/data/nominations.ts), rejecting stale writes from concurrent older actions.
    • Watchlist re-escalation allocates a fresh monotonic revision before I/O, PATCHes the existing card, and marks that revision synced.
  4. Open Case Promotion on Manual Review (src/commands/review.ts):
    • Promotes existing open or expired watchlist cases to escalated when manual review reaches review-recommended, setting deliveryStatus: "pending" for recovery while preserving terminal staff decisions (dismissed, confirmed_bot).
  5. Model-Estimated Assessment Phrasing (src/review/krillEvaluator.ts, src/review/analyzer.ts):
    • Replaced "calibrated probability" with "model-estimated assessment probability" in the system prompt and limitations report.
  6. Carbon 0.16.0 Contract Compliance & Guild Boundaries:
    • Uses interaction.options.getUser("user", true).id for type-safe User resolution.
    • Distinct customIds (review-dismiss:caseId=${caseId}, review-watchlist:caseId=${caseId}, review-confirm-bot:caseId=${caseId}) with defer = false for immediate Carbon v2 updates.
    • Restricts message intake, command execution, and escalation delivery strictly to the configured community guild.

Decision Resolution

  • Rollout Scope (Bounded Pilot Adopted): As recommended by ClawSweeper, initial screening will launch as a bounded staff-invoked pilot (/review command invoked by Community Team / Maintainers on suspicious accounts, with observations sourced from Discrawl exports or agreed test channels). Full automated guild-wide background escalation will be evaluated following operational experience and false-positive baseline verification.

Evidence

Boundary Before After
Message Observation Storage Required live D1 writes for all messages Configurable Discrawl export backend (DISCRAWL_EXPORT_PATH / DISCRAWL_EXPORT_URL) serves observations with zero live D1 writes
Worker Export File Boundary Worker could not access forwarder host files Forwarder HTTP bridge (startDiscrawlServer) exposes authenticated endpoints consumed via DISCRAWL_EXPORT_URL
Export Secret Configuration Forwarder hardcoded DEPLOY_SECRET on startup Forwarder startup uses `DISCRAWL_SECRET
Delivery Receipt Reconciliation Accepted any bot message with substring matches Strictly requires configured DISCORD_CLIENT_ID, bot === true, and caseId=${caseId}; foreign bot receipts rejected
Atomic Delivery Claim State Claim wiped uncertain / stale delivering to delivering previous_delivery_status durably preserved across atomic claims; stale claims (>120s) treated conservatively as uncertain
Inconclusive Reconciliation Lookup Treated absence as permission to re-POST, causing duplicates Inconclusive / empty lookup preserves uncertain without sending duplicate cards
Delivery Nonce Key Keyed by volatile updatedAt Keyed deterministically by caseId and cardRevision
Decision vs. Revision Persistence Decision saved before I/O, but revision saved only after Desired revision allocated and persisted with decision before I/O; acknowledged only after sync
Concurrent Card Sync Writes Delayed older action could overwrite newer revision markReviewCardSynced uses WHERE case_id = ? AND card_revision = ? to reject stale writes
Watchlist Re-escalation Re-escalated case marked delivered without updating closed card PATCHes existing card on reviewMessageId with fresh monotonic revision to reopen active review buttons
Manual Review of Existing Open Case Existing open case stayed open despite review-recommended Promotes existing open cases to escalated and schedules delivery
Shared Card Sync Failure Failed PATCH on ephemeral action logged and lost Persistent revision tracking (card_revision, synced_card_revision) repaired by periodic maintenance
Assessment Wording Claimed "calibrated probability" Accurately stated as "model-estimated assessment probability"
Database Migration from 0012 to 0013 Untested on populated database Verified: zero data loss across existing tables in populated SQLite migration test
  • Full Test Suite (bun test): Passed all 405 tests across 42 files (185,668 assertions) with 0 failures.
  • Discrawl Adapter & Forwarder Server (tests/discrawl.test.ts): 5 tests passing:
    • Single JSON archive parsing and observation extraction.
    • Multi-channel directory parsing (.json and .jsonl).
    • Local intake fallback and getRecentUserObservations integration with DISCRAWL_EXPORT_PATH.
    • Remote HTTP observation and count fetching via forwarder startDiscrawlServer with DISCRAWL_EXPORT_URL and Bearer token auth.
    • Startup secret precedence: tests DISCRAWL_SECRET || DEPLOY_SECRET and verifies unauthorized calls return 401.
  • Review Pipeline & Real D1 Integration (tests/review.test.ts): 29 tests passing:
    • Carbon User-option getter and foreign guild rejection.
    • Distinct customIds and defer = false across all review buttons.
    • Staff authorization checks and Carbon Container rejection notices.
    • Watchlist 7-day expiration timestamp storage and scheduled recovery.
    • Atomic delivery claim, stale claim recovery (>120s), and failure vs. uncertain state transitions.
    • Exact-bot receipt verification: adopts Hermit-owned card with caseId marker; strictly rejects foreign bot messages.
    • Watchlist re-escalation reopening existing card via PATCH without duplicate POST.
    • Failed shared card synchronization recovery via recoverSharedCardSync.
    • Immediate abort if case is no longer escalated prior to delivery POST.
    • Migration compatibility: applies migrations 0000..0012, populates sample data in existing tables, applies 0013 (card_revision, synced_card_revision, previous_delivery_status), and verifies zero data loss.
    • Real D1 Database & Atomic Delivery Lifecycle (regression suite using real SQLite/D1 instance):
      • Preserves uncertain delivery state across real atomic claim and prevents duplicate send on empty history.
      • Treats stale delivering claim conservatively as uncertain and reconciles existing card.
      • Rejects stale card writes using monotonic persisted revisions.
      • Promotes existing open cases when manual review reaches review-recommended.
  • Offline Benchmark (tests/reviewBenchmark.test.ts): 2 tests passing:
    • Rowan bot profile (1531171766179856496): 100/100 High concordance across 3 families -> review-recommended.
    • Human test account profile (958510681928400920): Low concordance -> gated at no-strong-indicators.
  • Typecheck & Deployment Dry Run: bun run typecheck, bun run --cwd forwarder typecheck, and bun run deploy:dry-run passed with 0 errors.

Review Disposition (Revision 4 Findings)

All 5 actionable findings from ClawSweeper's Revision 4 review are addressed and verified:

  1. Preserve uncertain delivery state across the atomic claim (src/services/reviewNotifier.ts:120-123, src/data/review.ts:199):

    • claimReviewCaseDelivery now writes previous_delivery_status: reviewCases.deliveryStatus and deliveryStatus: "delivering" atomically.
    • postReviewEscalationCard evaluates wasUncertain = claimedCase.previousDeliveryStatus === "uncertain" || claimedCase.previousDeliveryStatus === "delivering". If history reconciliation is inconclusive or empty, uncertain is preserved in D1 and duplicate sends are suppressed.
    • Replaced volatile updatedAt in nonce with deterministic review-escalate:${caseId}:${cardRevision}.
    • Verified via real D1 test: preserves uncertain delivery state across real atomic claim and prevents duplicate send on empty history.
  2. Persist synchronization work with the staff decision (src/components/reviewButtons.ts:145-152, src/data/review.ts):

    • recordReviewCaseDecision atomically updates the staff decision (status, expiresAt, decidedById, decisionReason) AND increments cardRevision: sql${reviewCases.cardRevision} + 1`` before any Discord I/O.
    • If the Discord update fails, cardRevision > syncedCardRevision is already persisted in D1, enabling periodic maintenance (recoverSharedCardSync) to discover and heal the card.
  3. Reject stale card writes using monotonic persisted revisions (src/services/reviewNotifier.ts:236-239, src/data/review.ts):

    • Added markReviewCardSynced(caseId, revision) which performs WHERE case_id = ? AND card_revision = ?. If a newer concurrent decision has bumped cardRevision, the update returns null, preventing stale writes from overwriting syncedCardRevision.
    • Verified via real D1 test: rejects stale card writes using monotonic persisted revisions.
  4. Honor the configured export secret in forwarder startup (forwarder/src/index.ts:54-59):

    • forwarder/src/index.ts extracts DISCRAWL_SECRET from Bun.env with fallback to DEPLOY_SECRET.
    • startDiscrawlServer receives secret: DISCRAWL_SECRET || DEPLOY_SECRET, eliminating 401s when DISCRAWL_SECRET is set.
    • Verified via unit test: authenticates discrawl server requests and rejects unauthorized calls in tests/discrawl.test.ts.
  5. Promote existing open cases when manual review recommends escalation (src/commands/review.ts:145-149):

    • ReviewCommand promotes open or expired watchlist cases to escalated when report.priority === "review-recommended", resetting deliveryStatus to "pending" for delivery while preserving terminal staff decisions (dismissed, confirmed_bot).
    • Verified via real D1 test: promotes existing open cases when manual review reaches review-recommended.

@clawsweeper

clawsweeper Bot commented Sep 17, 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 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: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 16, 2026, 11:49 PM ET / September 17, 2026, 03:49 UTC (Revision 6).

ClawSweeper review

What this changes

Adds staff-invoked Discord account screening, optional model assessments, persistent review cases, an authenticated message-export bridge, and recoverable review cards.

Merge readiness

Blocked before merge - 9 items remain

This remains a distinct contribution absent from main. Five prior concerns are addressed, but interrupted delivery and ambiguous stale writes still escape recovery, and real Discord proof remains incomplete.

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

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Substantial useful work and responsive repairs remain limited by recovery defects and incomplete real behavior evidence.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The complete matching body reports a real loopback export bridge and SQLite-backed validation, but the review command, Discord cards, and interrupted delivery have no observed real-setup result. The new script uses local D1 with mocked Discord transport and incorrectly sequences its populated-upgrade check. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 3 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The complete matching body reports a real loopback export bridge and SQLite-backed validation, but the review command, Discord cards, and interrupted delivery have no observed real-setup result. The new script uses local D1 with mocked Discord transport and incorrectly sequences its populated-upgrade check. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Applicable repository policy: Read the complete root AGENTS.md; no nested AGENTS.md files or maintainer-notes directory were found. Reviewed Carbon components, explicit guild-only command contexts, and registration in src/index.ts.
Main and replacement check: The pinned main tree has no account-screening pipeline, and its command registration lacks ReviewCommand. The repository-wide pull-request listing supplied no merged replacement for this behavior. The latest-release endpoint returned 404, so no release inclusion is established.
Revision continuity: Compared the previous reviewed head with the current head through GitHub. Default-off ingestion, atomic re-escalation revisions, receipt revision preservation, recovery ordering, and active-card rendering address five prior concerns. Stale-write repair now handles successful responses, but its error path still only logs and returns. Local git comparison encountered an unavailable historical blob; GitHub compare and pinned contents supplied the relevant history instead.
Findings 3 actionable findings [P2] Preserve repair work when a stale Discord write returns an error
[P2] Reconcile outstanding receipts after staff decide the case
[P2] Seed the upgrade database before applying migration 0013
Security None None.

How this fits together

Hermit runs Discord commands in a Cloudflare Worker, with a Bun forwarder supplying gateway events and optional message exports. The new review pipeline turns message telemetry into staff assessments and stores decisions in D1 before updating Discord cards.

flowchart TD
  A[Message exports or enabled intake] --> B[Behavioral analysis]
  C[Staff review command] --> B
  B --> D[Optional model assessment]
  B --> E[D1 review cases]
  D --> E
  E --> F[Discord review cards]
  F --> G[Authorized staff decisions]
  G --> E
  E --> H[Scheduled delivery recovery]
  H --> F
Loading

Decision needed

Question Recommendation
Should Hermit ship this staff-invoked account-screening pilot with identified behavioral telemetry sent for model assessment? Sponsor the bounded staff pilot: Approve staff-invoked screening after recovery repairs and real proof, keeping automatic screening disabled pending operational evaluation.

Why: The contributor adopted the suggested pilot, but the available discussion contains no maintainer approval of classification policy, data processing, or rollout scope.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The complete matching body reports a real loopback export bridge and SQLite-backed validation, but the review command, Discord cards, and interrupted delivery have no observed real-setup result. The new script uses local D1 with mocked Discord transport and incorrectly sequences its populated-upgrade check. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve repair work when a stale Discord write returns an error (P2) - The prior stale-write concern remains on the failure path. If revision 2's PATCH is delayed, revision 3 completes and is acknowledged, and Discord then applies revision 2 but its response is lost, this catch only logs and returns. D1 still says revision 3 is synchronized, so maintenance never repairs the now-stale card. Preserve an unsynchronized revision on ambiguous failed writes as well as rejected successful acknowledgments, including equivalent button-update failures.
  • Reconcile outstanding receipts after staff decide the case (P2) - If Discord accepts the initial POST, staff dismiss the case from an ephemeral card, and the sender stops before saving reviewMessageId, the decision persists but recovery cannot find it: delivery selection and claiming require escalated, while this synchronization query requires a message ID. The shared card can remain actionable indefinitely. Reconcile outstanding receipts independently of disposition without sending a new escalation for decided cases. This was missed previously; pinned prior-source comparison confirms these guards were already present.
  • Seed the upgrade database before applying migration 0013 (P2) - The script applies all migrations at lines 75–84, then inserts these supposedly pre-existing rows and announces zero data loss. A migration that deletes existing data would still pass this sequence. Use a separate database at migration 0012, seed and snapshot its rows, apply 0013, and assert preservation before printing success; keep the fresh-install scenario separate.
  • Resolve merge risk (P1) - The bounded pilot still needs maintainer acceptance of account-classification criteria, false-positive handling, and sending identified behavioral telemetry to the model provider.
  • Resolve merge risk (P1) - Fresh and populated Worker/D1 deployment compatibility has not been demonstrated; the additive SQL and SQLite regression are useful but do not establish the claimed D1 upgrade run.
  • Resolve merge risk (P2) - Actual Discord timeout and interaction behavior remains unverified, including convergence after interrupted sends and overlapping staff actions.
  • Complete next step (P2) - Repair the three findings, obtain maintainer approval for the staff pilot, and supply real Worker/Discord and correctly sequenced D1 upgrade evidence before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P2] Preserve repair work when a stale Discord write returns an error — src/services/reviewNotifier.ts:317-319
  • [P2] Reconcile outstanding receipts after staff decide the case — src/data/review.ts:403-410
  • [P2] Seed the upgrade database before applying migration 0013 — scripts/proof-review-pipeline.ts:100-108
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test code Production code +3,043/-1; tests +1,922/-0 The stated scope includes a new screening pipeline and export server; these counts exclude migration metadata and the proof script.
Stored schema 2 tables added; 0 existing tables changed The migration is additive, but deployment and populated-upgrade evidence still matter.

Merge-risk options

Maintainer options:

  1. Complete recovery and upgrade validation (recommended)
    Repair ambiguous stale writes and receipt recovery after decisions, then demonstrate the corrected pipeline and populated D1 upgrade.
  2. Hold rollout pending sponsorship and proof
    Keep this branch open without shipping the pilot until its operational owner and real Discord evidence are established.

Technical review

Best possible solution:

Deliver a maintainer-approved staff pilot with durable receipt reconciliation independent of case disposition, convergent card synchronization, and verified fresh and populated D1 operation.

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

Yes for the patch defects: source establishes the failing interruption schedules and the incorrect upgrade-proof ordering. No runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Partly: a default-off staff pilot fits the stated scope, but the recovery design must preserve work across ambiguous responses and terminal decisions; the existing nomination synchronization offers a useful failure-handling precedent.

Full review comments:

  • [P2] Preserve repair work when a stale Discord write returns an error — src/services/reviewNotifier.ts:317-319
    The prior stale-write concern remains on the failure path. If revision 2's PATCH is delayed, revision 3 completes and is acknowledged, and Discord then applies revision 2 but its response is lost, this catch only logs and returns. D1 still says revision 3 is synchronized, so maintenance never repairs the now-stale card. Preserve an unsynchronized revision on ambiguous failed writes as well as rejected successful acknowledgments, including equivalent button-update failures.
    Confidence: 0.96
  • [P2] Reconcile outstanding receipts after staff decide the case — src/data/review.ts:403-410
    If Discord accepts the initial POST, staff dismiss the case from an ephemeral card, and the sender stops before saving reviewMessageId, the decision persists but recovery cannot find it: delivery selection and claiming require escalated, while this synchronization query requires a message ID. The shared card can remain actionable indefinitely. Reconcile outstanding receipts independently of disposition without sending a new escalation for decided cases. This was missed previously; pinned prior-source comparison confirms these guards were already present.
    Confidence: 0.97
    Late finding: first raised on code an earlier review cycle already covered.
  • [P2] Seed the upgrade database before applying migration 0013 — scripts/proof-review-pipeline.ts:100-108
    The script applies all migrations at lines 75–84, then inserts these supposedly pre-existing rows and announces zero data loss. A migration that deletes existing data would still pass this sequence. Use a separate database at migration 0012, seed and snapshot its rows, apply 0013, and assert preservation before printing success; keep the fresh-install scenario separate.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8e6e63a8f29d.

Labels

Label justifications:

  • P2: This is a bounded new staff workflow with repairable reliability defects, not an established urgent production outage.
  • merge-risk: 🚨 message-delivery: Interrupted sends and ambiguous stale writes can leave shared review cards inconsistent with persisted staff decisions.
  • merge-risk: 🚨 compatibility: The PR adds durable D1 schema and an optional forwarder bridge without demonstrated fresh and populated Worker deployment compatibility.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The complete matching body reports a real loopback export bridge and SQLite-backed validation, but the review command, Discord cards, and interrupted delivery have no observed real-setup result. The new script uses local D1 with mocked Discord transport and incorrectly sequences its populated-upgrade check. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Applicable repository policy: Read the complete root AGENTS.md; no nested AGENTS.md files or maintainer-notes directory were found. Reviewed Carbon components, explicit guild-only command contexts, and registration in src/index.ts. (AGENTS.md:1, f232cd5aedd4)
  • Main and replacement check: The pinned main tree has no account-screening pipeline, and its command registration lacks ReviewCommand. The repository-wide pull-request listing supplied no merged replacement for this behavior. The latest-release endpoint returned 404, so no release inclusion is established. (src/index.ts, 8e6e63a8f29d)
  • Revision continuity: Compared the previous reviewed head with the current head through GitHub. Default-off ingestion, atomic re-escalation revisions, receipt revision preservation, recovery ordering, and active-card rendering address five prior concerns. Stale-write repair now handles successful responses, but its error path still only logs and returns. Local git comparison encountered an unavailable historical blob; GitHub compare and pinned contents supplied the relevant history instead. (src/services/reviewNotifier.ts:302, f232cd5aedd4)
  • Recovery excludes decided cases without receipts: Delivery claiming and candidate selection require escalated status, while synchronization selection requires a stored review message ID. A staff decision made while an initial POST is outstanding can therefore become unrecoverable if the sender stops before persisting the receipt. Pinned prior-file inspection verified that the claim and synchronization-selector blocks were unchanged since the previous review. (src/data/review.ts:409, f232cd5aedd4)
  • Complete proof body inspected: Read the full 13,466-unit body and verified SHA-256 4532981d0d1f9843ad2b0768dd609c024fbc83c3af8d8c7337ff7c4e4fad548d, matching the captured snapshot. It reports synthetic benchmarks, SQLite-backed tests, and a real loopback export bridge, but no observed real Discord command/card recovery. The new script also substitutes mock get/post/patch methods for Discord. No target code or embedded proof script was executed. (scripts/proof-review-pipeline.ts:143, f232cd5aedd4)
  • Upgrade evidence distinction: The existing SQLite test correctly seeds data before applying migration 0013. The new D1 proof script instead applies every migration before inserting its purported pre-existing rows, then prints an unconditional preservation success. Snapshot comparison found exactly two added tables and no changes to existing tables. (scripts/proof-review-pipeline.ts:100, f232cd5aedd4)

Likely related people:

  • hannesrudolph: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Cover ambiguous stale-write failures and staff decisions during an interrupted initial send with focused interleaving regressions.
  • Correct the D1 upgrade script and obtain maintainer sponsorship for the bounded pilot.
  • Add redacted real Worker/Discord evidence for staff review and interrupted recovery, plus fresh and populated D1 validation; screenshots or recordings help visible behavior, and logs or terminal traces count. Redact credentials, IP addresses, private endpoints, and personal details. Update the PR body for automatic re-review; if needed, ask a maintainer to comment @clawsweeper re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-17T01:29:53.278Z sha 891ef4c :: needs real behavior proof before merge. :: [P1] Read the target with Carbon's User-option getter | [P1] Give each review action a distinct Carbon key and parsed case field | [P1] Enforce the configured guild before collecting or escalating | [P2] Edit the source card without acknowledging the interaction twice | [P2] Persist the open-to-escalated transition on an existing case | [P2] Keep failed escalation delivery eligible for recovery
  • reviewed 2026-09-17T01:47:05.187Z sha b134933 :: needs real behavior proof before merge. :: [P2] Recover delivery claims left behind by an interrupted Worker | [P2] Distinguish uncertain delivery from a rejected send | [P2] Check current case status when claiming an escalation | [P2] Synchronize the stored staff card after command-card decisions
  • reviewed 2026-09-17T02:12:20.043Z sha 6f53de2 :: needs real behavior proof before merge. :: [P2] Skip live observation writes when the export backend is selected | [P2] Expose exports across the actual Worker boundary | [P2] Preserve uncertainty when reconciliation cannot prove delivery | [P2] Require a Hermit-owned case identity before adopting a receipt | [P2] Reopen the existing card when a watchlist case escalates again | [P2] Persist failed shared-card updates for recovery
  • reviewed 2026-09-17T02:33:12.051Z sha 014fcfa :: needs real behavior proof before merge. :: [P2] Preserve uncertain delivery state across the atomic claim | [P2] Persist synchronization work with the staff decision | [P2] Reject stale card writes using monotonic persisted revisions | [P2] Honor the configured export secret in forwarder startup | [P2] Promote existing open cases when manual review recommends escalation
  • reviewed 2026-09-17T02:54:54.004Z sha c6f4fad :: needs real behavior proof before merge. :: [P1] Enforce the stated staff-invoked pilot before enabling ingestion | [P2] Schedule repair when an older Discord write finishes last | [P2] Preserve current revisions when adopting a delivery receipt | [P2] Allocate re-escalation revisions atomically with the status guard | [P2] Rotate recovery candidates so uncertain cases cannot starve new ones | [P2] Preserve active buttons when recovering an escalated card

…delivery recovery

- Enforce reviewConfig.guildId at intake and delivery boundary
- Read target user via getUser('user', true).id in /review command
- Give review buttons distinct Carbon keys (review-dismiss, review-watchlist, review-confirm-bot) with defer=false and parsed caseId
- Render permission notices with Carbon v2 Container/TextDisplay
- Add guarded status transition in createReviewCase preserving staff decisions
- Add atomic delivery claim, error recovery tracking, and 14-day observation pruning
- Add 7-day watchlist expiry and maintenance worker in scheduled service
- Add unit tests for button routing, option getter, guild boundary, and delivery recovery
@jason-allen-oneal

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 17, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. label Sep 17, 2026
…elivery

- Add Discrawl backend adapter supporting single JSON/JSONL archives and channel directory exports via DISCRAWL_EXPORT_PATH
- Transparently route observation queries to Discrawl exports when configured, preserving D1 fallback
- Reclaim stale 'delivering' claims (>120s) and guard delivery to strictly require 'escalated' status
- Distinguish 4xx HTTP rejections ('failed') from network drops ('uncertain') and reconcile channel history before posting to prevent duplicate cards
- Synchronize shared public review card when decisions are submitted from ephemeral /review cards
- Clarify Krill probability label as model estimate
- Add populated database upgrade test verifying zero data loss from 0012 to 0013
@jason-allen-oneal

Copy link
Copy Markdown
Author

@clawsweeper re-review

Updated commit 6f53de2 addresses all findings from the recent review and adds the requested Discrawl export backend:

  1. Delivery-State Hardening & Interrupted Worker Recovery:

    • Reclaims stale delivering claims older than 120s (updatedAt <= staleCutoff) in claimReviewCaseDelivery and getUndeliveredEscalations.
    • Atomic status guard: claimReviewCaseDelivery checks status = 'escalated' and returns the fresh ReviewCase record; aborts delivery immediately if staff intervened (e.g. dismissed or watchlisted).
    • Distinguishes 4xx HTTP rejections (failed) from network drops/timeouts (uncertain).
    • Reconciles uncertain deliveries by scanning channel history for existing cards before posting to prevent duplicate cards.
  2. Shared Card Synchronization:

    • syncSharedReviewCard patches the persistent shared escalation card in #ct-general via REST API whenever staff takes action from an ephemeral /review command card.
  3. Accurate Assessment Wording:

    • Updated probability description to "Krill Assessment Probability (Model Estimate)".
  4. Discrawl Export Backend:

    • Added src/services/discrawl.ts supporting single JSON/JSONL archives or multi-channel directories via DISCRAWL_EXPORT_PATH.
    • Offline extraction and in-memory mtime indexing eliminates live D1 write overhead while keeping D1 for review cases and moderation actions. Seamless fallback to D1 observations when unset.
  5. Populated Database Upgrade Proof:

    • Automated migration test in tests/review.test.ts applies migrations 0000..0012, inserts sample rows into existing tables, applies 0013_reflective_rictor.sql, and verifies zero data loss and new schema readiness.
  6. Full Test Suite & Build:

    • Full suite: 396 pass, 0 fail across 42 test files (185,642 assertions).
    • Typecheck and dry-run deployment pass cleanly.

@clawsweeper

clawsweeper Bot commented Sep 17, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. and removed merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Sep 17, 2026
@jason-allen-oneal

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 17, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. and removed merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Sep 17, 2026
@jason-allen-oneal

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 17, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

[P1] Enforce staff-invoked pilot before enabling ingestion
  - Added ENABLE_AUTOMATIC_SCREENING env flag (default off)
  - Added REVIEW_PILOT_CHANNEL_IDS for optional channel scoping
  - Listener returns early unless flag is explicitly 'true'

[P2] Schedule repair when an older Discord write finishes last
  - Added markReviewCardStaleWrite (mirrors nominationCardSync pattern)
  - All three button handlers detect rejected acks and schedule repair
  - syncSharedReviewCard detects stale writes and retries

[P2] Preserve current revisions when adopting a delivery receipt
  - Receipt adoption no longer overwrites cardRevision/syncedCardRevision
  - Reads fresh case state after lookup and reconciles via syncSharedReviewCard

[P2] Allocate re-escalation revisions atomically with the status guard
  - Added allocateReescalationRevision: UPDATE SET cardRevision = cardRevision + 1
    WHERE status = 'escalated' (atomic guard)

[P2] Rotate recovery candidates so uncertain cases cannot starve new ones
  - getUndeliveredEscalations orders by priority (pending→failed→uncertain)
  - Uses asc(updatedAt) within each tier
  - Applies 60s backoff to uncertain cases

[P2] Preserve active buttons when recovering an escalated card
  - syncSharedReviewCard derives isClosed from fresh.status !== 'escalated'
  - Escalated cards keep interactive Dismiss/Watchlist/ConfirmBot buttons

Tests: 411 pass, 0 fail (35 review + 5 discrawl included)
Proof: scripts/proof-review-pipeline.ts exercises real D1 for all 6 findings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant