Skip to content

docs(db): telemetry retention is already active in pg_cron — retract scheduled-job proposal#1011

Merged
BigSimmo merged 3 commits into
mainfrom
claude/clinical-kb-pwa-review-asi3wb
Jul 20, 2026
Merged

docs(db): telemetry retention is already active in pg_cron — retract scheduled-job proposal#1011
BigSimmo merged 3 commits into
mainfrom
claude/clinical-kb-pwa-review-asi3wb

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

Close-out of the user-authorized "implement your recommendation for all decisions" pass — with a correction instead of a new job. Deeper discovery (PIA §6 + a fresh read-only cron.job verification, 2026-07-20) shows telemetry retention is already fully active inside the database via pg_cron:

jobid Job Schedule (UTC) Window
11 purge-expired-rag-queries daily 03:30 30 days
12 purge-rag-retrieval-logs daily 03:00 90 days
13 purge-rag-query-misses daily 03:45 90 days
16 purge-rag-response-cache hourly bounded expired-cache purge

The just-merged #1009 "open decision" premise ("retention is currently manual and unbounded") was wrong, and the proposed weekly GitHub-side purge workflow would have duplicated pg_cron with window drift — a 90-day rag_queries sweep can never delete anything the live 30-day job hasn't already removed. So: nothing was built, and no live mutation was made. This PR rewrites the db-maintenance section to the resolved state, documents purge:query-logs as the manual owner-scoped tool (not the retention mechanism), and records the retraction in the ledger. Retention windows remain PIA-governed privacy decisions (change via migration + PIA update only).

The other two authorized decisions stand as documented no-action: auth percentage connection strategy deferred to the next instance resize; operational unused-index drops not recommended.

Verification

  • npx prettier --check on both changed docs — clean
  • npm run docs:check-links — 1036 repo path references resolve
  • Supabase access was read-only: a single select … from cron.job (same user-authorized read-only envelope as tonight's advisor sweep); no schema, config, data, or workflow changes anywhere

Risk and rollout

  • Risk: none — documentation-only diff; no workflow, schema, or provider surface touched.
  • Rollback: revert.
  • Provider or production effects: none (one read-only SQL select was the only live interaction).

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use — no behaviour change
  • No patient-identifiable document workflow was introduced or expanded
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy) — read-only cron.job select only
  • Service-role keys and private document access remain server-only — nothing altered
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked: no clinical decision-support behaviour changed

🤖 Generated with Claude Code

https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9


Generated by Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated telemetry retention documentation to reflect that automated cleanup is already active at the database level.
    • Added concrete schedule and retention-window details for query, retrieval-log, query-miss, and response-cache purges.
    • Clarified which related backlog jobs are present but inactive under backlog controls.
    • Confirmed audit logs are intentionally retained indefinitely.
    • Clarified that manual owner-scoped query-log purging is a separate, non-automated tool.
    • Appended a ledger entry marking the review as resolved and retracting the earlier recommendation.

…scheduled-job proposal

Fresh read-only cron.job verification (2026-07-20) matches the PIA §6 record
exactly: rag_queries 30d (jobid 11), rag_retrieval_logs 90d (jobid 12),
rag_query_misses 90d (jobid 13), response cache hourly bounded (jobid 16) -
all active. The just-merged 'open decision' section's premise (manual and
unbounded) was wrong, and the proposed weekly GitHub-side purge would have
duplicated pg_cron with window drift. Section rewritten to the resolved state;
purge:query-logs documented as the manual owner-scoped tool, not the retention
mechanism. No live mutations - the single cron.job SELECT was the only access.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
@BigSimmo
BigSimmo marked this pull request as ready for review July 20, 2026 21:15
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 20, 2026 21:15
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cfe2ab7e-8131-4cfe-be3c-f4ec6e081ef3

📥 Commits

Reviewing files that changed from the base of the PR and between 01368ff and 7a60de0.

📒 Files selected for processing (1)
  • docs/branch-review-ledger.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/branch-review-ledger.md

📝 Walkthrough

Walkthrough

The documentation records telemetry retention as active through database-level pg_cron jobs, distinguishes automated retention from the manual query-log purge tool, and adds a branch review ledger entry documenting the verification.

Changes

Telemetry retention documentation

Layer / File(s) Summary
Document resolved retention state
docs/db-maintenance.md, docs/branch-review-ledger.md
The maintenance guide lists active purge schedules and retention windows, clarifies indefinite audit_logs retention and the absent unbounded cache job, and the ledger records the documentation-only verification.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the docs-only retraction of the scheduled retention proposal in favor of existing pg_cron jobs.
Description check ✅ Passed The PR description matches the template well with Summary, Verification, Risk and rollout, and Clinical Governance sections filled in.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/clinical-kb-pwa-review-asi3wb

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/branch-review-ledger.md`:
- Line 663: Update the ledger entry for claude/clinical-kb-pwa-review-asi3wb to
replace “see PR head” with the exact reviewed commit SHA. Preserve the existing
restart/base reference and all other verification details, ensuring the SHA
identifies the precise reviewed head.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f8dfd2ef-4722-4185-8d34-2a4ef4c8a5b5

📥 Commits

Reviewing files that changed from the base of the PR and between 8dfb377 and 01368ff.

📒 Files selected for processing (2)
  • docs/branch-review-ledger.md
  • docs/db-maintenance.md

Comment thread docs/branch-review-ledger.md Outdated
CodeRabbit review on #1011: the row used the 'see PR head' placeholder; the
ledger's skip-unchanged-reviews protocol keys on branch + HEAD SHA, so the row
now names 01368ff (content commit) plus the 0144e69 main merge-in.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
@BigSimmo
BigSimmo merged commit f33890a into main Jul 20, 2026
33 checks passed
@BigSimmo
BigSimmo deleted the claude/clinical-kb-pwa-review-asi3wb branch July 20, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants