Skip to content

Commit b1bd117

Browse files
authored
Add agentic graph contract validation and repo scanner
Adds the first sourceosctl tooling slice for the SourceOS/SociOS local-first agentic graph foundation. Includes: - .sourceos/manifest.json for sourceos-devtools - contract validate, repo scan, estate scan, graph doctor, sync doctor, and policy explain helpers - entrypoint routing for new command groups - tests for manifest validation and repo scanning - integration documentation for M1 contract validation Related: SourceOS-Linux/sourceos-spec#86, SourceOS-Linux/sourceos-spec#94, #18
1 parent 9cfd13f commit b1bd117

5 files changed

Lines changed: 525 additions & 0 deletions

File tree

.sourceos/manifest.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"repo": "SourceOS-Linux/sourceos-devtools",
3+
"domain": "tooling",
4+
"specVersion": "0.1.0",
5+
"ownedSchemas": [],
6+
"syncEngines": [],
7+
"sourceChannels": [],
8+
"policyClasses": [
9+
"high"
10+
],
11+
"auditEvents": [
12+
"devtools.contract.validated",
13+
"devtools.repo.scanned"
14+
],
15+
"dangerousSurfaces": [
16+
"devtools.schema.validation_bypass",
17+
"devtools.repo_scan.incomplete"
18+
],
19+
"authorityRepos": [
20+
"SourceOS-Linux/sourceos-spec"
21+
],
22+
"notes": "Developer/operator tooling surface for SourceOS contract validation, repo scanning, graph doctor, sync doctor, and policy explanation commands."
23+
}

bin/sourceosctl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,36 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
99
# Lightweight plugin routing for newer command groups while keeping the core
1010
# argparse surface stable. These command groups are non-mutating plan/probe
1111
# surfaces and own their own subparsers.
12+
if len(sys.argv) > 1 and sys.argv[1] == "contract":
13+
from sourceosctl.commands.contracts import contract_main
14+
15+
sys.exit(contract_main(sys.argv[2:]))
16+
17+
if len(sys.argv) > 1 and sys.argv[1] == "repo":
18+
from sourceosctl.commands.contracts import repo_main
19+
20+
sys.exit(repo_main(sys.argv[2:]))
21+
22+
if len(sys.argv) > 1 and sys.argv[1] == "estate":
23+
from sourceosctl.commands.contracts import estate_main
24+
25+
sys.exit(estate_main(sys.argv[2:]))
26+
27+
if len(sys.argv) > 1 and sys.argv[1] == "graph":
28+
from sourceosctl.commands.contracts import graph_main
29+
30+
sys.exit(graph_main(sys.argv[2:]))
31+
32+
if len(sys.argv) > 1 and sys.argv[1] == "sync":
33+
from sourceosctl.commands.contracts import sync_main
34+
35+
sys.exit(sync_main(sys.argv[2:]))
36+
37+
if len(sys.argv) > 1 and sys.argv[1] == "policy":
38+
from sourceosctl.commands.contracts import policy_main
39+
40+
sys.exit(policy_main(sys.argv[2:]))
41+
1242
if len(sys.argv) > 1 and sys.argv[1] == "network":
1343
from sourceosctl.commands.network import network_main
1444

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Agentic Graph Contract Validation
2+
3+
Status: draft
4+
Related spec: `SourceOS-Linux/sourceos-spec#94`
5+
Related tracker: `SourceOS-Linux/sourceos-spec#86`
6+
7+
## Purpose
8+
9+
This document defines the first `sourceosctl` tooling slice for the SourceOS/SociOS local-first agentic graph foundation.
10+
11+
The M1 objective is intentionally bounded: validate `.sourceos/manifest.json`, scan repos for contract posture, and provide non-mutating doctor/explain commands before runtime sync, agent, browser, shell, or relay integrations begin.
12+
13+
## Commands
14+
15+
### Validate a contract file
16+
17+
```bash
18+
python3 bin/sourceosctl contract validate .sourceos/manifest.json
19+
python3 bin/sourceosctl contract validate .sourceos/manifest.json --json
20+
```
21+
22+
The first validator pass checks JSON parseability and the minimum `SourceOSRepoManifest` shape.
23+
24+
### Scan one repo
25+
26+
```bash
27+
python3 bin/sourceosctl repo scan .
28+
python3 bin/sourceosctl repo scan . --json
29+
```
30+
31+
The repo scanner checks for `.sourceos/manifest.json` and reports whether it is compliant, missing, or invalid.
32+
33+
### Scan an estate root
34+
35+
```bash
36+
python3 bin/sourceosctl estate scan ~/dev
37+
python3 bin/sourceosctl estate scan ~/dev --json
38+
```
39+
40+
The estate scanner checks immediate child repos for `.sourceos/manifest.json` and reports each repo status.
41+
42+
### Inspect graph/sync posture
43+
44+
```bash
45+
python3 bin/sourceosctl graph doctor
46+
python3 bin/sourceosctl sync doctor
47+
```
48+
49+
These are non-mutating posture probes. Runtime graph and sync backends are not configured in `sourceos-devtools` yet.
50+
51+
### Explain a policy/audit JSON file
52+
53+
```bash
54+
python3 bin/sourceosctl policy explain path/to/decision-or-audit.json
55+
```
56+
57+
This prints the available decision/outcome, reason, policy ID, and policy domain fields.
58+
59+
## M1 validation statuses
60+
61+
The scanner uses these status classes:
62+
63+
- `compliant`
64+
- `missing-manifest`
65+
- `invalid-manifest`
66+
67+
Future hardening should add:
68+
69+
- `partial`
70+
- `missing-required-engine`
71+
- `missing-policy-class`
72+
- `missing-audit-events`
73+
- `schema-version-mismatch`
74+
- `authority-repo-mismatch`
75+
76+
## Current limitations
77+
78+
- The validator is dependency-light and does not yet perform full JSON Schema draft 2020-12 validation.
79+
- Schema loading from `SourceOS-Linux/sourceos-spec` is not yet vendored or pinned.
80+
- Estate scanning currently checks immediate child directories only.
81+
- Runtime SourceGraph, SourceSync, SourcePolicy, and SourceChannel backends are not configured in this repo.
82+
83+
## Acceptance criteria for this slice
84+
85+
1. `sourceos-devtools` declares a `.sourceos/manifest.json`.
86+
2. `sourceosctl contract validate` can validate the local manifest shape.
87+
3. `sourceosctl repo scan` can classify a repo manifest.
88+
4. `sourceosctl estate scan` can classify child repos with manifests.
89+
5. `sourceosctl graph doctor`, `sourceosctl sync doctor`, and `sourceosctl policy explain` are present and non-mutating.
90+
6. Tests cover manifest validation, repo scan, and doctor commands.

0 commit comments

Comments
 (0)