docs: resolve run lifecycle audit

This commit is contained in:
2026-07-10 03:16:05 +08:00
parent 682bc70563
commit ec630b9151
10 changed files with 365 additions and 3 deletions
@@ -1,7 +1,7 @@
# Audit run lifecycle and data integrity under failure
Type: research
Status: open
Status: resolved
## Question
@@ -10,3 +10,29 @@ database failure, or concurrent requests, which AgentRun, lock, session,
workspace, audit, and outbound-message invariants can be violated or leave work
lost, duplicated, or permanently stuck?
## Answer
The happy path and database lock uniqueness work, but the lifecycle is not
crash-safe. Deterministic fault injection confirmed permanent inbound loss,
terminal runs retaining locks, active runs losing locks, duplicate active
sessions, completion without outbound delivery, unconstrained audit run IDs,
and max-turn termination being stored as failure. Process-local queues,
non-transactional startup recovery, unused leases, silent audit/history writes,
and direct workspace mutation add restart and indefinite-hang failure modes.
The complete contract mapping, eight fault probes, recovery analysis, and
required release evidence are in the
[run lifecycle and data-integrity audit](../assets/run-lifecycle-integrity-audit.md).
The newly-clear implementation and decision frontier is:
- [Make Feishu intake and queued work durable](23-durable-feishu-inbox-and-queue.md)
- [Make run, session, lock, and recovery transitions safe](24-transactional-run-lock-recovery.md)
- [Make outbound Feishu delivery durable and idempotent](25-durable-outbound-delivery.md)
- [Decide workspace commit semantics for failed runs](26-decide-workspace-run-commit-semantics.md)
- [Reconcile the audit and run-history contract](27-reconcile-audit-history-contract.md)
Execution-time authorization remains owned by
[Bind and reauthorize deferred and card actions](18-bind-and-reauthorize-deferred-actions.md),
while cross-component metrics, alerts, and operator runbooks remain owned by
[Define production observability and incident recovery](04-define-observability-recovery.md).
@@ -2,7 +2,7 @@
Type: task
Status: open
Blocked by: 01, 02, 03, 04, 05, 06, 07, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
Blocked by: 01, 02, 03, 04, 05, 06, 07, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27
## Question
@@ -2,7 +2,7 @@
Type: task
Status: open
Blocked by: 03, 04, 10, 11, 12
Blocked by: 03, 04, 10, 11, 12, 23, 24, 25
## Question
@@ -0,0 +1,13 @@
# Make Feishu intake and queued work durable
Type: task
Status: open
## Question
Replace receipt-before-success and process-local batching/queueing with one
durable inbound work lifecycle that atomically claims duplicate events, records
processing/completion/failure, survives restart, retries recoverable failures,
and proves concurrent redelivery cannot duplicate a run or silently lose an
accepted prompt. Preserve execution-time authorization from ticket 18 when
deferred work is finally started.
@@ -0,0 +1,12 @@
# Make run, session, lock, and recovery transitions safe
Type: task
Status: open
## Question
Implement and fault-test a centralized AgentRun lifecycle that enforces one
active project/provider/role/model session, serializes provider-cursor updates,
preserves the ADR-0002 lock invariant across every database failure, applies a
real wall deadline and renewable lease, reconciles every non-terminal state on
startup/watchdog, and cannot let a second Hub process invalidate live work.
@@ -0,0 +1,12 @@
# Make outbound Feishu delivery durable and idempotent
Type: task
Status: open
## Question
Give status cards, final responses, files, and recovery notices a durable
outbox/delivery lifecycle with stable idempotency keys, provider message IDs,
bounded retry and reconciliation, so model completion is distinguishable from
pending/failed/delivered user-visible output and an operator can safely replay
ambiguous failures without duplicates.
@@ -0,0 +1,13 @@
# Decide workspace commit semantics for failed runs
Type: grilling
Status: open
## Question
When an agent run fails, is canceled, times out, loses the database, or is
killed mid-tool, should its workspace changes remain as partial collaborative
work, be quarantined for review, or roll back atomically? Decide the contract,
including the relationship among provider cursor, AgentMessage,
AgentFileChange, git/filesystem state, and the next run, then create the
smallest implementation tickets and crash tests that enforce it.
@@ -0,0 +1,13 @@
# Reconcile the audit and run-history contract
Type: grilling
Status: open
Blocked by: 04
## Question
Separate or unify run-bound audit entries, pre-run security/permission events,
structured messages, and operational recovery events without weakening
`Spec.System.Audit`'s pinned AuditEntry-to-run relation. Decide durability,
failure, retention, and query semantics; then enforce referential integrity and
observable/recoverable writes instead of silently swallowing lost evidence.