Skip to content

refactor(team-reports): await persistence and drain shutdown - #144646

Merged
steipete merged 1 commit into
mainfrom
codex/async-team-reports-store
Sep 11, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/async-team-reports-store

Conversation

@steipete

@steipete steipete commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Related: #144592

What Problem This Solves

Team Reports owns synchronous database operations across startup, scheduling, HTTP handlers and shutdown. Awaiting these operations requires shutdown to account for work admitted before it stops, including a run record that is still being created.

Why This Change Was Made

Convert the store factory, queries, mutations and close operation to asynchronous contracts and migrate all callers. The scheduler reserves a run before awaiting persistence and drains admitted database work before closing the store. Cancellation interrupts external collection and model work; final database outcomes are allowed to settle. Startup publishes one scheduler/store owner only after initialization succeeds and closes an instance retired during startup.

Remove the duplicate store-closing owner. Prepared in-memory organization and people accessors stay synchronous. The SQLite schema, transaction callbacks and retention policy are unchanged.

User Impact

Reports keep their existing API and scheduling behavior. Startup and shutdown consistently own pending persistence, preventing store closure underneath an admitted report run.

Evidence

  • 238 focused store, scheduler, lifecycle and HTTP tests passed, including delayed startup, cancellation and drainage.
  • Full selected changed checks, the full build (348.8 seconds) and fresh independent Codex review passed.
  • Standalone production-source smoke exercised synthetic collection, real SQLite persistence and fresh-process reopening, plus four real loopback HTTP routes returning 200.
  • Thirty warm samples measured read median 0.102 ms and write median 0.216 ms; no comparative speedup is claimed.
  • This proof uses isolated source runtime and synthetic inputs, not a deployed Gateway or external model service.

CI initially timed out in the unchanged managed-update refusal process test. The exact candidate case passed locally in 1.60 seconds with its original 60-second deadline and journal-immutability assertions; the same-head failed-job rerun is green. No Team Reports or test changes were needed.

@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation plugin: team-reports size: XL maintainer Maintainer-authored PR labels Sep 11, 2026
@steipete
steipete marked this pull request as ready for review September 11, 2026 04:17
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 12:23 AM ET / 04:23 UTC.

ClawSweeper review

What this changes

Team Reports makes storage operations awaitable and drains admitted report work before closing its database during shutdown.

Merge readiness

✅ Ready for maintainer review

Keep open: this focused storage-boundary conversion remains useful and follows the linked maintainer coordination issue. No blocking defect was found in the introduced changes.

Priority: P2
Reviewed head: 028f68f27eff9454daaa15b109336d50ca5ea277

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-and-caller conversion with meaningful lifecycle coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository context identifies this as maintainer-authored work, so ordinary contributor proof is exempt. The body reports real SQLite reopening and loopback HTTP success; delayed persistence and retirement are covered by inspected tests rather than independently observed runtime traces.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository context identifies this as maintainer-authored work, so ordinary contributor proof is exempt. The body reports real SQLite reopening and loopback HTTP success; delayed persistence and retirement are covered by inspected tests rather than independently observed runtime traces.
Evidence reviewed 7 items Pinned scope and clean checkout: The checkout matches the supplied original PR head. The introduced delta is confined to Team Reports implementation, tests, and documentation; git diff --check passed and the checkout remained clean.
Main and release still use synchronous contracts: The scheduler and store are unchanged between the pinned merge base and fetched main. The v2026.9.4 scheduler also retains synchronous storage calls and the former shutdown implementation, so neither inspected baseline supersedes this conversion.
Admission and shutdown ownership: The scheduler reserves its active run before awaiting run-record persistence, tracks scheduled work, awaits startup and active completion during stop, and owns the awaited store close. Cancellation now surrounds external work while database writes and final outcomes settle.
Findings None None.
Security None None.

How this fits together

Team Reports collects GitHub activity and optional Discord discussion, stores reports in SQLite, and serves them through authenticated HTTP pages and Gateway commands. Its scheduler coordinates collection, summarization, persistence, and shutdown.

