blun-king-cli 9.1.65 → 9.1.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LIESMICH.txt +8 -1
- package/README.md +8 -1
- package/bin/curiosity-scout-policy.cjs +45 -0
- package/blun.mjs +50 -3
- package/package.json +1 -1
- package/standard-skills/venture-flywheel/SKILL.md +28 -0
- package/standard-skills/venture-flywheel/identity/project-identity.cjs +146 -0
- package/standard-skills/venture-flywheel/policy/capability-engine.cjs +114 -0
- package/standard-skills/venture-flywheel/policy/repository-trust.cjs +229 -0
- package/standard-skills/venture-flywheel/references/CAPABILITY-MAP.md +34 -0
- package/standard-skills/venture-flywheel/references/SPEC-phase0-identity-trust.md +77 -0
- package/standard-skills/venture-flywheel/references/SPEC-phase0-state-events.md +93 -0
- package/standard-skills/venture-flywheel/schemas/capability-decision.schema.json +13 -0
- package/standard-skills/venture-flywheel/schemas/execution-event.schema.json +44 -0
- package/standard-skills/venture-flywheel/schemas/project-identity.schema.json +32 -0
- package/standard-skills/venture-flywheel/schemas/repository-trust.schema.json +57 -0
- package/standard-skills/venture-flywheel/schemas/run-transition.schema.json +59 -0
- package/standard-skills/venture-flywheel/state/execution-event.cjs +191 -0
- package/standard-skills/venture-flywheel/state/task-state-machine.cjs +190 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const TRUST_LEVELS = Object.freeze([
|
|
4
|
+
'UNTRUSTED',
|
|
5
|
+
'TRUSTED_LOCAL',
|
|
6
|
+
'TRUSTED_DEPLOY',
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
const CAPABILITIES = Object.freeze([
|
|
10
|
+
'deploy.production',
|
|
11
|
+
'network.external',
|
|
12
|
+
'network.none',
|
|
13
|
+
'network.registry.read',
|
|
14
|
+
'repo.metadata.read',
|
|
15
|
+
'repo.read',
|
|
16
|
+
'sandbox.execute',
|
|
17
|
+
'workspace.write',
|
|
18
|
+
'worktree.create',
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const BASE_CAPABILITIES = Object.freeze([
|
|
22
|
+
'network.none',
|
|
23
|
+
'repo.metadata.read',
|
|
24
|
+
'repo.read',
|
|
25
|
+
]);
|
|
26
|
+
const LOCAL_CAPABILITIES = Object.freeze([
|
|
27
|
+
...BASE_CAPABILITIES,
|
|
28
|
+
'sandbox.execute',
|
|
29
|
+
'workspace.write',
|
|
30
|
+
'worktree.create',
|
|
31
|
+
].sort());
|
|
32
|
+
const TRUST_CEILINGS = Object.freeze({
|
|
33
|
+
UNTRUSTED: BASE_CAPABILITIES,
|
|
34
|
+
TRUSTED_LOCAL: LOCAL_CAPABILITIES,
|
|
35
|
+
TRUSTED_DEPLOY: CAPABILITIES,
|
|
36
|
+
});
|
|
37
|
+
const TRUST_FIELDS = new Set([
|
|
38
|
+
'project_id',
|
|
39
|
+
'account_id',
|
|
40
|
+
'trust_level',
|
|
41
|
+
'version',
|
|
42
|
+
'granted_capabilities',
|
|
43
|
+
'denied_capabilities',
|
|
44
|
+
'last_event_id',
|
|
45
|
+
]);
|
|
46
|
+
const REQUEST_FIELDS = new Set([
|
|
47
|
+
'event_id',
|
|
48
|
+
'expected_version',
|
|
49
|
+
'from_trust_level',
|
|
50
|
+
'to_trust_level',
|
|
51
|
+
'granted_capabilities',
|
|
52
|
+
'denied_capabilities',
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
function uvfError(code, message) {
|
|
56
|
+
const error = new Error(message);
|
|
57
|
+
error.code = code;
|
|
58
|
+
return error;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function isRecord(value) {
|
|
62
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function requireText(value, field, code = 'UVF_INVALID_TRUST_RECORD') {
|
|
66
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
67
|
+
throw uvfError(code, `${field} must be a non-empty string`);
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function assertKnownFields(value, allowed, label, code) {
|
|
73
|
+
const unknown = Object.keys(value).filter((field) => !allowed.has(field));
|
|
74
|
+
if (unknown.length > 0) {
|
|
75
|
+
throw uvfError(code, `unknown ${label} fields: ${unknown.sort().join(', ')}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function validateCapabilityList(value, field, code) {
|
|
80
|
+
if (!Array.isArray(value)) throw uvfError(code, `${field} must be an array`);
|
|
81
|
+
const unique = new Set();
|
|
82
|
+
for (const capability of value) {
|
|
83
|
+
if (typeof capability !== 'string' || !CAPABILITIES.includes(capability)) {
|
|
84
|
+
throw uvfError(code, `${field} contains an unknown capability: ${String(capability)}`);
|
|
85
|
+
}
|
|
86
|
+
if (unique.has(capability)) throw uvfError(code, `${field} contains a duplicate: ${capability}`);
|
|
87
|
+
unique.add(capability);
|
|
88
|
+
}
|
|
89
|
+
return [...unique].sort();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function validatePartition(grantedInput, deniedInput, code) {
|
|
93
|
+
const granted = validateCapabilityList(grantedInput, 'granted_capabilities', code);
|
|
94
|
+
const denied = validateCapabilityList(deniedInput, 'denied_capabilities', code);
|
|
95
|
+
const combined = [...granted, ...denied];
|
|
96
|
+
if (new Set(combined).size !== CAPABILITIES.length
|
|
97
|
+
|| [...new Set(combined)].sort().some((capability, index) => capability !== CAPABILITIES[index])) {
|
|
98
|
+
throw uvfError(code, 'capability grants and denials must form a complete non-overlapping partition');
|
|
99
|
+
}
|
|
100
|
+
return { granted, denied };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function validateProjectIdentity(identity) {
|
|
104
|
+
if (!isRecord(identity)) throw uvfError('UVF_INVALID_PROJECT_IDENTITY', 'project identity must be an object');
|
|
105
|
+
requireText(identity.project_id, 'project_id', 'UVF_INVALID_PROJECT_IDENTITY');
|
|
106
|
+
requireText(identity.account_id, 'account_id', 'UVF_INVALID_PROJECT_IDENTITY');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function validateTrustRecord(trust) {
|
|
110
|
+
if (!isRecord(trust)) throw uvfError('UVF_INVALID_TRUST_RECORD', 'repository trust must be an object');
|
|
111
|
+
assertKnownFields(trust, TRUST_FIELDS, 'trust', 'UVF_INVALID_TRUST_RECORD');
|
|
112
|
+
requireText(trust.project_id, 'project_id');
|
|
113
|
+
requireText(trust.account_id, 'account_id');
|
|
114
|
+
if (!TRUST_LEVELS.includes(trust.trust_level)) {
|
|
115
|
+
throw uvfError('UVF_INVALID_TRUST_RECORD', `unknown trust level: ${String(trust.trust_level)}`);
|
|
116
|
+
}
|
|
117
|
+
if (!Number.isSafeInteger(trust.version) || trust.version < 0) {
|
|
118
|
+
throw uvfError('UVF_INVALID_TRUST_RECORD', 'version must be a non-negative integer');
|
|
119
|
+
}
|
|
120
|
+
if (trust.last_event_id !== null) requireText(trust.last_event_id, 'last_event_id');
|
|
121
|
+
const partition = validatePartition(
|
|
122
|
+
trust.granted_capabilities,
|
|
123
|
+
trust.denied_capabilities,
|
|
124
|
+
'UVF_INVALID_TRUST_RECORD',
|
|
125
|
+
);
|
|
126
|
+
const ceiling = new Set(TRUST_CEILINGS[trust.trust_level]);
|
|
127
|
+
const excessive = partition.granted.filter((capability) => !ceiling.has(capability));
|
|
128
|
+
if (excessive.length > 0) {
|
|
129
|
+
throw uvfError(
|
|
130
|
+
'UVF_CAPABILITY_TRUST_VIOLATION',
|
|
131
|
+
`${trust.trust_level} cannot grant: ${excessive.join(', ')}`,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return partition;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function createRepositoryTrust(projectIdentity) {
|
|
138
|
+
validateProjectIdentity(projectIdentity);
|
|
139
|
+
const granted = [...BASE_CAPABILITIES].sort();
|
|
140
|
+
return Object.freeze({
|
|
141
|
+
project_id: projectIdentity.project_id,
|
|
142
|
+
account_id: projectIdentity.account_id,
|
|
143
|
+
trust_level: 'UNTRUSTED',
|
|
144
|
+
version: 0,
|
|
145
|
+
granted_capabilities: Object.freeze(granted),
|
|
146
|
+
denied_capabilities: Object.freeze(CAPABILITIES.filter((capability) => !granted.includes(capability))),
|
|
147
|
+
last_event_id: null,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function validateTransitionRequest(request) {
|
|
152
|
+
if (!isRecord(request)) {
|
|
153
|
+
throw uvfError('UVF_INVALID_TRUST_REQUEST', 'trust transition request must be an object');
|
|
154
|
+
}
|
|
155
|
+
assertKnownFields(request, REQUEST_FIELDS, 'trust transition', 'UVF_INVALID_TRUST_REQUEST');
|
|
156
|
+
requireText(request.event_id, 'event_id', 'UVF_INVALID_TRUST_REQUEST');
|
|
157
|
+
if (!Number.isSafeInteger(request.expected_version) || request.expected_version < 0) {
|
|
158
|
+
throw uvfError('UVF_INVALID_TRUST_REQUEST', 'expected_version must be a non-negative integer');
|
|
159
|
+
}
|
|
160
|
+
for (const field of ['from_trust_level', 'to_trust_level']) {
|
|
161
|
+
if (!TRUST_LEVELS.includes(request[field])) {
|
|
162
|
+
throw uvfError('UVF_INVALID_TRUST_REQUEST', `unknown ${field}: ${String(request[field])}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return validatePartition(
|
|
166
|
+
request.granted_capabilities,
|
|
167
|
+
request.denied_capabilities,
|
|
168
|
+
'UVF_INVALID_TRUST_REQUEST',
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function transitionRepositoryTrust(current, request) {
|
|
173
|
+
validateTrustRecord(current);
|
|
174
|
+
const partition = validateTransitionRequest(request);
|
|
175
|
+
if (request.expected_version !== current.version) {
|
|
176
|
+
throw uvfError(
|
|
177
|
+
'UVF_TRUST_VERSION_CONFLICT',
|
|
178
|
+
`expected version ${request.expected_version}, current version ${current.version}`,
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (request.from_trust_level !== current.trust_level) {
|
|
182
|
+
throw uvfError(
|
|
183
|
+
'UVF_TRUST_STATE_CONFLICT',
|
|
184
|
+
`expected trust level ${request.from_trust_level}, current level ${current.trust_level}`,
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
const fromIndex = TRUST_LEVELS.indexOf(current.trust_level);
|
|
188
|
+
const toIndex = TRUST_LEVELS.indexOf(request.to_trust_level);
|
|
189
|
+
if (toIndex === fromIndex || toIndex > fromIndex + 1) {
|
|
190
|
+
throw uvfError(
|
|
191
|
+
'UVF_INVALID_TRUST_TRANSITION',
|
|
192
|
+
`transition ${current.trust_level} -> ${request.to_trust_level} is not allowed`,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const ceiling = new Set(TRUST_CEILINGS[request.to_trust_level]);
|
|
197
|
+
const excessive = partition.granted.filter((capability) => !ceiling.has(capability));
|
|
198
|
+
if (excessive.length > 0) {
|
|
199
|
+
throw uvfError(
|
|
200
|
+
'UVF_CAPABILITY_TRUST_VIOLATION',
|
|
201
|
+
`${request.to_trust_level} cannot grant: ${excessive.join(', ')}`,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
const missingBase = BASE_CAPABILITIES.filter((capability) => !partition.granted.includes(capability));
|
|
205
|
+
if (missingBase.length > 0) {
|
|
206
|
+
throw uvfError(
|
|
207
|
+
'UVF_CAPABILITY_TRUST_VIOLATION',
|
|
208
|
+
`trust records must retain baseline capabilities: ${missingBase.join(', ')}`,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return Object.freeze({
|
|
213
|
+
project_id: current.project_id,
|
|
214
|
+
account_id: current.account_id,
|
|
215
|
+
trust_level: request.to_trust_level,
|
|
216
|
+
version: current.version + 1,
|
|
217
|
+
granted_capabilities: Object.freeze(partition.granted),
|
|
218
|
+
denied_capabilities: Object.freeze(partition.denied),
|
|
219
|
+
last_event_id: request.event_id,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
module.exports = {
|
|
224
|
+
CAPABILITIES,
|
|
225
|
+
TRUST_LEVELS,
|
|
226
|
+
TRUST_CEILINGS,
|
|
227
|
+
createRepositoryTrust,
|
|
228
|
+
transitionRepositoryTrust,
|
|
229
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Capability Map: Universal Venture Flywheel
|
|
2
|
+
|
|
3
|
+
Source direction: UVF-Core RFC 2.0.0. This map keeps each rollout phase
|
|
4
|
+
independently testable and prevents the advisor, executor, and deployment gate
|
|
5
|
+
from becoming one authority.
|
|
6
|
+
|
|
7
|
+
| Module id | Responsibility | Depends on |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| contracts-trust | Schemas, project scope, trust, capabilities, event log, state machine | - |
|
|
10
|
+
| venture-advisor | Read-only discovery, metrics, baselines, proposals, strategic-authority bridge | contracts-trust |
|
|
11
|
+
| local-execution | Leases, isolated worktrees, sandbox, scoped execution, verification bundles | contracts-trust, venture-advisor |
|
|
12
|
+
| approval-deployment | Exact-state approval, adapter preflight, idempotency, staging, rollback | contracts-trust, local-execution |
|
|
13
|
+
| observation | Post-deployment metrics, guardrails, attribution, inconclusive outcomes | contracts-trust, approval-deployment |
|
|
14
|
+
| controlled-learning | Effectiveness history and human-approved bounded adaptation | observation |
|
|
15
|
+
|
|
16
|
+
Build order:
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
contracts-trust
|
|
20
|
+
-> venture-advisor
|
|
21
|
+
-> local-execution
|
|
22
|
+
-> approval-deployment
|
|
23
|
+
-> observation
|
|
24
|
+
-> controlled-learning
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The first implementation slice inside `contracts-trust` is `state-events`:
|
|
28
|
+
canonical run transitions plus a hash-linked, secret-rejecting event envelope.
|
|
29
|
+
It has no execution capability.
|
|
30
|
+
|
|
31
|
+
The second slice is `identity-trust`: deterministic project identity from
|
|
32
|
+
repository facts plus authenticated host context, explicit repository trust
|
|
33
|
+
transitions, and deny-by-default capability decisions. It is also side-effect
|
|
34
|
+
free and grants no execution path by itself.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Spec: UVF Phase 0 Identity, Trust, and Capability Contracts
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
|
|
5
|
+
Provide a deterministic policy boundary before any UVF repository action.
|
|
6
|
+
Project identity combines observed repository facts with a separately supplied
|
|
7
|
+
authenticated host context. Repository trust starts at `UNTRUSTED`, changes
|
|
8
|
+
only through versioned explicit transitions, and partitions every known
|
|
9
|
+
capability into granted or denied. Capability evaluation fails closed.
|
|
10
|
+
|
|
11
|
+
This slice does not inspect a repository, execute a command, create a worktree,
|
|
12
|
+
open a network connection, persist trust, or approve an external action.
|
|
13
|
+
|
|
14
|
+
## Public Contracts
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
const identity = deriveProjectIdentity(repositoryFacts, authenticatedHostContext);
|
|
18
|
+
const trust = createRepositoryTrust(identity);
|
|
19
|
+
const nextTrust = transitionRepositoryTrust(trust, request);
|
|
20
|
+
const decision = evaluateCapability({
|
|
21
|
+
project_identity: identity,
|
|
22
|
+
repository_trust: nextTrust,
|
|
23
|
+
capability: 'sandbox.execute',
|
|
24
|
+
execution_scope: 'isolated_worktree',
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Repository facts cannot contain an account, user, or owner identity. The
|
|
29
|
+
authenticated account enters only through the second argument. Equivalent SSH
|
|
30
|
+
and HTTPS remotes produce the same canonical repository identity.
|
|
31
|
+
|
|
32
|
+
## Trust Levels
|
|
33
|
+
|
|
34
|
+
- `UNTRUSTED`: metadata and repository reads only.
|
|
35
|
+
- `TRUSTED_LOCAL`: explicit local capabilities may run later, but write and
|
|
36
|
+
execution capabilities require an isolated worktree.
|
|
37
|
+
- `TRUSTED_DEPLOY`: external capabilities may be requested, but they return
|
|
38
|
+
`approval_required`; this contract never approves them.
|
|
39
|
+
|
|
40
|
+
Upgrades are sequential. Downgrades may return directly to a lower trust level.
|
|
41
|
+
Every transition checks `expected_version`, records an event ID, and supplies a
|
|
42
|
+
complete non-overlapping grant/deny partition for the known capability set.
|
|
43
|
+
|
|
44
|
+
## Commands
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
node --test test/venture-flywheel-trust.test.js
|
|
48
|
+
node --check standard-skills/venture-flywheel/identity/project-identity.cjs
|
|
49
|
+
node --check standard-skills/venture-flywheel/policy/repository-trust.cjs
|
|
50
|
+
node --check standard-skills/venture-flywheel/policy/capability-engine.cjs
|
|
51
|
+
npm test
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Testing Strategy
|
|
55
|
+
|
|
56
|
+
- Equivalent repository observations must derive the same identity.
|
|
57
|
+
- A different authenticated account must derive a different project ID.
|
|
58
|
+
- Identity fields injected into repository facts must be rejected.
|
|
59
|
+
- Unknown repositories may read but cannot write, execute, or use network.
|
|
60
|
+
- Forged grants above a trust ceiling remain denied.
|
|
61
|
+
- Local write and execution require an isolated worktree.
|
|
62
|
+
- External and irreversible capabilities never return `allow`.
|
|
63
|
+
- Stale or skipped trust upgrades are rejected.
|
|
64
|
+
- Schemas are strict and all modules remain free of I/O primitives.
|
|
65
|
+
|
|
66
|
+
## Success Criteria
|
|
67
|
+
|
|
68
|
+
- Cross-account and cross-project evaluations fail closed.
|
|
69
|
+
- Capability decisions are one of `allow`, `deny`, or `approval_required`.
|
|
70
|
+
- Every known capability appears exactly once in a trust record.
|
|
71
|
+
- Exported collections and returned records are deeply immutable.
|
|
72
|
+
- Focused mutation probes and the complete package suite are green.
|
|
73
|
+
|
|
74
|
+
## Boundary
|
|
75
|
+
|
|
76
|
+
Persistence, repository detection, command execution, worktree creation,
|
|
77
|
+
network adapters, approval issuance, and deployment remain later slices.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Spec: UVF Phase 0 State and Event Contracts
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
|
|
5
|
+
Provide the smallest deterministic foundation that makes every UVF run state
|
|
6
|
+
transition auditable. The module rejects illegal and stale transitions, gates
|
|
7
|
+
terminal states on required evidence, creates hash-linked event envelopes, and
|
|
8
|
+
rejects secret-shaped audit payloads.
|
|
9
|
+
|
|
10
|
+
This slice does not execute commands, inspect repositories, write event files,
|
|
11
|
+
open network connections, or expose a user-facing UVF command.
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
Focused test:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
node --test test/venture-flywheel-state.test.js
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Full suite:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
npm test
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Syntax checks:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
node --check standard-skills/venture-flywheel/state/task-state-machine.cjs
|
|
31
|
+
node --check standard-skills/venture-flywheel/state/execution-event.cjs
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Project Structure
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
standard-skills/venture-flywheel/
|
|
38
|
+
SKILL.md
|
|
39
|
+
references/
|
|
40
|
+
schemas/run-transition.schema.json
|
|
41
|
+
schemas/execution-event.schema.json
|
|
42
|
+
state/task-state-machine.cjs
|
|
43
|
+
state/execution-event.cjs
|
|
44
|
+
test/venture-flywheel-state.test.js
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Code Style
|
|
48
|
+
|
|
49
|
+
CommonJS, pure functions, frozen exported contracts, explicit machine-readable
|
|
50
|
+
error codes, no hidden I/O:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
const next = transitionRun(current, {
|
|
54
|
+
event_id: 'evt_01J...',
|
|
55
|
+
expected_version: current.version,
|
|
56
|
+
from_state: current.state,
|
|
57
|
+
to_state: 'profiled',
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Testing Strategy
|
|
62
|
+
|
|
63
|
+
- Small unit tests cover the canonical path and every guard direction.
|
|
64
|
+
- Mutation-style red probes attempt transition skipping, stale writes, missing
|
|
65
|
+
completion evidence, broken hash links, event mutation, and secret payloads.
|
|
66
|
+
- The standard-skill bootstrap test proves the contract ships with BLUN King.
|
|
67
|
+
- The full package suite protects unrelated console behavior.
|
|
68
|
+
|
|
69
|
+
## Boundaries
|
|
70
|
+
|
|
71
|
+
- Always: validate inputs strictly, reject unknown states and fields, preserve
|
|
72
|
+
deterministic hashes, keep transitions side-effect free.
|
|
73
|
+
- Ask first: change canonical transition topology, add persistence, expose a
|
|
74
|
+
CLI/MCP command, or connect repository identity.
|
|
75
|
+
- Never: execute repository code, grant capabilities, perform external action,
|
|
76
|
+
include secrets in audit data, or infer approval from an event.
|
|
77
|
+
|
|
78
|
+
## Success Criteria
|
|
79
|
+
|
|
80
|
+
- The documented canonical forward path is accepted.
|
|
81
|
+
- An illegal jump and a stale optimistic version are rejected.
|
|
82
|
+
- `completed` requires final evidence and `rolled_back` requires rollback
|
|
83
|
+
evidence.
|
|
84
|
+
- Every accepted transition increments the version and records its event ID.
|
|
85
|
+
- Event hashes are deterministic and a mutation or broken link is detected.
|
|
86
|
+
- Secret-shaped fields are rejected recursively before hashing.
|
|
87
|
+
- JSON schemas reject unknown top-level fields.
|
|
88
|
+
- Focused tests and the complete package suite are green.
|
|
89
|
+
|
|
90
|
+
## Open Questions
|
|
91
|
+
|
|
92
|
+
None inside this slice. Persistence, project identity, trust grants, and the
|
|
93
|
+
full schema set remain later `contracts-trust` tasks.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://blun.ai/schemas/uvf/capability-decision.schema.json",
|
|
4
|
+
"title": "UVF Capability Decision",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["capability", "decision", "reason"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"capability": { "type": "string", "minLength": 1 },
|
|
10
|
+
"decision": { "enum": ["allow", "deny", "approval_required"] },
|
|
11
|
+
"reason": { "type": "string", "minLength": 1 }
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://blun.ai/schemas/uvf/execution-event.schema.json",
|
|
4
|
+
"title": "UVF Execution Event",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"event_id",
|
|
9
|
+
"run_id",
|
|
10
|
+
"project_id",
|
|
11
|
+
"actor",
|
|
12
|
+
"event_type",
|
|
13
|
+
"occurred_at",
|
|
14
|
+
"payload",
|
|
15
|
+
"previous_event_hash",
|
|
16
|
+
"event_hash"
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"event_id": { "type": "string", "minLength": 1 },
|
|
20
|
+
"run_id": { "type": "string", "minLength": 1 },
|
|
21
|
+
"project_id": { "type": "string", "minLength": 1 },
|
|
22
|
+
"actor": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"additionalProperties": false,
|
|
25
|
+
"required": ["type", "id", "session_id"],
|
|
26
|
+
"properties": {
|
|
27
|
+
"type": { "enum": ["agent", "user", "system"] },
|
|
28
|
+
"id": { "type": "string", "minLength": 1 },
|
|
29
|
+
"session_id": { "type": "string", "minLength": 1 }
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"event_type": { "type": "string", "minLength": 1 },
|
|
33
|
+
"occurred_at": { "type": "string", "format": "date-time" },
|
|
34
|
+
"payload": { "type": "object" },
|
|
35
|
+
"previous_event_hash": {
|
|
36
|
+
"type": ["string", "null"],
|
|
37
|
+
"pattern": "^sha256:[a-f0-9]{64}$"
|
|
38
|
+
},
|
|
39
|
+
"event_hash": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"pattern": "^sha256:[a-f0-9]{64}$"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://blun.ai/schemas/uvf/project-identity.schema.json",
|
|
4
|
+
"title": "UVF Project Identity",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["project_id", "account_id", "repository"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"project_id": { "type": "string", "pattern": "^project:sha256:[a-f0-9]{64}$" },
|
|
10
|
+
"account_id": { "type": "string", "minLength": 1 },
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"required": [
|
|
15
|
+
"host",
|
|
16
|
+
"owner",
|
|
17
|
+
"name",
|
|
18
|
+
"canonical_remote_url",
|
|
19
|
+
"local_repository_root",
|
|
20
|
+
"initial_repository_fingerprint"
|
|
21
|
+
],
|
|
22
|
+
"properties": {
|
|
23
|
+
"host": { "type": "string", "minLength": 1 },
|
|
24
|
+
"owner": { "type": "string", "minLength": 1 },
|
|
25
|
+
"name": { "type": "string", "minLength": 1 },
|
|
26
|
+
"canonical_remote_url": { "type": "string", "pattern": "^https://" },
|
|
27
|
+
"local_repository_root": { "type": "string", "minLength": 1 },
|
|
28
|
+
"initial_repository_fingerprint": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://blun.ai/schemas/uvf/repository-trust.schema.json",
|
|
4
|
+
"title": "UVF Repository Trust",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"project_id",
|
|
9
|
+
"account_id",
|
|
10
|
+
"trust_level",
|
|
11
|
+
"version",
|
|
12
|
+
"granted_capabilities",
|
|
13
|
+
"denied_capabilities",
|
|
14
|
+
"last_event_id"
|
|
15
|
+
],
|
|
16
|
+
"properties": {
|
|
17
|
+
"project_id": { "type": "string", "pattern": "^project:sha256:[a-f0-9]{64}$" },
|
|
18
|
+
"account_id": { "type": "string", "minLength": 1 },
|
|
19
|
+
"trust_level": { "enum": ["UNTRUSTED", "TRUSTED_LOCAL", "TRUSTED_DEPLOY"] },
|
|
20
|
+
"version": { "type": "integer", "minimum": 0 },
|
|
21
|
+
"granted_capabilities": {
|
|
22
|
+
"type": "array",
|
|
23
|
+
"uniqueItems": true,
|
|
24
|
+
"items": {
|
|
25
|
+
"enum": [
|
|
26
|
+
"deploy.production",
|
|
27
|
+
"network.external",
|
|
28
|
+
"network.none",
|
|
29
|
+
"network.registry.read",
|
|
30
|
+
"repo.metadata.read",
|
|
31
|
+
"repo.read",
|
|
32
|
+
"sandbox.execute",
|
|
33
|
+
"workspace.write",
|
|
34
|
+
"worktree.create"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"denied_capabilities": {
|
|
39
|
+
"type": "array",
|
|
40
|
+
"uniqueItems": true,
|
|
41
|
+
"items": {
|
|
42
|
+
"enum": [
|
|
43
|
+
"deploy.production",
|
|
44
|
+
"network.external",
|
|
45
|
+
"network.none",
|
|
46
|
+
"network.registry.read",
|
|
47
|
+
"repo.metadata.read",
|
|
48
|
+
"repo.read",
|
|
49
|
+
"sandbox.execute",
|
|
50
|
+
"workspace.write",
|
|
51
|
+
"worktree.create"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"last_event_id": { "type": ["string", "null"], "minLength": 1 }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://blun.ai/schemas/uvf/run-transition.schema.json",
|
|
4
|
+
"title": "UVF Run Transition",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"event_id",
|
|
9
|
+
"expected_version",
|
|
10
|
+
"from_state",
|
|
11
|
+
"to_state"
|
|
12
|
+
],
|
|
13
|
+
"$defs": {
|
|
14
|
+
"state": {
|
|
15
|
+
"enum": [
|
|
16
|
+
"discovered",
|
|
17
|
+
"profiled",
|
|
18
|
+
"configured",
|
|
19
|
+
"baseline_measured",
|
|
20
|
+
"observing",
|
|
21
|
+
"evidence_ready",
|
|
22
|
+
"proposal_created",
|
|
23
|
+
"selected_by_strategic_authority",
|
|
24
|
+
"approved_for_local_execution",
|
|
25
|
+
"executing_local",
|
|
26
|
+
"verifying",
|
|
27
|
+
"blocked",
|
|
28
|
+
"aborted",
|
|
29
|
+
"no_action",
|
|
30
|
+
"locally_verified",
|
|
31
|
+
"completed_local",
|
|
32
|
+
"waiting_approval",
|
|
33
|
+
"denied",
|
|
34
|
+
"expired",
|
|
35
|
+
"approved_exact_state",
|
|
36
|
+
"deploying",
|
|
37
|
+
"post_deploy_observation",
|
|
38
|
+
"attribution_pending",
|
|
39
|
+
"completed",
|
|
40
|
+
"rolled_back",
|
|
41
|
+
"inconclusive"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"properties": {
|
|
46
|
+
"event_id": { "type": "string", "minLength": 1 },
|
|
47
|
+
"expected_version": { "type": "integer", "minimum": 0 },
|
|
48
|
+
"from_state": { "$ref": "#/$defs/state" },
|
|
49
|
+
"to_state": { "$ref": "#/$defs/state" },
|
|
50
|
+
"evidence": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"additionalProperties": false,
|
|
53
|
+
"properties": {
|
|
54
|
+
"final_evidence_id": { "type": "string", "minLength": 1 },
|
|
55
|
+
"rollback_evidence_id": { "type": "string", "minLength": 1 }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|