[sweep] strip Fxxx audit-ID tokens + trim bloated comments/docstrings + add behavior-change docs

Post-audit sweep over the 135 audit-fix commits since 19a474d3:

1. Stripped every # Fxxx: audit-ID token from comments AND every Fxxx token
   from docstring openings across 211 blocks / ~626 lines. The CEO flagged
   these twice: audit-issue IDs in code confuse future devs/agents. The
   descriptive text is preserved; only the Fxxx token is removed (and bloated
   narrative blocks trimmed to 1-3 lines keeping the one non-obvious invariant).
2. Trimmed bloated comments/docstrings to the concise standard (1-3 lines).
3. Added missing behavior-change docs for the audit-fix batch: prompts/roles
   (documenter, pr_reviewer, qa), user-facing docs (api auth, websockets,
   agent-gateway, megatask, merge-model, task-lifecycle, grok, resilience,
   conventions, panel, security, troubleshooting), and the RAG corpus (cell-pm,
   main-pm, pr-reviewer, qa roles; conventions; messaging-tools; escalation;
   megatask; task-claiming workflows).

Comment/docstring/prose ONLY — zero code-line edits (verified: the diff
contains no def/class/return/if/for/await/assignment/call lines). Gates green:
ruff format + ruff check clean, mypy clean on roboco/. The only pytest failures
are the pre-existing sync_branch tracing-decision gap (B1, 250be5c2) — not
sweep-caused and tracked separately.
This commit is contained in:
Renn F
2026-06-29 01:25:40 +02:00
parent fb850e8235
commit 3441e37120
131 changed files with 842 additions and 1391 deletions
+10 -28
View File
@@ -1,32 +1,14 @@
"""F125 — the delegate sibling-dedup guard had a read/write TOCTOU.
"""The delegate sibling-dedup guard is serialized by a PostgreSQL
transaction-scoped advisory lock keyed by the parent task id, acquired at the
TOP of the delegate body (before the first ``get_subtasks`` read) and held
through ``create_subtask``'s flush + the outer request commit. Different
parents hash to different keys (seed ``1``, disjoint from the per-agent claim
lock's seed ``0``) so cross-parent delegates are not serialized.
``_delegate_sibling_dedup_guard`` reads the parent's existing subtasks via an
unlocked ``get_subtasks`` SELECT (the dedup read), then the verb body calls
``create_subtask`` (the write) — with no DB serialization between the two. Two
concurrent ``delegate`` calls for the SAME parent (a PM re-delegating while a
stale-heartbeat reaper unclaims + re-dispatches, or two orchestrator ticks
racing) each read an empty/duplicate-free sibling set, each pass the dedup
guard, and each create a subtask → the parent gets the duplicate the guard
exists to prevent (the smoke-run runaway pattern the guard was built for).
The fix: a PostgreSQL transaction-scoped advisory lock keyed by the parent
task id, acquired at the TOP of the delegate body — before the first
``get_subtasks`` read (the briefing's context read AND the dedup guard's
sibling read) and held through ``create_subtask``'s flush + the outer request
commit. The second concurrent same-parent delegate blocks on the lock until
the first commits; its dedup read then sees the first's committed sibling and
is rejected. Different parents hash to different keys (seed ``1``, disjoint
from the per-agent claim lock's seed ``0``) so cross-parent delegates are not
serialized — the PM coordinator concurrency feature (parallel root planning)
is preserved.
CRITICAL logical-regression guard: the lock is per-PARENT, not per-agent. A
single cell_pm / main_pm legitimately delegates many subtasks under one parent
in quick succession (a per-dev sequenced queue), and a coordinator PM plans
many roots in parallel. A per-agent lock would serialize all of a PM's
delegates and regress coordinator concurrency; a per-parent lock serializes
only same-parent delegates (the actual dedup invariant is per-parent) and
leaves different parents untouched.
CRITICAL regression guard: the lock is per-PARENT, not per-agent. A per-agent
lock would serialize all of a coordinator PM's delegates and regress
coordinator concurrency; the dedup invariant is per-parent, so only same-parent
delegates serialize.
"""
from __future__ import annotations