Skip to content

Milestone 13: deterministic run archiving and retention controls - #24

Merged
anschmieg merged 2 commits into
mainfrom
copilot/add-deterministic-run-archiving
Mar 15, 2026
Merged

anschmieg merged 2 commits into
mainfrom
copilot/add-deterministic-run-archiving

Conversation

Copilot AI commented Mar 15, 2026 •

Copy link
Copy Markdown

Adds an explicit lifecycle operation to archive finalized runs, distinguishing preserved historical runs from the active working set — without introducing any backend autonomy.

Protocol (deterministic-protocol)

  • New ArchiveMetadata struct (reason, archived_at) added to RunState
  • New RunArchiveParams / RunArchiveResult types
  • RunsListParams extended with include_archived / archived_only booleans
  • RunSummary and RunGetResult carry archive fields
  • Method::RunArchive → wire name "run.archive"

Core logic (deterministic-core)

New run_archive module enforces eligibility rules:

  • Eligible: finalized:completed, finalized:failed, finalized:abandoned
  • Rejected: active, prepared, awaiting-approval, already-archived
  • Appends run_archived audit entry; does not execute work or reopen the run

Daemon (deterministic-daemon)

  • handle_run_archive dispatches archive operation
  • handle_runs_list passes include_archived / archived_only through to persistence
  • handle_run_get exposes archive_metadata
  • SQLite M13 migration adds is_archived INTEGER DEFAULT 0 and archive_metadata TEXT to runs table (safe ALTER TABLE ADD COLUMN, backward-compatible)
  • list_runs default behavior: excludes archived runs; include_archived=true shows all; archived_only=true shows only archived

MCP gateway (apps/chatgpt-mcp)

  • New ArchiveRunInput Zod schema (runId, reason 1–500 chars)
  • ListRunsInput extended with optional includeArchived / archivedOnly booleans
  • archive_run tool registered (calls run.archive); added to REGISTERED_TOOL_NAMES
  • list_runs tool passes archive filter params to daemon
  • TypeScript remains thin: validation + mapping + daemon calls only

Tests

  • 245 Rust tests (141 core + 102 daemon + 2 protocol), clippy clean
  • 64 TypeScript tests; exact registry set updated to 20 tools
  • Coverage: archive of completed/failed/abandoned runs, rejection of ineligible statuses, metadata roundtrip, audit trail, list filtering, SQLite migration from M12 schema, no-hidden-agent regression
Original prompt

This section details on the original issue you should resolve

<issue_title>Milestone 13: deterministic run archiving and retention controls</issue_title>
<issue_description>## Summary

Implement Milestone 13 for ChatCodex: add deterministic run archiving and retention controls so ChatGPT can explicitly archive runs that should remain preserved but no longer appear in the active working set, without introducing backend autonomy.

This milestone builds on the current system, which already includes:

  • deterministic Rust protocol/core/daemon
  • thin TypeScript MCP gateway
  • minimal coding loop
  • refresh / replan / approval plumbing
  • approval policy hardening
  • deterministic retry/resumption guidance
  • run history, audit trail, and direct state inspection
  • per-run deterministic policy configuration
  • deterministic operation preflight / approval preview
  • deterministic run finalization and outcome recording
  • deterministic run reopening and continuation controls
  • deterministic run supersession and replacement lineage
  • SQLite-backed persistence with migration support
  • milestone-scoped CI

The architecture rule remains absolute:

The only LLM in the stack is ChatGPT.

No backend model calls, no hidden agent loop, and no coarse autonomous tools may be introduced.

Why this milestone

The control plane can now finalize, reopen, and supersede runs, but it still lacks a first-class way to mark old runs as retained history rather than part of the current operational set.

ChatGPT should be able to say things like:

  • archive this completed run so it stays preserved but out of the active list
  • archive this superseded run because it should remain historical only
  • inspect whether a run is archived and when it was archived
  • keep archived runs readable and auditable without allowing silent autonomous behavior

Milestone 13 adds deterministic archival controls so the system can distinguish:

  • active/current runs
  • finalized but still normal runs
  • archived historical runs

This is about lifecycle hygiene and inspectability, not automation.

In scope

1. Deterministic run archiving

Add an explicit lifecycle operation to archive a run.

At minimum:

  • archiving must be explicit
  • archiving must be auditable
  • archiving must not execute work
  • archiving must preserve run state and history
  • archived runs must remain inspectable via existing read-only surfaces

2. Deterministic archiving rules

Define straightforward rules such as:

  • finalized runs may be archived
  • superseded runs may be archived
  • active / prepared / awaiting-approval runs may not be archived
  • reopening or superseding an archived run is either rejected or handled by explicit deterministic rules
  • archiving does not delete the run
  • archiving does not mutate audit history except for the new archive event

A conservative first version is preferred.

3. Structured archive metadata

Persist compact archive metadata such as:

  • archived flag or archived status
  • archive reason
  • archived timestamp
  • archived by lifecycle action type if useful

Keep this compact and deterministic.

4. Authoritative inspection support

Expose archive metadata in:

  • run.get
  • run.refresh where appropriate
  • runs.list
  • run history / audit trail

Archived runs should still be visible when explicitly requested, but listing behavior may distinguish them from non-archived runs.

5. Listing and retention behavior

Improve run-list semantics in a tightly scoped way.

At minimum, support deterministic filtering such as:

  • include archived runs
  • exclude archived runs by default if that is the chosen behavior
  • optionally filter specifically for archived runs

Keep the result model compact and backward-compatible where practical.

6. Audit trail integration

Append a deterministic audit entry such as:

  • run_archived

If helpful, include concise metadata such as archive reason.

7. TypeScript MCP gateway updates

Keep TypeScript thin:

  • add schemas
  • validate inputs
  • call the daemon
  • map responses

Do not move lifecycle logic into TypeScript.

8. SQLite persistence updates

Persist archive metadata with safe, idempotent migration support.

New databases must work immediately.
Older databases must migrate safely and deterministically.

9. Tests and CI

Add milestone-scoped tests for:

  • archiving completed runs
  • archiving failed runs
  • archiving superseded runs if supported
  • rejecting archiving of active/prepared/awaiting-approval runs
  • persistence roundtrip of archive metadata
  • audit trail entry creation
  • list filtering behavior for archived vs non-archived runs
  • migration behavior for new archive fields
  • exact MCP tool registry and daemon method registry
  • no hidden-agent regression

Update CI only as needed for Milestone 13.
Do not broaden CI to the full upstream workspace.

Out of scope

Do not implement:

  • autonomous cleanup
  • background retention jobs
  • automatic archival
  • hard deletion / garbage...

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Co-authored-by: anschmieg <6830368+anschmieg@users.noreply.github.com>
Copilot AI changed the title [WIP] Add deterministic run archiving and retention controls Milestone 13: deterministic run archiving and retention controls Mar 15, 2026
Copilot AI requested a review from anschmieg March 15, 2026 20:13
@anschmieg
anschmieg merged commit 03bf001 into main Mar 15, 2026
@anschmieg
anschmieg deleted the copilot/add-deterministic-run-archiving branch March 15, 2026 20:37
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.

Milestone 13: deterministic run archiving and retention controls

2 participants