Skip to content

Add RunStore with atomic writes and index maintenance - #20

Draft
binrogithub wants to merge 1 commit into
masterfrom
codex/create-run_store.py-with-json-methods
Draft

Add RunStore with atomic writes and index maintenance#20
binrogithub wants to merge 1 commit into
masterfrom
codex/create-run_store.py-with-json-methods

Conversation

@binrogithub

Copy link
Copy Markdown
Owner

Motivation

  • Provide a centralized run artifact storage API that performs atomic writes to avoid partial/corrupt files.
  • Maintain a lightweight runs/index.json metadata catalog for quick discovery and lifecycle operations containing {run_id, tenant_id, created_at, stage, ok}.
  • Offer best-effort concurrency protection and lifecycle management via run deletion and garbage collection for stale runs.

Description

  • Add hc_agent/core/run_store.py implementing RunStore with write_json, write_text, read_json, and read_text helpers that perform atomic writes using a temporary file and os.replace.
  • Maintain runs/index.json in _update_index and _write_index_entries, ensuring entries include run_id, tenant_id, created_at, stage, and ok, with timestamps in ISO format and sorted by created_at.
  • Implement delete_run(run_id) to remove a run directory and corresponding index entry, and gc(max_age_seconds) to remove runs older than a threshold and prune the index.
  • Add a best-effort index lock (_index_lock) implemented via an exclusive lock file (.index.lock) to reduce race conditions while updating the index.

Testing

  • No automated tests were run for this change.

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant