owlrunkit 0.16.1 → 0.17.0

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.
Files changed (25) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +48 -9
  3. package/docs/architecture/OWLCODA_RUNKIT_017_AGENT_NATIVE_PRODUCT_DEFINITION.md +154 -0
  4. package/integrations/codex/skills/owlcoda-runkit/SKILL.md +59 -14
  5. package/integrations/codex/skills/owlcoda-runkit/assets/templates/config.json +3 -3
  6. package/package.json +1 -1
  7. package/packages/attest/distribution-manifest-v1.json +5 -0
  8. package/packages/attest/src/quick.mjs +5 -0
  9. package/registry-release-policy-v1.json +5 -5
  10. package/sbom.spdx.json +5 -5
  11. package/scripts/runkit-contract/core-contract.mjs +12 -2
  12. package/scripts/runkit-contract/formal-workflow.mjs +201 -0
  13. package/scripts/runkit-contract/lifecycle-orchestration.mjs +7 -2
  14. package/scripts/runkit-contract/runkit-cli.mjs +99 -8
  15. package/scripts/runkit-contract/schemas/team-project-definition-v1.schema.json +108 -0
  16. package/scripts/runkit-contract/schemas/team-project-event-v1.schema.json +99 -0
  17. package/scripts/runkit-contract/schemas/team-project-status-v1.schema.json +50 -0
  18. package/scripts/runkit-contract/schemas/verification-envelope-v1.schema.json +102 -0
  19. package/scripts/runkit-contract/sync-release-identity.mjs +224 -0
  20. package/scripts/runkit-contract/team-project.mjs +1006 -0
  21. package/scripts/runkit-contract/templates/team-project-definition.json +30 -0
  22. package/scripts/runkit-contract/templates/team-project-event.json +9 -0
  23. package/scripts/runkit-contract/templates/verification-envelope.json +28 -0
  24. package/scripts/runkit-contract/verification-envelope-check.mjs +45 -0
  25. package/scripts/runkit-contract/verification-envelope.mjs +846 -0
