KB-B81E

GPT Review — Backup Triage Fix Path Decision

6 min read Revision 1
gptgovernancebackupg6sandbox_tacfix-pathdecision

GPT Review — Backup Triage Fix Path Decision

Date: 2026-04-27
Scope: Review Claude Code triage report knowledge/dev/laws/dieu38-trien-khai/reports/p9-g6-backup-incident-triage-fix-plan-2026-04-27.md and Opus evaluation.

Verdict

Claude Code PASS. Proceed to a narrow governed fix gate: Option A + Option D.

Do not wait for broader P7/C2 ownership clarification before restoring backups. Backup integrity is an operational blocker and should be restored first. Medium-term ownership/cleanup of sandbox_tac can be handled after backups are healthy.

Evidence checked

  • knowledge/dev/laws/dieu38-trien-khai/reports/p9-g6-backup-incident-triage-fix-plan-2026-04-27.md rev 1.
  • knowledge/dev/reports/gpt-review-backup-incident-triage-dispatch-final-pass-2026-04-27.md.
  • knowledge/dev/reports/gpt-review-backup-recovery-root-cause-sandbox-tac-2026-04-27.md.
  • Prior P7B/PF-4 evidence: sandbox_tac was a P7B/C2 sandbox schema and had 0 Directus collections exposed.

Findings

  1. sandbox_tac is owned by workflow_admin, not directus.
  2. It has 8 tables, at least 243 live rows, 3 functions, and 2 triggers.
  3. It is standalone except internal pg_toast dependency.
  4. It has 0 Directus collection binding based on prior PF-4 evidence and current triage.
  5. directus lacks USAGE on sandbox_tac, causing pg_dump failure.
  6. Backup failure window is about 37–41h, with last good backup around 2026-04-26 02:00 UTC at about 43.7 MB.
  7. Script was already partially hardened in S174; the remaining weakness is failure cleanup/notification behavior around pg_dump | gzip with set -euo pipefail.
  8. Kuma did not false-report UP; failure was DOWN-by-absence / no success heartbeat. The previous Opus assumption was incorrect and should be corrected.

Decision

Choose Option A + Option D now:

Option A — narrow grant for backup restore

Grant only what is needed for backup role directus to dump sandbox_tac:

  • GRANT USAGE ON SCHEMA sandbox_tac TO directus;
  • GRANT SELECT ON ALL TABLES IN SCHEMA sandbox_tac TO directus;
  • If sequences exist or appear later: GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA sandbox_tac TO directus;

Do not grant CREATE. Do not modify owners. Do not expose Directus collections. Do not change search_path.

Option D — script hardening companion

Patch the governed backup script so future dump failures do not leave misleading output and do not silently disappear:

  • Use temp output file and atomic move only after validation PASS.
  • Add trap/cleanup for incomplete temp files.
  • Preserve set -euo pipefail.
  • Make validation explicit: size threshold, gzip validity, PG dump header/table sanity.
  • Success heartbeat only after validation PASS.
  • Failure notification/alert path should be explicit without leaking secrets. If Kuma supports explicit failure status in the existing setup, use it; otherwise rely on absence of success heartbeat plus Telegram/log alert.

Law / constitutional check

Rule Result Finding
Hiến pháp / Zero Trust PASS Fix is scoped to restoring backup integrity; post-verify required.
Đ33 DB governance PASS if gated GRANT is DDL and must be executed only via a scoped governed gate.
Đ35 / 100% DOT-AI PASS if AI/DOT governed User must not run manual psql; Claude Code/agent can execute after explicit authorization.
Đ32 gate discipline PASS Fix gate must be separate from G6 retry.
Đ24 PASS No taxonomy/entity labels involved.

Required next step

Opus should draft a compact Backup Fix Execution Gate — Option A + D for Claude Code, medium/high effort. Because it includes production DDL GRANT plus script patch, recommended effort is high (not xhigh unless the executor has low confidence). The task should be one execution block with pre-checks, mutation, post-verify, and action log.

The gate must include:

  1. Pre-checks:
    • VPS context.
    • Confirm sandbox_tac exists and directus lacks required privileges.
    • Confirm no Directus collections bind sandbox_tac.
    • Confirm current backup script path, owner, permissions, and last good backup baseline.
    • Backup script snapshot/hash before edit.
  2. Mutations:
    • Apply narrow GRANTs only.
    • Patch backup script hardening only; no cron/systemd/rclone destination changes.
  3. Post-verify:
    • has_schema_privilege('directus','sandbox_tac','USAGE') = true.
    • Table SELECT privilege sufficient for backup.
    • Run governed backup script.
    • New backup is non-trivial size, gzip valid, PG header/table sanity PASS.
    • No 20-byte output remains as “latest good”.
    • Failure path documented if backup still fails.
  4. Action log:
    • knowledge/dev/laws/dieu38-trien-khai/reports/p9-g6-backup-fix-option-a-d-log-2026-04-27.md.
  5. Stop after report. No G6 retry, no PF-07 wrapper patch, no Directus mutation.

Medium-term follow-up after backup restored

  • Decide whether to keep, cleanup, or archive sandbox_tac after P7/C2 ownership clarification.
  • Update operational memory: code backup 4x/day vs full DB backup daily; remote gdrive-backup:; Kuma failure behavior is DOWN-by-absence, not false-UP.