Skip to content

fix(P001): pin fire-and-forget task refs in audit_log + phases to prevent GC drop#465

Merged
cirwel merged 1 commit into
masterfrom
claude/auto/20260518-200800-fixp001-pin-fire-and-forget-task-refs-in
May 19, 2026
Merged

fix(P001): pin fire-and-forget task refs in audit_log + phases to prevent GC drop#465
cirwel merged 1 commit into
masterfrom
claude/auto/20260518-200800-fixp001-pin-fire-and-forget-task-refs-in

Conversation

@cirwel
Copy link
Copy Markdown
Owner

@cirwel cirwel commented May 19, 2026

Auto-shipped by ship.sh — runtime path. Auto-merge is enabled; CI gate applies.

…vent GC drop

Per asyncio docs (Python 3.11+): bare loop.create_task(coro) returns a Task that CPython GC can collect mid-await if no caller holds a reference. Three sites in the codebase had this hazard, all flagged by Watcher (#69f2ccbc, #0a0616c2, #acfc7012 — 2026-05-18):

1. src/audit_log.py _write_entry — fire-and-forget PG audit tail. Coroutine awaits asyncpg via append_audit_event_async; GC mid-await would silently drop the row that backs audit.events queries (the same surface §129 reads from).

2. src/mcp_handlers/updates/phases.py — _persist_thread_identity_async (per check-in, high frequency).

3. src/mcp_handlers/updates/phases.py — _persist_inferred_purpose_async (per check-in, high frequency).

All three fixed using the established 'module-local set + add_done_callback' pattern already in src/coordination_failure_emit.py:_inflight_dedicated_writes and src/mcp_handlers/support/pause_ttl.py:_inflight_persistence_tasks. Regression tests in tests/test_p001_task_refs.py pin the pattern at each new helper.

These were pre-existing bugs surfaced during the pause-ttl work (PR #464); they predate that change and live on master. Watcher fingerprints will be resolved against this commit per the audit-trail convention in CLAUDE.md.
@github-actions
Copy link
Copy Markdown

✅ Documentation Validation Passed

Tool Count: 7 tools tools
Version: 2.13.0

All documentation is synchronized with the codebase.

@cirwel cirwel merged commit d6122bc into master May 19, 2026
6 checks passed
@cirwel cirwel deleted the claude/auto/20260518-200800-fixp001-pin-fire-and-forget-task-refs-in branch May 19, 2026 02:25
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.

1 participant