Your objective is to correct background CocoPod completion timestamps from authoritative transcript queue records.
Inputs
Accept direct arguments or a queued request from .cocoplus/v2-runtime-requests.jsonl:
transcript_pathflow_state(default.cocoplus/lifecycle/flow-state.json)idempotency_key
Timestamp Precedence
Use transcript-derived completion records as the strongest source:
completed_atfrom a terminal transcript recordtimestampfrom a terminal transcript recordenqueued_atonly when no completion timestamp exists- existing hook/tool-result timing as fallback
Do not overwrite transcript-derived timestamps with hook timing. If a pod already has completion_source: "enqueue_record" and completion_timestamp_reliable: true, preserve it unless a newer transcript record for the same pod has an explicit terminal completed_at.
Procedure
- Read the existing flow-state JSON if present; otherwise start with
{ "pods": [] }. - Read the transcript JSONL line by line.
- Identify queue/subagent completion records using named fields only:
subagent_id,pod_id,agent_id, ortask_idstatus,event, ortypecompleted_at,timestamp, orenqueued_at
- For each terminal completion event (
completed,failed,exited,cancelled), update the matching pod record:completed_atcompletion_source: "enqueue_record"completion_timestamp_reliable: true
- If a pod has only hook/tool-result timing, preserve it but mark:
completion_source: "tool_result_fallback"completion_timestamp_reliable: false
- Write
flow_stateatomically.
Queue Settlement
When invoked from .cocoplus/v2-runtime-requests.jsonl, follow execution-engine/runtime-queue:
- Claim the request using
idempotency_keyor a derived key fromtranscript_pathandflow_state. - Reconcile the flow-state file.
- Append
completedsettlement withartifact: flow_state. - Append
failedif the transcript cannot be read orflow_statecannot be written.
Output
Report:
CocoFlow completion events reconciled.
Pods corrected: <N>
Fallback records retained: <N>
Flow state: <path>
Exit Criteria
- Transcript-derived completion records set
completion_source. - Fallback records are explicitly marked unreliable.
- The flow-state file remains valid JSON.
- Queued requests are settled and can be replayed without duplicating state changes.
Anti-Rationalization
| Shortcut / Temptation | Why It Fails |
|---|---|
| Treat the skill as complete because the file exists | Skill contracts must describe observable behavior and verification, not just command names. |
| Skip artifact and safety checks for a small command | Small commands still mutate state or guide execution; preserve the same gates. |