Skip to content

Commit fd8702d

Browse files
committed
Document local store and registry CLI contracts
1 parent c7e228e commit fd8702d

1 file changed

Lines changed: 93 additions & 11 deletions

File tree

docs/contracts.md

Lines changed: 93 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
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, and non-destructive repair planning.
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, and registry persistence for early actor/schema/object/profile/device state.
66

7-
The next daemon phases should extend this baseline into actor, schema, object, event-log, policy, profile, and repair subsystems without breaking the current JSON report contracts.
7+
The next daemon phases should extend this baseline into full actor, schema, object, event-log, policy, profile, and repair subsystems without breaking the current JSON report contracts.
88

99
## Contract Principles
1010

@@ -15,6 +15,7 @@ The next daemon phases should extend this baseline into actor, schema, object, e
1515
- Policy denials, conflicts, transport failures, degraded indexes, and repair-needed states must not collapse into generic errors.
1616
- Agent writes must eventually be attributable to registered actors.
1717
- Downstream surfaces should consume reports/events, not scrape raw daemon logs.
18+
- Read paths must not silently initialize, reset, or repair local state.
1819

1920
## Current CLI Commands
2021

@@ -23,13 +24,91 @@ The current repo implementation exposes:
2324
```bash
2425
sourceos-syncd health snapshot
2526
sourceos-syncd health snapshot --compact
27+
sourceos-syncd health snapshot --store-root ./state --compact
2628
sourceos-syncd health explain --file examples/health/healthy.snapshot.json
2729
sourceos-syncd health verify --file examples/health/healthy.snapshot.json
2830
sourceos-syncd repair plan --file examples/health/degraded.snapshot.json
2931
```
3032

3133
The current commands are intentionally read-only or preview-only. `repair plan` emits a plan; it does not mutate state.
3234

35+
## Local Store CLI Commands
36+
37+
The filesystem-backed prototype adds explicit store commands:
38+
39+
```bash
40+
sourceos-syncd store init --root ./state
41+
sourceos-syncd store record --root ./state --event-type add --lane normal --object-id object:alpha --producer manual --payload-json '{}'
42+
sourceos-syncd store put-record --root ./state --kind actors --record-id actor:agent-one --record-json '{"actor_id":"actor:agent-one","actor_type":"agent"}'
43+
sourceos-syncd store get-record --root ./state --kind actors --record-id actor:agent-one
44+
sourceos-syncd store list-records --root ./state --kind actors
45+
```
46+
47+
Supported registry kinds:
48+
49+
- `profiles`
50+
- `devices`
51+
- `actors`
52+
- `schemas`
53+
- `objects`
54+
- `indexes`
55+
- `repair-reports`
56+
57+
## Local Store Layout
58+
59+
The MVP filesystem store uses this layout:
60+
61+
```text
62+
<store-root>/
63+
manifest.json
64+
journal.jsonl
65+
profiles/
66+
devices/
67+
actors/
68+
schemas/
69+
objects/
70+
events/
71+
repair-reports/
72+
indexes/
73+
checkpoints/
74+
tmp/
75+
```
76+
77+
Durable directories:
78+
79+
- `profiles`
80+
- `devices`
81+
- `actors`
82+
- `schemas`
83+
- `objects`
84+
- `events`
85+
- `repair-reports`
86+
87+
Rebuildable directories:
88+
89+
- `indexes`
90+
- `checkpoints`
91+
92+
Disposable directories:
93+
94+
- `tmp`
95+
96+
## Current Registry Record Schemas
97+
98+
Registry writes assign default schemas when a record does not already provide one:
99+
100+
```text
101+
profiles -> sourceos.profile-record/v1alpha1
102+
devices -> sourceos.device-record/v1alpha1
103+
actors -> sourceos.actor-record/v1alpha1
104+
schemas -> sourceos.schema-record/v1alpha1
105+
objects -> sourceos.object-record/v1alpha1
106+
indexes -> sourceos.index-record/v1alpha1
107+
repair-reports -> sourceos.repair-report/v1alpha1
108+
```
109+
110+
Registry records are JSON objects written atomically as individual files. The MVP intentionally avoids opaque database behavior until the contract is stable.
111+
33112
## Intended CLI Commands
34113

35114
The README tracks the intended larger CLI surface:
@@ -83,16 +162,19 @@ The current Python implementation defines these contract families:
83162
- diagnosis
84163
- controls
85164
- attestation
165+
- local store metadata
166+
- append-only journal events
167+
- registry records
86168

87169
## Next Model Families
88170

89171
The next implementation phase should add first-class contracts for:
90172

91-
- actor records
173+
- richer actor records
92174
- source objects
93175
- schema contracts
94176
- sync plans
95-
- conflicts
177+
- conflict records
96178
- policy decisions
97179
- canonical integrity events
98180
- repair reports tied to durable/rebuildable/disposable state
@@ -101,14 +183,14 @@ The next implementation phase should add first-class contracts for:
101183

102184
## MVP Persistence Boundary
103185

104-
The next implementation phase should add persistence in this order:
186+
The next implementation phase should deepen persistence in this order:
105187

106-
1. local config/profile/device discovery
107-
2. local append-only event log
108-
3. actor registry
109-
4. schema registry
110-
5. object registry
111-
6. derived index classification
188+
1. formal local config/profile/device discovery
189+
2. stronger append-only event log checksums
190+
3. actor registry validation
191+
4. schema registry validation and migrations
192+
5. object registry validation
193+
6. derived index classification and rebuild reports
112194
7. dry-run repair of a derived index
113195
8. policy decision adapter
114196
9. workspace/file object adapter

0 commit comments

Comments
 (0)