Skip to content

Commit 22cb086

Browse files
Copilotmdheller
andauthored
feat: add workspace operation and operation task contracts
Agent-Logs-Url: https://github.com/SourceOS-Linux/sourceos-syncd/sessions/744c639e-1999-4873-80c6-cbc4b6f037f1 Co-authored-by: mdheller <21163552+mdheller@users.noreply.github.com>
1 parent f9038b5 commit 22cb086

27 files changed

Lines changed: 263 additions & 4 deletions

docs/contracts.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Canonical architecture: `SourceOS-Linux/sourceos-spec/docs/architecture/sourceos-state-integrity-layer.md`
44

5-
This repository implements the first executable contract for SourceOS State Integrity. The current implementation lane is Python and standard-library-first. It provides State Integrity Report generation, diagnosis, verification, non-destructive repair planning, a filesystem-backed local store prototype, an append-only JSONL event log, registry persistence, and contract models for actors, schemas, objects, policy decisions, conflicts, events, profiles, devices, sync plans, and agent object transactions.
5+
This repository implements the first executable contract for SourceOS State Integrity. The current implementation lane is Python and standard-library-first. It provides State Integrity Report generation, diagnosis, verification, non-destructive repair planning, a filesystem-backed local store prototype, an append-only JSONL event log, registry persistence, and contract models for actors, schemas, objects, policy decisions, conflicts, events, profiles, devices, sync plans, workspace operations, operation tasks, and agent object transactions.
66

77
The next daemon phases should extend this baseline into full event-log, policy, profile, repair, service, and adapter subsystems without breaking the current JSON report contracts.
88

@@ -114,6 +114,8 @@ sourceos.conflict-record/v1alpha1
114114
sourceos.policy-decision/v1alpha1
115115
sourceos.integrity-event/v1alpha1
116116
sourceos.agent-object-transaction/v1alpha1
117+
sourceos.workspace-operation/v1alpha1
118+
sourceos.operation-task/v1alpha1
117119
```
118120

119121
Use `validate_contract(record)` to validate a JSON object by its `schema` field. Use the specific dataclass `from_dict()` helpers when callers know the expected type.
@@ -139,6 +141,8 @@ conflict.alpha.json
139141
policy.decision-review.json
140142
event.object-alpha-created.json
141143
agent-transaction.alpha.json
144+
workspace-operation.alpha.json
145+
operation-task.alpha.json
142146
```
143147

144148
The contract test suite loads every fixture, validates it through the model registry, and round-trips each fixture through its dataclass model.
@@ -223,6 +227,18 @@ Agent transaction statuses:
223227
draft, proposed, approved, applied, rejected, reverted
224228
```
225229

230+
Workspace operation types:
231+
232+
```text
233+
sync.operation.enqueue, sync.operation.replay, sync.operation.reconcile, sync.conflict.detect, sync.conflict.resolve, sync.repair.apply, sync.tombstone.apply, sync.checkpoint.write
234+
```
235+
236+
Decision card options:
237+
238+
```text
239+
merge, fork, skip
240+
```
241+
226242
Device states:
227243

228244
```text

examples/contracts/conflict.alpha.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
"schema_version": "v1",
1111
"severity": "review_required",
1212
"merge_policy": "human_review_required",
13+
"decision_card": {
14+
"card_id": "decision-card:conflict-alpha-001",
15+
"options": ["merge", "fork", "skip"],
16+
"recommended_option": "merge",
17+
"selected_option": "fork",
18+
"rationale": "Payload lineage diverged after remote replay; preserve both versions for review.",
19+
"selected_by": "actor:local-user",
20+
"selected_at": "2026-05-05T00:07:30Z"
21+
},
1322
"user_explanation": "Two scoped actors produced competing updates for the same object fixture.",
1423
"created_at": "2026-05-05T00:07:00Z"
1524
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"schema": "sourceos.operation-task/v1alpha1",
3+
"task_id": "operation-task:alpha-0001",
4+
"operation_id": "workspace-operation:alpha-001",
5+
"operation_type": "sync.operation.replay",
6+
"status": "succeeded",
7+
"attempt": 1,
8+
"idempotency_key": "idem-replay-alpha-0001",
9+
"policy_decision_ref": "policy-decision:review-alpha",
10+
"evidence_refs": ["evidence:operation-task-0001"],
11+
"created_at": "2026-05-05T00:10:01Z",
12+
"updated_at": "2026-05-05T00:10:06Z",
13+
"started_at": "2026-05-05T00:10:02Z",
14+
"completed_at": "2026-05-05T00:10:06Z",
15+
"remote_operation_id": "remote-op:9931",
16+
"conflict_id": "conflict:alpha-001",
17+
"checkpoint_ref": "checkpoint:workspace-default-0001",
18+
"replay_safe": true
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"schema": "sourceos.workspace-operation/v1alpha1",
3+
"operation_id": "workspace-operation:alpha-001",
4+
"local_operation_id": "local-op:0001",
5+
"remote_operation_id": "remote-op:9931",
6+
"operation_type": "sync.operation.reconcile",
7+
"status": "reconciled",
8+
"workspace_id": "workspace:default",
9+
"profile_id": "profile:local-dev",
10+
"actor_id": "actor:agent-one",
11+
"device_id": "device:local",
12+
"encryption_profile_ref": "encryption-profile:local-default",
13+
"local_log_ref": "journal:evt-00000001",
14+
"checkpoint_ref": "checkpoint:workspace-default-0001",
15+
"causal_parent_ids": ["local-op:0000"],
16+
"conflict_ids": ["conflict:alpha-001"],
17+
"provisional_artifact_ids": {
18+
"artifact:temp-1": "object:alpha"
19+
},
20+
"artifact_reconciliation": {
21+
"artifact:temp-1": "artifact:final-44"
22+
},
23+
"policy_decision_ref": "policy-decision:review-alpha",
24+
"artifact_admission_ref": "artifact-admission:alpha-allow",
25+
"ledger_evidence_refs": ["evidence:operation-0001"],
26+
"replay_safe": true,
27+
"stale_task": false,
28+
"lease_expired": false,
29+
"replay_idempotency_key": "idem-replay-alpha-0001",
30+
"created_at": "2026-05-05T00:10:00Z",
31+
"updated_at": "2026-05-05T00:10:05Z"
32+
}
289 Bytes
Binary file not shown.
22.6 KB
Binary file not shown.
6.66 KB
Binary file not shown.
23.4 KB
Binary file not shown.
6.53 KB
Binary file not shown.
36 KB
Binary file not shown.

0 commit comments

Comments
 (0)