@@ -0,0 +1,50 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://owlcoda.com/schemas/runkit/team-project-status-v1.schema.json",
4
+ "title": "OwlCoda RunKit Team Project Status V1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "status", "projectId", "objective", "overall", "counts", "milestones", "workstreams", "workItems", "agents", "readyQueue", "criticalWorkItems", "openDecisions", "resolvedDecisions", "integrationGates", "dataCandidates", "projectTruthHash", "authorizationGranted", "exitCode"],
8
+ "properties": {
9
+ "schemaVersion": { "const": "OwlCodaRunKitTeamProjectStatusV1" },
10
+ "status": { "const": "team_project_status" },
11
+ "projectId": { "type": "string", "minLength": 1 },
12
+ "objective": { "type": "string", "minLength": 1 },
13
+ "overall": { "enum": ["planned", "active", "active_with_blockers", "completed"] },
14
+ "counts": { "type": "object" },
15
+ "milestones": { "type": "array", "items": { "type": "object" } },
16
+ "workstreams": { "type": "array", "items": { "type": "object" } },
17
+ "workItems": { "type": "array", "items": { "type": "object" } },
18
+ "agents": { "type": "array", "items": { "type": "object" } },
19
+ "readyQueue": { "type": "array", "items": { "type": "string" } },
20
+ "criticalWorkItems": { "type": "array", "items": { "type": "string" } },
21
+ "openDecisions": { "type": "array", "items": { "type": "object" } },
22
+ "resolvedDecisions": { "type": "array", "items": { "type": "object" } },
23
+ "integrationGates": { "type": "array", "items": { "type": "object" } },
24
+ "dataCandidates": { "type": "array", "items": { "type": "object" } },
25
+ "projectTruthHash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
26
+ "authorizationGranted": { "const": false },
27
+ "exitCode": { "const": 0 }
28
+ },
29
+ "examples": [{
30
+ "schemaVersion": "OwlCodaRunKitTeamProjectStatusV1",
31
+ "status": "team_project_status",
32
+ "projectId": "release-017",
33
+ "objective": "Ship OwlRunKit 0.17",
34
+ "overall": "active",
35
+ "counts": {},
36
+ "milestones": [],
37
+ "workstreams": [],
38
+ "workItems": [],
39
+ "agents": [],
40
+ "readyQueue": [],
41
+ "criticalWorkItems": [],
42
+ "openDecisions": [],
43
+ "resolvedDecisions": [],
44
+ "integrationGates": [],
45
+ "dataCandidates": [],
46
+ "projectTruthHash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
47
+ "authorizationGranted": false,
48
+ "exitCode": 0
49
+ }]
50
+ }
@@ -0,0 +1,102 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://owlcoda.com/schemas/runkit/verification-envelope-v1.schema.json",
4
+ "title": "OwlCoda RunKit Verification Envelope V1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "envelopeId", "cwd", "lockfiles", "paths", "environment", "network", "process", "phases"],
8
+ "properties": {
9
+ "schemaVersion": { "const": "OwlCodaRunKitVerificationEnvelopeV1" },
10
+ "envelopeId": { "$ref": "#/$defs/id" },
11
+ "cwd": { "type": "string", "minLength": 1 },
12
+ "lockfiles": { "$ref": "#/$defs/strings" },
13
+ "paths": {
14
+ "type": "object",
15
+ "additionalProperties": false,
16
+ "required": ["immutableSource", "declaredOutput", "disposableScratch", "forbidden"],
17
+ "properties": {
18
+ "immutableSource": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
19
+ "declaredOutput": { "$ref": "#/$defs/strings" },
20
+ "disposableScratch": { "$ref": "#/$defs/strings" },
21
+ "forbidden": { "$ref": "#/$defs/strings" }
22
+ }
23
+ },
24
+ "environment": {
25
+ "type": "object",
26
+ "additionalProperties": false,
27
+ "required": ["allowNames", "values"],
28
+ "properties": {
29
+ "allowNames": { "$ref": "#/$defs/strings" },
30
+ "values": { "type": "object" }
31
+ }
32
+ },
33
+ "network": {
34
+ "type": "object",
35
+ "additionalProperties": false,
36
+ "required": ["mode"],
37
+ "properties": { "mode": { "enum": ["deny", "loopback"] } }
38
+ },
39
+ "process": {
40
+ "type": "object",
41
+ "additionalProperties": false,
42
+ "required": ["allowSubprocesses", "allowedExecutables", "allowBackgroundAfterFinish"],
43
+ "properties": {
44
+ "allowSubprocesses": { "type": "boolean" },
45
+ "allowedExecutables": { "$ref": "#/$defs/strings" },
46
+ "allowBackgroundAfterFinish": { "const": false }
47
+ }
48
+ },
49
+ "phases": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "required": ["setup", "check", "teardown"],
53
+ "properties": {
54
+ "setup": { "oneOf": [{ "$ref": "#/$defs/command" }, { "type": "null" }] },
55
+ "check": { "$ref": "#/$defs/command" },
56
+ "teardown": { "oneOf": [{ "$ref": "#/$defs/command" }, { "type": "null" }] }
57
+ }
58
+ }
59
+ },
60
+ "$defs": {
61
+ "id": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$" },
62
+ "strings": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
63
+ "command": {
64
+ "type": "object",
65
+ "additionalProperties": false,
66
+ "required": ["executable", "argv", "timeoutMs"],
67
+ "properties": {
68
+ "executable": { "type": "string", "minLength": 1 },
69
+ "argv": { "type": "array", "items": { "type": "string" } },
70
+ "timeoutMs": { "type": "integer", "minimum": 100, "maximum": 3600000 }
71
+ }
72
+ }
73
+ },
74
+ "examples": [{
75
+ "schemaVersion": "OwlCodaRunKitVerificationEnvelopeV1",
76
+ "envelopeId": "quality-v1",
77
+ "cwd": ".",
78
+ "lockfiles": ["package-lock.json"],
79
+ "paths": {
80
+ "immutableSource": ["src/**", "tests/**", "package-lock.json"],
81
+ "declaredOutput": ["dist/**", "coverage/**"],
82
+ "disposableScratch": [".tmp/**"],
83
+ "forbidden": [".env", ".ssh/**", ".owlcoda/**"]
84
+ },
85
+ "environment": { "allowNames": ["PATH"], "values": {} },
86
+ "network": { "mode": "deny" },
87
+ "process": {
88
+ "allowSubprocesses": false,
89
+ "allowedExecutables": [],
90
+ "allowBackgroundAfterFinish": false
91
+ },
92
+ "phases": {
93
+ "setup": null,
94
+ "check": {
95
+ "executable": "/absolute/path/to/node",
96
+ "argv": ["tests/run.mjs"],
97
+ "timeoutMs": 120000
98
+ },
99
+ "teardown": null
100
+ }
101
+ }]
102
+ }
@@ -0,0 +1,224 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ readFileSync,
5
+ renameSync,
6
+ writeFileSync,
7
+ } from "node:fs";
8
+ import path from "node:path";
9
+ import { fileURLToPath } from "node:url";
10
+
11
+ import { currentCoreIdentity } from "./core-contract.mjs";
12
+
13
+ const RELEASE_FILES = Object.freeze({
14
+ packageManifest: "packages/runkit/package.json",
15
+ attestManifest: "packages/attest/distribution-manifest-v1.json",
16
+ attestRuntime: "packages/attest/src/quick.mjs",
17
+ skillMarkdown: "integrations/codex/skills/owlcoda-runkit/SKILL.md",
18
+ skillConfig: "integrations/codex/skills/owlcoda-runkit/assets/templates/config.json",
19
+ });
20
+
21
+ function readJson(ref) {
22
+ return JSON.parse(readFileSync(ref, "utf8"));
23
+ }
24
+
25
+ function bytes(value) {
26
+ return `${JSON.stringify(value, null, 2)}\n`;
27
+ }
28
+
29
+ function writeAtomic(ref, value) {
30
+ const temporary = `${ref}.sync-${process.pid}`;
31
+ writeFileSync(temporary, value, { flag: "wx" });
32
+ renameSync(temporary, ref);
33
+ }
34
+
35
+ function exactCore(actual, expected, includeSourceRef) {
36
+ return actual?.contractVersion === expected.contractVersion
37
+ && actual?.coreVersion === expected.coreVersion
38
+ && actual?.coreManifestSha256 === expected.coreManifestSha256
39
+ && (!includeSourceRef || actual?.coreSourceRef === expected.coreSourceRef);
40
+ }
41
+
42
+ function escaped(value) {
43
+ return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
44
+ }
45
+
46
+ export function synchronizeReleaseIdentityV1({
47
+ repositoryRoot,
48
+ core,
49
+ write = false,
50
+ }) {
51
+ const root = path.resolve(repositoryRoot);
52
+ if (core?.contractVersion !== "0.2"
53
+ || typeof core?.coreVersion !== "string"
54
+ || !/^\d+\.\d+\.\d+$/u.test(core.coreVersion)
55
+ || !/^sha256:[a-f0-9]{64}$/u.test(core?.coreManifestSha256 ?? "")
56
+ || core?.coreSourceRef !== `artifact:${core.coreManifestSha256}`) {
57
+ throw new Error("release_identity_core_invalid");
58
+ }
59
+ const refs = Object.fromEntries(Object.entries(RELEASE_FILES).map(
60
+ ([key, relative]) => [key, path.join(root, relative)],
61
+ ));
62
+ const packageManifest = readJson(refs.packageManifest);
63
+ if (packageManifest.name !== "owlrunkit"
64
+ || packageManifest.version !== core.coreVersion) {
65
+ throw new Error("release_identity_package_invalid");
66
+ }
67
+ const attestManifest = readJson(refs.attestManifest);
68
+ const candidateIndexes = attestManifest.supportedProducerCoreIdentities
69
+ ?.map((identity, index) => ({ identity, index }))
70
+ .filter(({ identity }) => identity?.coreVersion === core.coreVersion) ?? [];
71
+ if (candidateIndexes.length !== 1) {
72
+ throw new Error("release_identity_attest_candidate_ambiguous");
73
+ }
74
+ const attestRuntime = readFileSync(refs.attestRuntime, "utf8");
75
+ const runtimePattern = new RegExp(
76
+ `(coreVersion:\\s*"${escaped(core.coreVersion)}",`
77
+ + `\\s*coreManifestSha256:\\s*")sha256:[a-f0-9]{64}("\\s*,?)`,
78
+ "gu",
79
+ );
80
+ const runtimeMatches = [...attestRuntime.matchAll(runtimePattern)];
81
+ if (runtimeMatches.length !== 1) {
82
+ throw new Error("release_identity_attest_runtime_candidate_ambiguous");
83
+ }
84
+ const skillMarkdown = readFileSync(refs.skillMarkdown, "utf8");
85
+ const skillHashes = skillMarkdown.match(/sha256:[a-f0-9]{64}/gu) ?? [];
86
+ if (skillHashes.length !== 1) {
87
+ throw new Error("release_identity_skill_identity_ambiguous");
88
+ }
89
+ const skillConfig = readJson(refs.skillConfig);
90
+ const mismatches = [];
91
+ if (!exactCore(candidateIndexes[0].identity, core, false)) mismatches.push("attest");
92
+ if (!runtimeMatches[0][0].includes(core.coreManifestSha256)) mismatches.push("attest_runtime");
93
+ if (skillHashes[0] !== core.coreManifestSha256) mismatches.push("skill_markdown");
94
+ if (!exactCore(skillConfig.core, core, true)) mismatches.push("skill_config");
95
+ if (write && mismatches.length > 0) {
96
+ attestManifest.supportedProducerCoreIdentities[candidateIndexes[0].index] = {
97
+ contractVersion: core.contractVersion,
98
+ coreVersion: core.coreVersion,
99
+ coreManifestSha256: core.coreManifestSha256,
100
+ };
101
+ writeAtomic(refs.attestManifest, bytes(attestManifest));
102
+ writeAtomic(
103
+ refs.attestRuntime,
104
+ attestRuntime.replace(runtimePattern, `$1${core.coreManifestSha256}$2`),
105
+ );
106
+ writeAtomic(
107
+ refs.skillMarkdown,
108
+ skillMarkdown.replace(skillHashes[0], core.coreManifestSha256),
109
+ );
110
+ writeAtomic(refs.skillConfig, bytes({
111
+ ...skillConfig,
112
+ core: structuredClone(core),
113
+ }));
114
+ }
115
+ return {
116
+ status: mismatches.length === 0 ? "exact" : write ? "synchronized" : "drifted",
117
+ core: structuredClone(core),
118
+ mismatches,
119
+ changed: write ? mismatches : [],
120
+ };
121
+ }
122
+
123
+ function requireSurface(condition, surface) {
124
+ if (!condition) {
125
+ throw new Error(`release_identity_surface_mismatch:${surface}`);
126
+ }
127
+ }
128
+
129
+ export function verifyReleaseIdentitySurfacesV1(input) {
130
+ const core = input?.core;
131
+ requireSurface(
132
+ core?.contractVersion === "0.2"
133
+ && /^\d+\.\d+\.\d+$/u.test(core?.coreVersion ?? "")
134
+ && /^sha256:[a-f0-9]{64}$/u.test(core?.coreManifestSha256 ?? "")
135
+ && core?.coreSourceRef === `artifact:${core.coreManifestSha256}`,
136
+ "core",
137
+ );
138
+ const packageExact = (manifest) => (
139
+ manifest?.name === "owlrunkit" && manifest?.version === core.coreVersion
140
+ );
141
+ const attestExact = (manifest) => (
142
+ manifest?.supportedProducerCoreIdentities?.some(
143
+ (identity) => exactCore(identity, core, false),
144
+ ) === true
145
+ );
146
+ const attestRuntimeExact = (source) => {
147
+ if (typeof source !== "string") return false;
148
+ const pattern = new RegExp(
149
+ `coreVersion:\\s*"${escaped(core.coreVersion)}",`
150
+ + `\\s*coreManifestSha256:\\s*"(sha256:[a-f0-9]{64})"`,
151
+ "gu",
152
+ );
153
+ const matches = [...source.matchAll(pattern)];
154
+ return matches.length === 1 && matches[0][1] === core.coreManifestSha256;
155
+ };
156
+ const skillExact = (markdown) => {
157
+ if (typeof markdown !== "string") return false;
158
+ const hashes = markdown.match(/sha256:[a-f0-9]{64}/gu) ?? [];
159
+ return hashes.length === 1
160
+ && hashes[0] === core.coreManifestSha256
161
+ && markdown.includes(`Bundled release: standalone \`owlrunkit@${core.coreVersion}\``)
162
+ && markdown.includes(`Core \`${core.coreVersion}\``)
163
+ && !/(?:It is not published|current published release remains)/iu.test(markdown);
164
+ };
165
+
166
+ requireSurface(packageExact(input.packageManifest), "package_manifest");
167
+ requireSurface(attestExact(input.attestManifest), "attest");
168
+ requireSurface(attestRuntimeExact(input.attestRuntime), "attest_runtime");
169
+ requireSurface(skillExact(input.skillMarkdown), "skill_markdown");
170
+ requireSurface(exactCore(input.skillConfig?.core, core, true), "skill_config");
171
+ requireSurface(packageExact(input.packed?.packageManifest), "packed_package_manifest");
172
+ requireSurface(attestExact(input.packed?.attestManifest), "packed_attest");
173
+ requireSurface(attestRuntimeExact(input.packed?.attestRuntime), "packed_attest_runtime");
174
+ requireSurface(skillExact(input.packed?.skillMarkdown), "packed_skill_markdown");
175
+ requireSurface(
176
+ exactCore(input.packed?.skillConfig?.core, core, true),
177
+ "packed_skill_config",
178
+ );
179
+ requireSurface(
180
+ input.binding?.packageName === "owlrunkit"
181
+ && input.binding?.version === core.coreVersion
182
+ && exactCore(input.binding?.core, core, true),
183
+ "release_binding",
184
+ );
185
+ requireSurface(
186
+ /^sha256:[a-f0-9]{64}$/u.test(input.binding?.tarball?.sha256 ?? "")
187
+ && input.retainedTarballSha256 === input.binding.tarball.sha256,
188
+ "retained_tarball",
189
+ );
190
+ return {
191
+ status: "exact",
192
+ packageName: "owlrunkit",
193
+ version: core.coreVersion,
194
+ core: structuredClone(core),
195
+ surfaceCount: 11,
196
+ retainedTarballSha256: input.retainedTarballSha256,
197
+ };
198
+ }
199
+
200
+ function main(argv) {
201
+ const write = argv.includes("--write");
202
+ const rootIndex = argv.indexOf("--repository-root");
203
+ const repositoryRoot = rootIndex === -1
204
+ ? path.resolve(fileURLToPath(new URL("../..", import.meta.url)))
205
+ : argv[rootIndex + 1];
206
+ if (!repositoryRoot) throw new Error("repository_root_required");
207
+ const result = synchronizeReleaseIdentityV1({
208
+ repositoryRoot,
209
+ core: currentCoreIdentity(),
210
+ write,
211
+ });
212
+ process.stdout.write(`${JSON.stringify(result)}\n`);
213
+ if (!write && result.status !== "exact") process.exitCode = 2;
214
+ }
215
+
216
+ if (process.argv[1]
217
+ && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
218
+ try {
219
+ main(process.argv.slice(2));
220
+ } catch (error) {
221
+ process.stderr.write(`${error instanceof Error ? error.stack : String(error)}\n`);
222
+ process.exitCode = 1;
223
+ }
224
+ }