flowchart TD
  A[Schedule or manual request] --> B[Reserve and record run]
  B --> C[Collect activity and summarize]
  C --> D[SQLite report storage]
  D --> E[Authenticated pages and commands]
  F[Service shutdown] --> G[Stop admission and drain work]
  G --> D
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +65, Tests +188, Docs +2. Total +255 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 6 233 168 +65
Tests 4 399 211 +188
Docs 1 4 2 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 636 381 +255

Review metrics

Metric Value Why it matters
Production versus test growth Production +65 net lines; tests +188 net lines Production growth implements admission and drainage ownership, with most net growth devoted to caller migration and lifecycle coverage.

Technical review

Best possible solution:

Keep one scheduler responsible for report admission and database disposal, with callers awaiting durable outcomes and cancellation confined to external work.

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

Not applicable: this is a coordinated storage-contract refactor rather than a reported current-main failure; source inspection confirms the synchronous baseline.

Is this the best way to solve the issue?

Yes: the patch converts the existing owner and its callers together while preserving SQLite transactions, stored formats, and public response shapes.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 068318110aec.

Labels

Label changes:

  • add P2: This is a bounded reliability and storage-contract improvement within the optional Team Reports plugin.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository context identifies this as maintainer-authored work, so ordinary contributor proof is exempt. The body reports real SQLite reopening and loopback HTTP success; delayed persistence and retirement are covered by inspected tests rather than independently observed runtime traces.

Label justifications:

  • P2: This is a bounded reliability and storage-contract improvement within the optional Team Reports plugin.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository context identifies this as maintainer-authored work, so ordinary contributor proof is exempt. The body reports real SQLite reopening and loopback HTTP success; delayed persistence and retirement are covered by inspected tests rather than independently observed runtime traces.

Evidence

What I checked:

  • Pinned scope and clean checkout: The checkout matches the supplied original PR head. The introduced delta is confined to Team Reports implementation, tests, and documentation; git diff --check passed and the checkout remained clean. (028f68f27eff)
  • Main and release still use synchronous contracts: The scheduler and store are unchanged between the pinned merge base and fetched main. The v2026.9.4 scheduler also retains synchronous storage calls and the former shutdown implementation, so neither inspected baseline supersedes this conversion. (extensions/team-reports/src/scheduler.ts, 068318110aec)
  • Admission and shutdown ownership: The scheduler reserves its active run before awaiting run-record persistence, tracks scheduled work, awaits startup and active completion during stop, and owns the awaited store close. Cancellation now surrounds external work while database writes and final outcomes settle. (extensions/team-reports/src/scheduler.ts:170, 028f68f27eff)
  • Stored format and transaction boundaries preserved: The complete store retains its database path, schema initialization, synchronous SQLite transaction callbacks, serialization, conditional run completion, and retention logic. Changed methods expose Promise contracts without adding a public SDK surface. (extensions/team-reports/src/store.ts:152, 028f68f27eff)
  • Lifecycle regression coverage: Inspected tests cover delayed admission, rejected admission followed by recovery, cancellation during an admitted report write, reopening the persisted result, and delayed startup/disposal. The registration test additionally covers retirement while storage opens. These tests were read, not executed in this read-only review. (extensions/team-reports/src/scheduler.test.ts:230, 028f68f27eff)
  • Coordination and reported runtime evidence: The captured PR body links Complete asynchronous runtime storage boundaries while retaining SQLite #144592, which requests coherent async storage-owner conversions while retaining SQLite. It reports 238 focused passing tests and a production-source smoke using synthetic collection, real SQLite persistence, fresh-process reopening, and four loopback HTTP routes returning 200. It explicitly excludes a deployed Gateway and external model service; this review did not independently execute that smoke. (028f68f27eff)

Likely related people:

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

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.

@steipete
steipete merged commit 665e062 into main Sep 11, 2026
314 of 316 checks passed
@steipete
steipete deleted the codex/async-team-reports-store branch September 11, 2026 05:02
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. plugin: team-reports rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

1 participant