Skip to content

[Bug]: archived-session cleanup does not exclude pinned threads (2.8.0) #858

Description

@GENEXIS-AI

Client or integration

Codex App

Area

CLI

Summary

OpenCodex 2.8.0 archived-session cleanup does not inspect Codex's threads.is_pinned column. An archived pinned task can therefore enter an oldest-percent preview and then be quarantined or permanently removed together with its rollout and satellite rows.

Expected: pinned tasks must be protected independently of archive status, age, percentage target, cleanup mode, and whether cleanup is manual or policy-driven.

This is a source-level safety reproduction. I did not destructively delete a real pinned task.

Reproduction

  1. Inspect the Codex state schema and confirm threads.is_pinned INTEGER NOT NULL DEFAULT 0.
  2. Inspect src/storage/cleanup.ts in OpenCodex 2.8.0.
  3. Follow loadMatchingThreads(): it selects id, rollout_path, optional archived, and optional history_mode, but not is_pinned.
  4. Follow the candidate filter and execution path: archived rollout matches can be staged, snapshotted, and deleted without a pin-state guard.
  5. Search the storage-cleanup path and tests for is_pinned; no cleanup exclusion or execution-time pin re-check is present.

Suggested safety contract:

  • Preview excludes matched rows where is_pinned = 1.
  • Execution re-checks pin state under the same state-DB write lock used to freeze the delete set.
  • If a candidate became pinned after preview, fail closed with a typed stale-preview/pinned result and restore staged files.
  • If the live schema has is_pinned but it cannot be read, fail closed.
  • Older schemas without the column retain compatibility.
  • Add quarantine, permanent, policy, and pin-between-preview-and-execution tests.

Version

2.8.0

Operating system

macOS 26.5.2 (25F84)

Provider and model

Not provider- or model-specific.

Logs or error output

Source-level safety finding; no destructive cleanup command was run against a pinned task.

Screenshots and supporting files

Relevant 2.8.0 source: src/storage/cleanup.ts. The current Codex schema contains is_pinned INTEGER NOT NULL DEFAULT 0.

Redacted configuration

{
  "cleanup_scope": "archived sessions",
  "required_exclusion": "threads.is_pinned = 1"
}

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions