forked from Dicklesworthstone/pi_agent_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswarm-replay-trace-contract.json
More file actions
427 lines (427 loc) · 12.2 KB
/
Copy pathswarm-replay-trace-contract.json
File metadata and controls
427 lines (427 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
{
"schema": "pi.swarm.replay_trace_contract.v1",
"trace_schema": "pi.swarm.replay_trace.v1",
"contract_version": "1.0.0",
"bead_id": "bd-in57w.1",
"parent_bead_id": "bd-in57w",
"purpose": "offline_swarm_replay_trace_contract_not_live_control",
"summary": "Defines the canonical replay trace contract and source inventory for an offline swarm replay lab. The trace is evidence for simulation and policy comparison only; it must not mutate Beads, Agent Mail, git, RCH jobs, reservations, or live build slots.",
"non_goals": [
"replace_beads_or_agent_mail_as_sources_of_truth",
"replace_live_swarm_autopilot_or_operator_runpacks",
"claim_release_performance_without_existing_claim_gates",
"infer_missing_timeline_facts_without_uncertainty_markers",
"emit_unredacted_prompts_tokens_credentials_or_mail_bodies",
"perform_live_mutation_during_replay"
],
"required_trace_top_level_keys": [
"schema",
"trace_id",
"generated_at",
"contract_version",
"source_inventory",
"ordering",
"events",
"redaction_summary",
"uncertainty_summary",
"replay_guards"
],
"source_inventory_contract": {
"required_source_ids": [
"beads_jsonl",
"beads_db",
"agent_mail_archive",
"doctor_swarm_diagnostics",
"rch_queue_status",
"operator_runpack",
"git_refs",
"validation_command_records",
"context_intelligence_evidence",
"swarm_flight_recorder",
"swarm_activity_ledger"
],
"required_source_fields": [
"source_id",
"source_kind",
"path",
"availability",
"freshness_state",
"source_hash",
"redaction_state",
"authoritative_for",
"uncertainty"
],
"allowed_availability": [
"available",
"unavailable",
"partial",
"malformed",
"stale"
],
"allowed_freshness_states": [
"current",
"stale",
"missing",
"malformed",
"freshness_unknown"
],
"unavailable_source_policy": "Unavailable sources remain inventory rows with explicit uncertainty; replay may continue only when remaining authoritative sources cover the requested event classes and the missing source cannot be silently inferred."
},
"event_contract": {
"required_event_types": [
"bead_lifecycle",
"reservation_intent",
"reservation_conflict",
"agent_message",
"build_slot_state",
"rch_job_state",
"cargo_gate_result",
"worktree_state",
"doctor_finding",
"runpack_recommendation",
"validation_artifact",
"operator_handoff"
],
"required_event_fields": [
"event_id",
"sequence",
"occurred_at_utc",
"observed_at_utc",
"event_type",
"actor",
"source_ref",
"source_hash",
"redaction_state",
"uncertainty",
"payload"
],
"required_uncertainty_fields": [
"state",
"reasons",
"suppressed_claims"
],
"event_type_contracts": [
{
"event_type": "bead_lifecycle",
"authoritative_sources": [
"beads_jsonl",
"beads_db"
],
"required_payload_fields": [
"bead_id",
"from_status",
"to_status",
"priority",
"assignee"
]
},
{
"event_type": "reservation_intent",
"authoritative_sources": [
"agent_mail_archive"
],
"required_payload_fields": [
"reservation_id",
"path_patterns",
"exclusive",
"ttl_seconds",
"reason"
]
},
{
"event_type": "reservation_conflict",
"authoritative_sources": [
"agent_mail_archive"
],
"required_payload_fields": [
"path_pattern",
"holder",
"conflict_reason"
]
},
{
"event_type": "agent_message",
"authoritative_sources": [
"agent_mail_archive"
],
"required_payload_fields": [
"thread_id",
"sender",
"recipients",
"importance",
"ack_required"
]
},
{
"event_type": "build_slot_state",
"authoritative_sources": [
"agent_mail_archive"
],
"required_payload_fields": [
"slot",
"holder",
"state",
"expires_at_utc"
]
},
{
"event_type": "rch_job_state",
"authoritative_sources": [
"rch_queue_status"
],
"required_payload_fields": [
"job_id",
"state",
"worker",
"command",
"queue_position"
]
},
{
"event_type": "cargo_gate_result",
"authoritative_sources": [
"validation_command_records"
],
"required_payload_fields": [
"command",
"runner",
"exit_code",
"target_dir",
"tmpdir"
]
},
{
"event_type": "worktree_state",
"authoritative_sources": [
"git_refs"
],
"required_payload_fields": [
"head",
"branch",
"dirty",
"changed_paths"
]
},
{
"event_type": "doctor_finding",
"authoritative_sources": [
"doctor_swarm_diagnostics"
],
"required_payload_fields": [
"finding_id",
"severity",
"surface",
"status"
]
},
{
"event_type": "runpack_recommendation",
"authoritative_sources": [
"operator_runpack"
],
"required_payload_fields": [
"action",
"severity",
"evidence_paths",
"operator_notes"
]
},
{
"event_type": "validation_artifact",
"authoritative_sources": [
"validation_command_records",
"context_intelligence_evidence",
"swarm_flight_recorder",
"swarm_activity_ledger"
],
"required_payload_fields": [
"artifact_path",
"artifact_schema",
"verdict",
"command"
]
},
{
"event_type": "operator_handoff",
"authoritative_sources": [
"operator_runpack",
"swarm_activity_ledger"
],
"required_payload_fields": [
"handoff_id",
"summary",
"next_actions",
"evidence_paths"
]
}
]
},
"ordering_contract": {
"monotonic_sequence_required": true,
"timestamp_normalization": "utc_rfc3339_z",
"required_ordering_fields": [
"sequence",
"occurred_at_utc",
"observed_at_utc"
],
"tie_breakers": [
"sequence",
"source_ref",
"event_id"
],
"out_of_order_policy": "Keep the raw observed timestamps, preserve monotonic sequence order, and mark uncertainty.state as uncertain when source timestamps conflict."
},
"redaction_policy": {
"fail_closed": true,
"allowed_redaction_states": [
"none",
"redacted",
"sensitive_omitted",
"unsafe_to_emit"
],
"required_redaction_fields": [
"redaction_state",
"redacted_fields",
"redaction_reason"
],
"sensitive_fields": [
"authorization",
"body",
"cookie",
"prompt",
"registration_token",
"secret",
"token",
"transcript"
]
},
"uncertainty_policy": {
"fail_closed": true,
"allowed_uncertainty_states": [
"certain",
"inferred",
"partial",
"missing_source",
"malformed_source",
"uncertain"
],
"suppressed_claim_policy": "Any metric, latency, ownership, or coordination claim that depends on a missing, stale, malformed, or unavailable source must be listed in uncertainty.suppressed_claims instead of emitted as fact."
},
"replay_guards": {
"read_only": true,
"no_live_mutation": true,
"no_network_required": true,
"fail_closed_on_missing_required_sources": true,
"requires_source_inventory": true,
"disallowed_live_actions": [
"claim_bead",
"close_bead",
"send_agent_mail",
"reserve_file",
"release_file",
"acquire_build_slot",
"cancel_rch_job",
"git_commit",
"git_push"
]
},
"overlap_boundaries": [
{
"existing_surface": "swarm_autopilot",
"boundary": "Replay trace may compare dry-run decisions offline, but it must not replace live autopilot input packs, planner guards, or operator execution."
},
{
"existing_surface": "resource_governor_and_flight_recorder",
"boundary": "Replay trace may consume resource and flight-recorder events, but it must not reimplement live admission control or claim fresh performance evidence."
},
{
"existing_surface": "context_intelligence",
"boundary": "Replay trace may reference context-intelligence evidence freshness, but it must not serve file contents or bypass freshness and redaction gates."
},
{
"existing_surface": "operator_runpack",
"boundary": "Replay trace may ingest runpack recommendations, but the runpack remains an operator handoff summary and not a source of release claims."
}
],
"contract_test_fixtures": [
{
"fixture_id": "agent_mail_unavailable_beads_rch_doctor_usable",
"path": "tests/fixtures/swarm_replay_trace/agent_mail_unavailable_trace.json",
"must_prove": [
"agent_mail_archive source remains explicit and unavailable",
"beads_jsonl source remains available for bead_lifecycle events",
"rch_queue_status source remains available for rch_job_state events",
"doctor_swarm_diagnostics source remains available for doctor_finding events",
"claims requiring Agent Mail are suppressed rather than inferred"
]
},
{
"fixture_id": "source_inventory_scenario_suite",
"path": "tests/fixtures/swarm_replay_trace/source_inventory_scenarios.json",
"must_prove": [
"source inventory scenarios include unavailable-source and malformed-source cases",
"Agent Mail unavailable does not block Beads, RCH, or Doctor evidence",
"malformed RCH input suppresses queue-depth and admission claims",
"raw secret bytes emitted stays zero in replay fixtures"
]
}
],
"downstream_dependencies": {
"unblocked_beads": [
"bd-in57w.2",
"bd-in57w.3",
"bd-in57w.12"
]
},
"must_requirements": [
{
"id": "REPLAY-TRACE-MUST-001",
"description": "The contract declares the canonical replay trace schema, version, Beads linkage, and non-live-control purpose.",
"validated_by": [
"schema",
"trace_schema",
"bead_id",
"purpose"
]
},
{
"id": "REPLAY-TRACE-MUST-002",
"description": "The source inventory names every authoritative artifact family needed by replay and records availability, freshness, hashes, redaction, and uncertainty.",
"validated_by": [
"source_inventory_contract.required_source_ids",
"source_inventory_contract.required_source_fields"
]
},
{
"id": "REPLAY-TRACE-MUST-003",
"description": "Every required replay event type has explicit authoritative sources and payload fields.",
"validated_by": [
"event_contract.required_event_types",
"event_contract.event_type_contracts"
]
},
{
"id": "REPLAY-TRACE-MUST-004",
"description": "Replay order uses monotonic sequence numbers with UTC timestamp normalization and deterministic tie breakers.",
"validated_by": [
"ordering_contract"
]
},
{
"id": "REPLAY-TRACE-MUST-005",
"description": "Redaction and uncertainty policies fail closed, and unavailable Agent Mail data suppresses dependent claims instead of inventing coordination facts.",
"validated_by": [
"redaction_policy",
"uncertainty_policy",
"contract_test_fixtures"
]
},
{
"id": "REPLAY-TRACE-MUST-006",
"description": "Replay guards forbid live mutation of Beads, Agent Mail, git, RCH jobs, reservations, and build slots.",
"validated_by": [
"replay_guards.disallowed_live_actions"
]
}
]
}