diff --git a/CHANGELOG.md b/CHANGELOG.md index d343ef8..89aafda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## Local candidate — 2026-10-31 + +Add an opt-in Comic build result 1.1.0 candidate for confirmed no-output +rate-limit failures and bounded synthetic retry conformance. Released v1 +artifacts and default behavior are preserved. No publication or production +adoption is declared. + ## Unreleased — Comic Manifest revision and approval boundaries (#95) - Pin the exact merged Codex approval-time clarification and its synthetic diff --git a/CONSTITUTION_CONFORMANCE.md b/CONSTITUTION_CONFORMANCE.md index f3df5c7..beff5ef 100644 --- a/CONSTITUTION_CONFORMANCE.md +++ b/CONSTITUTION_CONFORMANCE.md @@ -1,5 +1,18 @@ ## Studio #99 Codex publication and Platform adoption — 2026-10-09 +## O02/O03 local retry candidate — 2026-10-31 + +Owner/reviewer: @andrewperis. Constitution 1.0.0 at +`a9cc8a503aa30e17820edc62ac95f7cbe10e0564`. Profiles: universal, +RFC/specification and runtime implementation. Bounded synthetic, in-memory-only +rate-limit retry candidate; exact version negotiation, actual provenance, +protected outcome evidence, immutable terminal readback, original budgets and +explicit caller authority. No new dependencies, private data, creative work or +exception. Tests and candidate decision documents provide technical evidence; +owner normative acceptance, production adoption and publication remain pending. +Released v1 artifacts remain unchanged. Re-review on any provider, storage, +identity, authority, retention or scope expansion. + Owner: @andrewperis. Constitution 1.0.0 at `a9cc8a503aa30e17820edc62ac95f7cbe10e0564`. Platform base: `9476aeb27246230d982bd8cfde7cfc0d82939de7`, including merged preparation PR #42. diff --git a/docs/offline-orchestration-prototype.md b/docs/offline-orchestration-prototype.md index 9f32914..a4c265f 100644 --- a/docs/offline-orchestration-prototype.md +++ b/docs/offline-orchestration-prototype.md @@ -121,3 +121,46 @@ only accepted production input. A completed mock result only demonstrates the synthetic lifecycle and structural compatibility; it does not establish content quality, rights, safety, approval, release eligibility, or publication authority. + +## Local opt-in no-output retry candidate (2026-10-31) + +Default behavior described above remains available. Passing +`noOutputResultVersion: '1.1.0'` to `submit` explicitly selects the **unreleased** +Comic build-result candidate for confirmed no-action rate-limit failures only. +Success continues to emit v1. Other versions fail before admission. Cancellation, +validation failure and timeout remain unmapped when no verified output exists. + +```js +const first = await runner.submit({ + productionSource, + noOutputResultVersion: '1.1.0', + mockOutcome: { kind: 'rate-limit', retry_after_ms: 10 } +}); +// After the delay, while the original job deadline and budgets permit: +const second = await runner.retry({ authorizeRetry: true }); +``` + +The first failed result has `outputs: []`, `diagnostics: ['OUTPUT_MISSING']`, +and one actual-input transformation with empty output digests and false withheld +flags. Immutable outcome and result bytes plus terminal linkage must verify. +Retry rechecks pinned inputs, prompt, protected outcome and terminal result +before allocating IDs and again immediately before dispatch after async mock +preflight. IDs are fresh; the prepared event links `retry_of_attempt_id`. +The second attempt always closes the job; there is no third attempt or hidden +retry. Delay is measured conservatively from terminal completion. A caller may +use `closeJob()` instead. A restart can only inspect; it cannot resume retry. + +The experimental validator lives in `src/comic-manifest/result-candidate.js`; +the stable `validateComicManifest` entry point continues to reject 1.1.0. +`candidate-contract.js` pins exact local Codex schema bytes. Regenerate with: + +```sh +node scripts/generate-comic-result-candidate.mjs /path/to/codex/schemas/json/comic-manifest/v1.1/comic-build-result.schema.json +``` + +Codex's `specs/comic-build-result-1.1-candidate.md` records the additive minor +compatibility choice, exact schema ID, lifecycle and migration boundary. This +is a local implementation candidate, not a published contract pin or production +consumer adoption. Existing release manifests, v1 validators and fixtures are +unchanged. O02/O03 owner review remains pending. Real providers, durable storage, +cancellation retries, timeout/integrity mapping and production use are excluded. diff --git a/scripts/generate-comic-result-candidate.mjs b/scripts/generate-comic-result-candidate.mjs new file mode 100644 index 0000000..3afad20 --- /dev/null +++ b/scripts/generate-comic-result-candidate.mjs @@ -0,0 +1,21 @@ +import { createRequire } from 'node:module'; +import { createHash } from 'node:crypto'; +import { readFile, writeFile } from 'node:fs/promises'; +import Ajv2020 from 'ajv/dist/2020.js'; +import addFormats from 'ajv-formats'; +import standaloneCode from 'ajv/dist/standalone/index.js'; +import { COMIC_BUILD_RESULT_CANDIDATE as pin } from '../src/comic-manifest/candidate-contract.js'; +const require = createRequire(import.meta.url); +const lock = JSON.parse(await readFile(new URL('../package-lock.json', import.meta.url))); +for (const [name, version] of Object.entries({ ajv: '8.20.0', 'ajv-formats': '3.0.1' })) { + if (require(`${name}/package.json`).version !== version || lock.packages[`node_modules/${name}`].version !== version) throw new Error('Validator dependency mismatch'); +} +const bytes = await readFile(process.argv[2]); +if (bytes.length !== pin.byte_size || 'sha256:' + createHash('sha256').update(bytes).digest('hex') !== pin.sha256) throw new Error('Candidate schema identity mismatch'); +const schema = JSON.parse(bytes); +if (schema.$id !== pin.schema_id) throw new Error('Candidate schema ID mismatch'); +const ajv = new Ajv2020({ strict: true, strictRequired: false, strictTypes: false, ownProperties: true, code: { source: true, esm: true, lines: true } }); +addFormats(ajv); +ajv.addSchema(schema); +await writeFile(new URL('../src/comic-manifest/generated/result-v1.1-candidate.js', import.meta.url), + `// Generated from local ${pin.repository}@${pin.commit}; ${pin.source_path}; ${pin.sha256}; ${pin.byte_size} bytes.\n// Unreleased candidate; rebuild with scripts/generate-comic-result-candidate.mjs.\nimport { createRequire } from 'node:module';\nconst require = createRequire(import.meta.url);\n` + standaloneCode(ajv, { result: schema.$id })); diff --git a/src/comic-manifest/candidate-contract.js b/src/comic-manifest/candidate-contract.js new file mode 100644 index 0000000..8ddcef3 --- /dev/null +++ b/src/comic-manifest/candidate-contract.js @@ -0,0 +1,11 @@ +// Local candidate only; not a released contract or production adoption. +export const COMIC_BUILD_RESULT_CANDIDATE = Object.freeze({ + "repository": "DefinitelySecureStudio/codex", + "commit": "780de1c7e3b76e02f43f0a594991e3cf7fe874f8", + "version": "1.1.0", + "status": "unreleased-local-candidate", + "schema_id": "urn:definitely-secure:contract:comic-manifest:1.1.0:comic-build-result", + "source_path": "schemas/json/comic-manifest/v1.1/comic-build-result.schema.json", + "byte_size": 32330, + "sha256": "sha256:aee6887e056ca709717f579c46e98c9da4c5d9214735af7137ec457767ed231d" +}); diff --git a/src/comic-manifest/generated/result-v1.1-candidate.js b/src/comic-manifest/generated/result-v1.1-candidate.js new file mode 100644 index 0000000..914e111 --- /dev/null +++ b/src/comic-manifest/generated/result-v1.1-candidate.js @@ -0,0 +1,3972 @@ +// Generated from local DefinitelySecureStudio/codex@780de1c7e3b76e02f43f0a594991e3cf7fe874f8; schemas/json/comic-manifest/v1.1/comic-build-result.schema.json; sha256:aee6887e056ca709717f579c46e98c9da4c5d9214735af7137ec457767ed231d; 32330 bytes. +// Unreleased candidate; rebuild with scripts/generate-comic-result-candidate.mjs. +import { createRequire } from 'node:module'; +const require = createRequire(import.meta.url); +"use strict"; +export const result = validate20; +const schema31 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"urn:definitely-secure:contract:comic-manifest:1.1.0:comic-build-result","title":"Comic build result 1.1.0 candidate (unreleased)","$defs":{"uuid":{"type":"string","pattern":"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"digest":{"type":"string","pattern":"^sha256:[0-9a-f]{64}$"},"name":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$"},"time":{"type":"string","format":"date-time","pattern":"Z$","maxLength":32},"size":{"type":"integer","minimum":0,"maximum":9007199254740991},"revision":{"type":"integer","minimum":1,"maximum":9007199254740991},"classification":{"enum":["public","internal","confidential","restricted"]},"uri":{"type":"string","format":"uri","pattern":"^https://","maxLength":2048},"identity":{"type":"object","additionalProperties":false,"required":["canonicalization","byte_size","sha256"],"properties":{"canonicalization":{"const":"studio-json-v1"},"byte_size":{"$ref":"#/$defs/size"},"sha256":{"$ref":"#/$defs/digest"}}},"artifact":{"type":"object","additionalProperties":false,"required":["artifact_uri","media_type","byte_size","sha256"],"properties":{"artifact_uri":{"$ref":"#/$defs/uri"},"media_type":{"type":"string","minLength":1,"maxLength":128},"byte_size":{"$ref":"#/$defs/size"},"sha256":{"$ref":"#/$defs/digest"}}},"dependency":{"type":"object","additionalProperties":false,"required":["repository","version","tag","commit","artifact"],"properties":{"repository":{"type":"string","pattern":"^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$","maxLength":200},"version":{"type":"string","pattern":"^[0-9]+\\.[0-9]+\\.[0-9]+$"},"tag":{"type":"string","minLength":1,"maxLength":200},"commit":{"type":"string","pattern":"^[0-9a-f]{40}$"},"artifact":{"$ref":"#/$defs/artifact"}}},"productionRef":{"type":"object","additionalProperties":false,"required":["production_id","revision","identity"],"properties":{"production_id":{"$ref":"#/$defs/uuid"},"revision":{"$ref":"#/$defs/revision"},"identity":{"$ref":"#/$defs/identity"}}},"releaseRef":{"type":"object","additionalProperties":false,"required":["release_id","episode_id","revision","identity"],"properties":{"release_id":{"$ref":"#/$defs/uuid"},"episode_id":{"type":"string","pattern":"^DS-(?!0000)[0-9]{4}$"},"revision":{"$ref":"#/$defs/revision"},"identity":{"$ref":"#/$defs/identity"}}},"context":{"type":"object","additionalProperties":false,"required":["contract_version","package_id","package_version","instance_id","manifest_identity","classification","purpose","sections","builder_result_identity","preparation_reference","use_authorization_reference"],"properties":{"contract_version":{"const":"1.0.0"},"package_id":{"type":"string","minLength":1,"maxLength":200},"package_version":{"type":"string","minLength":1,"maxLength":32},"instance_id":{"$ref":"#/$defs/uuid"},"manifest_identity":{"$ref":"#/$defs/identity"},"classification":{"$ref":"#/$defs/classification"},"purpose":{"type":"string","minLength":1,"maxLength":4096},"sections":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":256},"builder_result_identity":{"$ref":"#/$defs/identity"},"preparation_reference":{"$ref":"#/$defs/uuid"},"use_authorization_reference":{"$ref":"#/$defs/uuid"}}},"prompt":{"type":"object","additionalProperties":false,"required":["binding_id","definition","prompt_id","prompt_version","identity","context"],"properties":{"binding_id":{"$ref":"#/$defs/name"},"definition":{"$ref":"#/$defs/dependency"},"prompt_id":{"type":"string","minLength":1,"maxLength":200},"prompt_version":{"type":"string","pattern":"^[0-9]+\\.[0-9]+\\.[0-9]+$"},"identity":{"$ref":"#/$defs/identity"},"context":{"anyOf":[{"$ref":"#/$defs/context"},{"type":"null"}]}}},"asset":{"type":"object","additionalProperties":false,"required":["asset_id","classification","reference","rights_notice"],"properties":{"asset_id":{"$ref":"#/$defs/name"},"classification":{"$ref":"#/$defs/classification"},"reference":{"oneOf":[{"type":"object","additionalProperties":false,"required":["kind","dependency"],"properties":{"kind":{"const":"public"},"dependency":{"$ref":"#/$defs/dependency"}}},{"type":"object","additionalProperties":false,"required":["kind","handle","media_type","byte_size","sha256"],"properties":{"kind":{"const":"protected"},"handle":{"$ref":"#/$defs/uuid"},"media_type":{"type":"string","minLength":1,"maxLength":128},"byte_size":{"$ref":"#/$defs/size"},"sha256":{"$ref":"#/$defs/digest"}}}]},"rights_notice":{"type":"string","minLength":1,"maxLength":4096}}},"inputs":{"type":"object","additionalProperties":false,"required":["canon","dependencies","prompts","assets"],"properties":{"canon":{"$ref":"#/$defs/dependency"},"dependencies":{"type":"array","items":{"$ref":"#/$defs/dependency"},"minItems":1,"maxItems":256},"prompts":{"type":"array","items":{"$ref":"#/$defs/prompt"},"minItems":0,"maxItems":256},"assets":{"type":"array","items":{"$ref":"#/$defs/asset"},"minItems":0,"maxItems":256}}},"panel":{"type":"object","additionalProperties":false,"required":["panel_id","description","text","asset_ids","prompt_bindings"],"properties":{"panel_id":{"$ref":"#/$defs/name"},"description":{"type":"string","minLength":1,"maxLength":4096},"text":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["text_id","kind","speaker","text"],"properties":{"text_id":{"$ref":"#/$defs/name"},"kind":{"enum":["dialogue","caption"]},"speaker":{"anyOf":[{"type":"string","minLength":1,"maxLength":128},{"type":"null"}]},"text":{"type":"string","minLength":1,"maxLength":4096}}},"minItems":0,"maxItems":256},"asset_ids":{"type":"array","items":{"$ref":"#/$defs/name"},"minItems":0,"maxItems":256},"prompt_bindings":{"type":"array","items":{"$ref":"#/$defs/name"},"minItems":0,"maxItems":256}}},"dimensions":{"anyOf":[{"type":"object","additionalProperties":false,"required":["width","height"],"properties":{"width":{"type":"integer","minimum":1,"maximum":32768},"height":{"type":"integer","minimum":1,"maximum":32768}}},{"type":"null"}]},"renditionProfile":{"type":"object","additionalProperties":false,"required":["profile_id","profile_version"],"properties":{"profile_id":{"enum":["comic-page-image","comic-portable-document","comic-accessible-transcript"]},"profile_version":{"const":"1.0.0"}}},"rendition":{"type":"object","additionalProperties":false,"required":["rendition_id","required","profile","media_type","dimensions","max_bytes","alt_text","transcript","rights_notice"],"properties":{"rendition_id":{"$ref":"#/$defs/name"},"required":{"type":"boolean"},"profile":{"$ref":"#/$defs/renditionProfile"},"media_type":{"enum":["image/png","image/jpeg","image/webp","application/pdf","text/plain"]},"dimensions":{"$ref":"#/$defs/dimensions"},"max_bytes":{"type":"integer","minimum":1,"maximum":50000000},"alt_text":{"type":"string","minLength":1,"maxLength":4096},"transcript":{"type":"string","minLength":1,"maxLength":32768},"rights_notice":{"type":"string","minLength":1,"maxLength":4096}}},"production":{"type":"object","additionalProperties":false,"required":["kind","spec_version","production_id","revision","previous","classification","title","intent","inputs","panels","renditions"],"properties":{"kind":{"const":"comic-production"},"spec_version":{"const":"1.0.0"},"production_id":{"$ref":"#/$defs/uuid"},"revision":{"$ref":"#/$defs/revision"},"previous":{"anyOf":[{"$ref":"#/$defs/productionRef"},{"type":"null"}]},"classification":{"$ref":"#/$defs/classification"},"title":{"type":"string","minLength":1,"maxLength":200},"intent":{"type":"string","minLength":1,"maxLength":4096},"inputs":{"$ref":"#/$defs/inputs"},"panels":{"type":"array","items":{"$ref":"#/$defs/panel"},"minItems":1,"maxItems":256},"renditions":{"type":"array","items":{"$ref":"#/$defs/rendition"},"minItems":1,"maxItems":32}}},"output":{"type":"object","additionalProperties":false,"required":["rendition_id","artifact","profile","dimensions","max_bytes","rights_notice","alt_text","transcript"],"properties":{"rendition_id":{"$ref":"#/$defs/name"},"artifact":{"$ref":"#/$defs/artifact"},"profile":{"$ref":"#/$defs/renditionProfile"},"dimensions":{"$ref":"#/$defs/dimensions"},"max_bytes":{"type":"integer","minimum":1,"maximum":50000000},"rights_notice":{"type":"string","minLength":1,"maxLength":4096},"alt_text":{"type":"string","minLength":1,"maxLength":4096},"transcript":{"type":"string","minLength":1,"maxLength":32768}}},"buildOutput":{"type":"object","additionalProperties":false,"required":["rendition_id","artifact","profile","dimensions","max_bytes","rights_notice","alt_text","transcript"],"properties":{"rendition_id":{"$ref":"#/$defs/name"},"artifact":{"type":"object","additionalProperties":false,"required":["artifact_uri","media_type","byte_size","sha256"],"properties":{"artifact_uri":{"oneOf":[{"$ref":"#/$defs/uri"},{"$ref":"#/$defs/uuid"}]},"media_type":{"type":"string","minLength":1,"maxLength":128},"byte_size":{"$ref":"#/$defs/size"},"sha256":{"$ref":"#/$defs/digest"}}},"profile":{"$ref":"#/$defs/renditionProfile"},"dimensions":{"$ref":"#/$defs/dimensions"},"max_bytes":{"type":"integer","minimum":1,"maximum":50000000},"rights_notice":{"type":"string","minLength":1,"maxLength":4096},"alt_text":{"type":"string","minLength":1,"maxLength":4096},"transcript":{"type":"string","minLength":1,"maxLength":32768}}},"gate":{"type":"object","additionalProperties":false,"required":["gate","disposition","evidence_reference","rationale"],"properties":{"gate":{"enum":["editorial","canon-continuity","visual-text","integrity","provenance","security-privacy","rights","accessibility","packaging"]},"disposition":{"enum":["pass","fail","inconclusive","not-run","not-applicable"]},"evidence_reference":{"$ref":"#/$defs/uuid"},"rationale":{"type":"string","minLength":1,"maxLength":4096}}},"generation":{"type":"object","additionalProperties":false,"required":["provider","model","parameters","evidence_state","limitations"],"properties":{"provider":{"type":"string","minLength":1,"maxLength":128},"model":{"type":"string","minLength":1,"maxLength":128},"parameters":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","value"],"properties":{"name":{"$ref":"#/$defs/name"},"value":{"type":"string","minLength":1,"maxLength":1024}}},"minItems":0,"maxItems":256},"evidence_state":{"enum":["recorded","unavailable","withheld"]},"limitations":{"type":"string","minLength":1,"maxLength":4096}}},"execution":{"type":"object","additionalProperties":false,"required":["tool","workflow_id","run_uri","started_at","finished_at","transformations","generation","reproducibility","limitations"],"properties":{"tool":{"$ref":"#/$defs/dependency"},"workflow_id":{"type":"string","minLength":1,"maxLength":200},"run_uri":{"anyOf":[{"$ref":"#/$defs/uri"},{"type":"null"}]},"started_at":{"$ref":"#/$defs/time"},"finished_at":{"$ref":"#/$defs/time"},"transformations":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["step_id","input_digests","output_digests","private_inputs_withheld","private_outputs_withheld"],"properties":{"step_id":{"$ref":"#/$defs/name"},"input_digests":{"type":"array","items":{"$ref":"#/$defs/digest"},"minItems":0,"maxItems":256},"output_digests":{"type":"array","items":{"$ref":"#/$defs/digest"},"minItems":0,"maxItems":256},"private_inputs_withheld":{"type":"boolean"},"private_outputs_withheld":{"type":"boolean"}}},"minItems":1,"maxItems":256},"generation":{"type":"array","items":{"$ref":"#/$defs/generation"},"minItems":0,"maxItems":256},"reproducibility":{"enum":["exact","partial","audit-only"]},"limitations":{"type":"string","minLength":1,"maxLength":4096}}},"result":{"type":"object","additionalProperties":false,"required":["kind","spec_version","result_id","attempt_id","production","classification","inputs","status","outputs","gates","execution","diagnostics"],"properties":{"kind":{"const":"comic-build-result"},"spec_version":{"const":"1.1.0"},"result_id":{"$ref":"#/$defs/uuid"},"attempt_id":{"$ref":"#/$defs/uuid"},"production":{"$ref":"#/$defs/productionRef"},"classification":{"$ref":"#/$defs/classification"},"inputs":{"$ref":"#/$defs/inputs"},"status":{"enum":["complete","partial","failed"]},"outputs":{"type":"array","items":{"$ref":"#/$defs/buildOutput"},"minItems":0,"maxItems":32},"gates":{"type":"array","items":{"$ref":"#/$defs/gate"},"minItems":0,"maxItems":9},"execution":{"$ref":"#/$defs/execution"},"diagnostics":{"type":"array","items":{"enum":["INPUT_MISMATCH","OUTPUT_MISSING","OUTPUT_INTEGRITY","AUTHORITY_DENIED","VALIDATION_FAILED","CANCELLED"]},"minItems":0,"maxItems":32}},"allOf":[{"if":{"properties":{"status":{"const":"complete"}}},"then":{"properties":{"outputs":{"minItems":1},"diagnostics":{"maxItems":0}}},"else":{"properties":{"diagnostics":{"minItems":1}}}},{"if":{"properties":{"execution":{"properties":{"transformations":{"contains":{"properties":{"output_digests":{"maxItems":0}}}}}}}},"then":{"properties":{"status":{"const":"failed"},"outputs":{"maxItems":0},"diagnostics":{"const":["OUTPUT_MISSING"]},"execution":{"properties":{"transformations":{"minItems":1,"maxItems":1,"items":{"properties":{"input_digests":{"minItems":1},"output_digests":{"maxItems":0},"private_inputs_withheld":{"const":false},"private_outputs_withheld":{"const":false}}}}}}}}}]},"scope":{"type":"object","additionalProperties":false,"required":["destination","audience","purpose","publication_time"],"properties":{"destination":{"$ref":"#/$defs/uri"},"audience":{"type":"string","minLength":1,"maxLength":200},"purpose":{"type":"string","minLength":1,"maxLength":4096},"publication_time":{"$ref":"#/$defs/time"}}},"approver":{"type":"object","additionalProperties":false,"required":["decision_id","role","actor","decided_at"],"properties":{"decision_id":{"$ref":"#/$defs/uuid"},"role":{"enum":["publisher","canon-editor","disclosure-reviewer"]},"actor":{"type":"string","minLength":1,"maxLength":200},"decided_at":{"$ref":"#/$defs/time"}}},"release":{"type":"object","additionalProperties":false,"required":["kind","spec_version","release_id","episode_id","revision","previous","classification","title","production_credit","canon_scope","scope","input_canon","dependencies","outputs","gates","execution","approvers","private_context"],"properties":{"kind":{"const":"comic-public-release"},"spec_version":{"const":"1.0.0"},"release_id":{"$ref":"#/$defs/uuid"},"episode_id":{"type":"string","pattern":"^DS-(?!0000)[0-9]{4}$"},"revision":{"$ref":"#/$defs/revision"},"previous":{"anyOf":[{"$ref":"#/$defs/releaseRef"},{"type":"null"}]},"classification":{"const":"public"},"title":{"type":"string","minLength":1,"maxLength":200},"production_credit":{"const":"A Definitely Secure Studio production."},"canon_scope":{"type":"string","minLength":1,"maxLength":4096},"scope":{"$ref":"#/$defs/scope"},"input_canon":{"$ref":"#/$defs/dependency"},"dependencies":{"type":"array","items":{"$ref":"#/$defs/dependency"},"minItems":1,"maxItems":256},"outputs":{"type":"array","items":{"$ref":"#/$defs/output"},"minItems":1,"maxItems":32},"gates":{"type":"array","items":{"$ref":"#/$defs/gate"},"minItems":9,"maxItems":9},"execution":{"$ref":"#/$defs/execution"},"approvers":{"type":"array","items":{"$ref":"#/$defs/approver"},"minItems":2,"maxItems":16},"private_context":{"oneOf":[{"type":"object","additionalProperties":false,"required":["influenced"],"properties":{"influenced":{"const":false}}},{"type":"object","additionalProperties":false,"required":["influenced","attestation_reference"],"properties":{"influenced":{"const":true},"attestation_reference":{"$ref":"#/$defs/uuid"}}}]}}},"approval":{"type":"object","additionalProperties":false,"required":["kind","spec_version","decision_id","role","actor","subject","artifact_digests","scope","decided_at","expires_at","authority_reference"],"properties":{"kind":{"const":"comic-approval-binding"},"spec_version":{"const":"1.0.0"},"decision_id":{"$ref":"#/$defs/uuid"},"role":{"enum":["production-reviewer","publisher","canon-editor","disclosure-reviewer"]},"actor":{"type":"string","minLength":1,"maxLength":200},"subject":{"$ref":"#/$defs/identity"},"artifact_digests":{"type":"array","items":{"$ref":"#/$defs/digest"},"minItems":0,"maxItems":256},"scope":{"$ref":"#/$defs/scope"},"decided_at":{"$ref":"#/$defs/time"},"expires_at":{"$ref":"#/$defs/time"},"authority_reference":{"$ref":"#/$defs/uuid"}}}},"$ref":"#/$defs/result"}; +const schema32 = {"type":"object","additionalProperties":false,"required":["kind","spec_version","result_id","attempt_id","production","classification","inputs","status","outputs","gates","execution","diagnostics"],"properties":{"kind":{"const":"comic-build-result"},"spec_version":{"const":"1.1.0"},"result_id":{"$ref":"#/$defs/uuid"},"attempt_id":{"$ref":"#/$defs/uuid"},"production":{"$ref":"#/$defs/productionRef"},"classification":{"$ref":"#/$defs/classification"},"inputs":{"$ref":"#/$defs/inputs"},"status":{"enum":["complete","partial","failed"]},"outputs":{"type":"array","items":{"$ref":"#/$defs/buildOutput"},"minItems":0,"maxItems":32},"gates":{"type":"array","items":{"$ref":"#/$defs/gate"},"minItems":0,"maxItems":9},"execution":{"$ref":"#/$defs/execution"},"diagnostics":{"type":"array","items":{"enum":["INPUT_MISMATCH","OUTPUT_MISSING","OUTPUT_INTEGRITY","AUTHORITY_DENIED","VALIDATION_FAILED","CANCELLED"]},"minItems":0,"maxItems":32}},"allOf":[{"if":{"properties":{"status":{"const":"complete"}}},"then":{"properties":{"outputs":{"minItems":1},"diagnostics":{"maxItems":0}}},"else":{"properties":{"diagnostics":{"minItems":1}}}},{"if":{"properties":{"execution":{"properties":{"transformations":{"contains":{"properties":{"output_digests":{"maxItems":0}}}}}}}},"then":{"properties":{"status":{"const":"failed"},"outputs":{"maxItems":0},"diagnostics":{"const":["OUTPUT_MISSING"]},"execution":{"properties":{"transformations":{"minItems":1,"maxItems":1,"items":{"properties":{"input_digests":{"minItems":1},"output_digests":{"maxItems":0},"private_inputs_withheld":{"const":false},"private_outputs_withheld":{"const":false}}}}}}}}}]}; +const schema33 = {"type":"string","pattern":"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}; +const schema41 = {"enum":["public","internal","confidential","restricted"]}; +const func0 = Object.prototype.hasOwnProperty; +const func27 = require("ajv/dist/runtime/equal").default; +const pattern4 = new RegExp("^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", "u"); +const schema35 = {"type":"object","additionalProperties":false,"required":["production_id","revision","identity"],"properties":{"production_id":{"$ref":"#/$defs/uuid"},"revision":{"$ref":"#/$defs/revision"},"identity":{"$ref":"#/$defs/identity"}}}; +const schema37 = {"type":"integer","minimum":1,"maximum":9007199254740991}; +const schema38 = {"type":"object","additionalProperties":false,"required":["canonicalization","byte_size","sha256"],"properties":{"canonicalization":{"const":"studio-json-v1"},"byte_size":{"$ref":"#/$defs/size"},"sha256":{"$ref":"#/$defs/digest"}}}; +const schema39 = {"type":"integer","minimum":0,"maximum":9007199254740991}; +const schema40 = {"type":"string","pattern":"^sha256:[0-9a-f]{64}$"}; +const pattern7 = new RegExp("^sha256:[0-9a-f]{64}$", "u"); + +function validate23(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate23.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if(((((data.canonicalization === undefined) || (!(func0.call(data, "canonicalization")))) && (missing0 = "canonicalization")) || (((data.byte_size === undefined) || (!(func0.call(data, "byte_size")))) && (missing0 = "byte_size"))) || (((data.sha256 === undefined) || (!(func0.call(data, "sha256")))) && (missing0 = "sha256"))){ +validate23.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs1 = errors; +for(const key0 of Object.keys(data)){ +if(!(((key0 === "canonicalization") || (key0 === "byte_size")) || (key0 === "sha256"))){ +validate23.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs1 === errors){ +if(data.canonicalization !== undefined && func0.call(data, "canonicalization")){ +const _errs2 = errors; +if("studio-json-v1" !== data.canonicalization){ +validate23.errors = [{instancePath:instancePath+"/canonicalization",schemaPath:"#/properties/canonicalization/const",keyword:"const",params:{allowedValue: "studio-json-v1"},message:"must be equal to constant"}]; +return false; +} +var valid0 = _errs2 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.byte_size !== undefined && func0.call(data, "byte_size")){ +let data1 = data.byte_size; +const _errs3 = errors; +const _errs4 = errors; +if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){ +validate23.errors = [{instancePath:instancePath+"/byte_size",schemaPath:"#/$defs/size/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; +return false; +} +if(errors === _errs4){ +if((typeof data1 == "number") && (isFinite(data1))){ +if(data1 > 9007199254740991 || isNaN(data1)){ +validate23.errors = [{instancePath:instancePath+"/byte_size",schemaPath:"#/$defs/size/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"}]; +return false; +} +else { +if(data1 < 0 || isNaN(data1)){ +validate23.errors = [{instancePath:instancePath+"/byte_size",schemaPath:"#/$defs/size/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"}]; +return false; +} +} +} +} +var valid0 = _errs3 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.sha256 !== undefined && func0.call(data, "sha256")){ +let data2 = data.sha256; +const _errs6 = errors; +const _errs7 = errors; +if(errors === _errs7){ +if(typeof data2 === "string"){ +if(!pattern7.test(data2)){ +validate23.errors = [{instancePath:instancePath+"/sha256",schemaPath:"#/$defs/digest/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""}]; +return false; +} +} +else { +validate23.errors = [{instancePath:instancePath+"/sha256",schemaPath:"#/$defs/digest/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs6 === errors; +} +else { +var valid0 = true; +} +} +} +} +} +} +else { +validate23.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +validate23.errors = vErrors; +return errors === 0; +} +validate23.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; + + +function validate22(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate22.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if(((((data.production_id === undefined) || (!(func0.call(data, "production_id")))) && (missing0 = "production_id")) || (((data.revision === undefined) || (!(func0.call(data, "revision")))) && (missing0 = "revision"))) || (((data.identity === undefined) || (!(func0.call(data, "identity")))) && (missing0 = "identity"))){ +validate22.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs1 = errors; +for(const key0 of Object.keys(data)){ +if(!(((key0 === "production_id") || (key0 === "revision")) || (key0 === "identity"))){ +validate22.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs1 === errors){ +if(data.production_id !== undefined && func0.call(data, "production_id")){ +let data0 = data.production_id; +const _errs2 = errors; +const _errs3 = errors; +if(errors === _errs3){ +if(typeof data0 === "string"){ +if(!pattern4.test(data0)){ +validate22.errors = [{instancePath:instancePath+"/production_id",schemaPath:"#/$defs/uuid/pattern",keyword:"pattern",params:{pattern: "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},message:"must match pattern \""+"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"+"\""}]; +return false; +} +} +else { +validate22.errors = [{instancePath:instancePath+"/production_id",schemaPath:"#/$defs/uuid/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs2 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.revision !== undefined && func0.call(data, "revision")){ +let data1 = data.revision; +const _errs5 = errors; +const _errs6 = errors; +if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){ +validate22.errors = [{instancePath:instancePath+"/revision",schemaPath:"#/$defs/revision/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; +return false; +} +if(errors === _errs6){ +if((typeof data1 == "number") && (isFinite(data1))){ +if(data1 > 9007199254740991 || isNaN(data1)){ +validate22.errors = [{instancePath:instancePath+"/revision",schemaPath:"#/$defs/revision/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"}]; +return false; +} +else { +if(data1 < 1 || isNaN(data1)){ +validate22.errors = [{instancePath:instancePath+"/revision",schemaPath:"#/$defs/revision/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"}]; +return false; +} +} +} +} +var valid0 = _errs5 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.identity !== undefined && func0.call(data, "identity")){ +const _errs8 = errors; +if(!(validate23(data.identity, {instancePath:instancePath+"/identity",parentData:data,parentDataProperty:"identity",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate23.errors : vErrors.concat(validate23.errors); +errors = vErrors.length; +} +var valid0 = _errs8 === errors; +} +else { +var valid0 = true; +} +} +} +} +} +} +else { +validate22.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +validate22.errors = vErrors; +return errors === 0; +} +validate22.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; + +const schema42 = {"type":"object","additionalProperties":false,"required":["canon","dependencies","prompts","assets"],"properties":{"canon":{"$ref":"#/$defs/dependency"},"dependencies":{"type":"array","items":{"$ref":"#/$defs/dependency"},"minItems":1,"maxItems":256},"prompts":{"type":"array","items":{"$ref":"#/$defs/prompt"},"minItems":0,"maxItems":256},"assets":{"type":"array","items":{"$ref":"#/$defs/asset"},"minItems":0,"maxItems":256}}}; +const schema43 = {"type":"object","additionalProperties":false,"required":["repository","version","tag","commit","artifact"],"properties":{"repository":{"type":"string","pattern":"^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$","maxLength":200},"version":{"type":"string","pattern":"^[0-9]+\\.[0-9]+\\.[0-9]+$"},"tag":{"type":"string","minLength":1,"maxLength":200},"commit":{"type":"string","pattern":"^[0-9a-f]{40}$"},"artifact":{"$ref":"#/$defs/artifact"}}}; +const func120 = require("ajv/dist/runtime/ucs2length").default; +const pattern8 = new RegExp("^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$", "u"); +const pattern9 = new RegExp("^[0-9]+\\.[0-9]+\\.[0-9]+$", "u"); +const pattern10 = new RegExp("^[0-9a-f]{40}$", "u"); +const schema44 = {"type":"object","additionalProperties":false,"required":["artifact_uri","media_type","byte_size","sha256"],"properties":{"artifact_uri":{"$ref":"#/$defs/uri"},"media_type":{"type":"string","minLength":1,"maxLength":128},"byte_size":{"$ref":"#/$defs/size"},"sha256":{"$ref":"#/$defs/digest"}}}; +const schema45 = {"type":"string","format":"uri","pattern":"^https://","maxLength":2048}; +const formats0 = require("ajv-formats/dist/formats").fullFormats.uri; +const pattern11 = new RegExp("^https://", "u"); + +function validate28(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate28.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if((((((data.artifact_uri === undefined) || (!(func0.call(data, "artifact_uri")))) && (missing0 = "artifact_uri")) || (((data.media_type === undefined) || (!(func0.call(data, "media_type")))) && (missing0 = "media_type"))) || (((data.byte_size === undefined) || (!(func0.call(data, "byte_size")))) && (missing0 = "byte_size"))) || (((data.sha256 === undefined) || (!(func0.call(data, "sha256")))) && (missing0 = "sha256"))){ +validate28.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs1 = errors; +for(const key0 of Object.keys(data)){ +if(!((((key0 === "artifact_uri") || (key0 === "media_type")) || (key0 === "byte_size")) || (key0 === "sha256"))){ +validate28.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs1 === errors){ +if(data.artifact_uri !== undefined && func0.call(data, "artifact_uri")){ +let data0 = data.artifact_uri; +const _errs2 = errors; +const _errs3 = errors; +if(errors === _errs3){ +if(errors === _errs3){ +if(typeof data0 === "string"){ +if(func120(data0) > 2048){ +validate28.errors = [{instancePath:instancePath+"/artifact_uri",schemaPath:"#/$defs/uri/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"}]; +return false; +} +else { +if(!pattern11.test(data0)){ +validate28.errors = [{instancePath:instancePath+"/artifact_uri",schemaPath:"#/$defs/uri/pattern",keyword:"pattern",params:{pattern: "^https://"},message:"must match pattern \""+"^https://"+"\""}]; +return false; +} +else { +if(!(formats0(data0))){ +validate28.errors = [{instancePath:instancePath+"/artifact_uri",schemaPath:"#/$defs/uri/format",keyword:"format",params:{format: "uri"},message:"must match format \""+"uri"+"\""}]; +return false; +} +} +} +} +else { +validate28.errors = [{instancePath:instancePath+"/artifact_uri",schemaPath:"#/$defs/uri/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +} +var valid0 = _errs2 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.media_type !== undefined && func0.call(data, "media_type")){ +let data1 = data.media_type; +const _errs5 = errors; +if(errors === _errs5){ +if(typeof data1 === "string"){ +if(func120(data1) > 128){ +validate28.errors = [{instancePath:instancePath+"/media_type",schemaPath:"#/properties/media_type/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}]; +return false; +} +else { +if(func120(data1) < 1){ +validate28.errors = [{instancePath:instancePath+"/media_type",schemaPath:"#/properties/media_type/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate28.errors = [{instancePath:instancePath+"/media_type",schemaPath:"#/properties/media_type/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs5 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.byte_size !== undefined && func0.call(data, "byte_size")){ +let data2 = data.byte_size; +const _errs7 = errors; +const _errs8 = errors; +if(!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))){ +validate28.errors = [{instancePath:instancePath+"/byte_size",schemaPath:"#/$defs/size/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; +return false; +} +if(errors === _errs8){ +if((typeof data2 == "number") && (isFinite(data2))){ +if(data2 > 9007199254740991 || isNaN(data2)){ +validate28.errors = [{instancePath:instancePath+"/byte_size",schemaPath:"#/$defs/size/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"}]; +return false; +} +else { +if(data2 < 0 || isNaN(data2)){ +validate28.errors = [{instancePath:instancePath+"/byte_size",schemaPath:"#/$defs/size/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"}]; +return false; +} +} +} +} +var valid0 = _errs7 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.sha256 !== undefined && func0.call(data, "sha256")){ +let data3 = data.sha256; +const _errs10 = errors; +const _errs11 = errors; +if(errors === _errs11){ +if(typeof data3 === "string"){ +if(!pattern7.test(data3)){ +validate28.errors = [{instancePath:instancePath+"/sha256",schemaPath:"#/$defs/digest/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""}]; +return false; +} +} +else { +validate28.errors = [{instancePath:instancePath+"/sha256",schemaPath:"#/$defs/digest/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs10 === errors; +} +else { +var valid0 = true; +} +} +} +} +} +} +} +else { +validate28.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +validate28.errors = vErrors; +return errors === 0; +} +validate28.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; + + +function validate27(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate27.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if(((((((data.repository === undefined) || (!(func0.call(data, "repository")))) && (missing0 = "repository")) || (((data.version === undefined) || (!(func0.call(data, "version")))) && (missing0 = "version"))) || (((data.tag === undefined) || (!(func0.call(data, "tag")))) && (missing0 = "tag"))) || (((data.commit === undefined) || (!(func0.call(data, "commit")))) && (missing0 = "commit"))) || (((data.artifact === undefined) || (!(func0.call(data, "artifact")))) && (missing0 = "artifact"))){ +validate27.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs1 = errors; +for(const key0 of Object.keys(data)){ +if(!(((((key0 === "repository") || (key0 === "version")) || (key0 === "tag")) || (key0 === "commit")) || (key0 === "artifact"))){ +validate27.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs1 === errors){ +if(data.repository !== undefined && func0.call(data, "repository")){ +let data0 = data.repository; +const _errs2 = errors; +if(errors === _errs2){ +if(typeof data0 === "string"){ +if(func120(data0) > 200){ +validate27.errors = [{instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"}]; +return false; +} +else { +if(!pattern8.test(data0)){ +validate27.errors = [{instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$"},message:"must match pattern \""+"^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$"+"\""}]; +return false; +} +} +} +else { +validate27.errors = [{instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs2 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.version !== undefined && func0.call(data, "version")){ +let data1 = data.version; +const _errs4 = errors; +if(errors === _errs4){ +if(typeof data1 === "string"){ +if(!pattern9.test(data1)){ +validate27.errors = [{instancePath:instancePath+"/version",schemaPath:"#/properties/version/pattern",keyword:"pattern",params:{pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$"},message:"must match pattern \""+"^[0-9]+\\.[0-9]+\\.[0-9]+$"+"\""}]; +return false; +} +} +else { +validate27.errors = [{instancePath:instancePath+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs4 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.tag !== undefined && func0.call(data, "tag")){ +let data2 = data.tag; +const _errs6 = errors; +if(errors === _errs6){ +if(typeof data2 === "string"){ +if(func120(data2) > 200){ +validate27.errors = [{instancePath:instancePath+"/tag",schemaPath:"#/properties/tag/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"}]; +return false; +} +else { +if(func120(data2) < 1){ +validate27.errors = [{instancePath:instancePath+"/tag",schemaPath:"#/properties/tag/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate27.errors = [{instancePath:instancePath+"/tag",schemaPath:"#/properties/tag/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs6 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.commit !== undefined && func0.call(data, "commit")){ +let data3 = data.commit; +const _errs8 = errors; +if(errors === _errs8){ +if(typeof data3 === "string"){ +if(!pattern10.test(data3)){ +validate27.errors = [{instancePath:instancePath+"/commit",schemaPath:"#/properties/commit/pattern",keyword:"pattern",params:{pattern: "^[0-9a-f]{40}$"},message:"must match pattern \""+"^[0-9a-f]{40}$"+"\""}]; +return false; +} +} +else { +validate27.errors = [{instancePath:instancePath+"/commit",schemaPath:"#/properties/commit/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs8 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.artifact !== undefined && func0.call(data, "artifact")){ +const _errs10 = errors; +if(!(validate28(data.artifact, {instancePath:instancePath+"/artifact",parentData:data,parentDataProperty:"artifact",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate28.errors : vErrors.concat(validate28.errors); +errors = vErrors.length; +} +var valid0 = _errs10 === errors; +} +else { +var valid0 = true; +} +} +} +} +} +} +} +} +else { +validate27.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +validate27.errors = vErrors; +return errors === 0; +} +validate27.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; + +const schema48 = {"type":"object","additionalProperties":false,"required":["binding_id","definition","prompt_id","prompt_version","identity","context"],"properties":{"binding_id":{"$ref":"#/$defs/name"},"definition":{"$ref":"#/$defs/dependency"},"prompt_id":{"type":"string","minLength":1,"maxLength":200},"prompt_version":{"type":"string","pattern":"^[0-9]+\\.[0-9]+\\.[0-9]+$"},"identity":{"$ref":"#/$defs/identity"},"context":{"anyOf":[{"$ref":"#/$defs/context"},{"type":"null"}]}}}; +const schema49 = {"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$"}; +const pattern13 = new RegExp("^[a-z][a-z0-9-]{0,63}$", "u"); +const schema50 = {"type":"object","additionalProperties":false,"required":["contract_version","package_id","package_version","instance_id","manifest_identity","classification","purpose","sections","builder_result_identity","preparation_reference","use_authorization_reference"],"properties":{"contract_version":{"const":"1.0.0"},"package_id":{"type":"string","minLength":1,"maxLength":200},"package_version":{"type":"string","minLength":1,"maxLength":32},"instance_id":{"$ref":"#/$defs/uuid"},"manifest_identity":{"$ref":"#/$defs/identity"},"classification":{"$ref":"#/$defs/classification"},"purpose":{"type":"string","minLength":1,"maxLength":4096},"sections":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":256},"builder_result_identity":{"$ref":"#/$defs/identity"},"preparation_reference":{"$ref":"#/$defs/uuid"},"use_authorization_reference":{"$ref":"#/$defs/uuid"}}}; + +function validate35(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate35.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if(((((((((((((data.contract_version === undefined) || (!(func0.call(data, "contract_version")))) && (missing0 = "contract_version")) || (((data.package_id === undefined) || (!(func0.call(data, "package_id")))) && (missing0 = "package_id"))) || (((data.package_version === undefined) || (!(func0.call(data, "package_version")))) && (missing0 = "package_version"))) || (((data.instance_id === undefined) || (!(func0.call(data, "instance_id")))) && (missing0 = "instance_id"))) || (((data.manifest_identity === undefined) || (!(func0.call(data, "manifest_identity")))) && (missing0 = "manifest_identity"))) || (((data.classification === undefined) || (!(func0.call(data, "classification")))) && (missing0 = "classification"))) || (((data.purpose === undefined) || (!(func0.call(data, "purpose")))) && (missing0 = "purpose"))) || (((data.sections === undefined) || (!(func0.call(data, "sections")))) && (missing0 = "sections"))) || (((data.builder_result_identity === undefined) || (!(func0.call(data, "builder_result_identity")))) && (missing0 = "builder_result_identity"))) || (((data.preparation_reference === undefined) || (!(func0.call(data, "preparation_reference")))) && (missing0 = "preparation_reference"))) || (((data.use_authorization_reference === undefined) || (!(func0.call(data, "use_authorization_reference")))) && (missing0 = "use_authorization_reference"))){ +validate35.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs1 = errors; +for(const key0 of Object.keys(data)){ +if(!(func0.call(schema50.properties, key0))){ +validate35.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs1 === errors){ +if(data.contract_version !== undefined && func0.call(data, "contract_version")){ +const _errs2 = errors; +if("1.0.0" !== data.contract_version){ +validate35.errors = [{instancePath:instancePath+"/contract_version",schemaPath:"#/properties/contract_version/const",keyword:"const",params:{allowedValue: "1.0.0"},message:"must be equal to constant"}]; +return false; +} +var valid0 = _errs2 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.package_id !== undefined && func0.call(data, "package_id")){ +let data1 = data.package_id; +const _errs3 = errors; +if(errors === _errs3){ +if(typeof data1 === "string"){ +if(func120(data1) > 200){ +validate35.errors = [{instancePath:instancePath+"/package_id",schemaPath:"#/properties/package_id/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"}]; +return false; +} +else { +if(func120(data1) < 1){ +validate35.errors = [{instancePath:instancePath+"/package_id",schemaPath:"#/properties/package_id/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate35.errors = [{instancePath:instancePath+"/package_id",schemaPath:"#/properties/package_id/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs3 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.package_version !== undefined && func0.call(data, "package_version")){ +let data2 = data.package_version; +const _errs5 = errors; +if(errors === _errs5){ +if(typeof data2 === "string"){ +if(func120(data2) > 32){ +validate35.errors = [{instancePath:instancePath+"/package_version",schemaPath:"#/properties/package_version/maxLength",keyword:"maxLength",params:{limit: 32},message:"must NOT have more than 32 characters"}]; +return false; +} +else { +if(func120(data2) < 1){ +validate35.errors = [{instancePath:instancePath+"/package_version",schemaPath:"#/properties/package_version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate35.errors = [{instancePath:instancePath+"/package_version",schemaPath:"#/properties/package_version/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs5 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.instance_id !== undefined && func0.call(data, "instance_id")){ +let data3 = data.instance_id; +const _errs7 = errors; +const _errs8 = errors; +if(errors === _errs8){ +if(typeof data3 === "string"){ +if(!pattern4.test(data3)){ +validate35.errors = [{instancePath:instancePath+"/instance_id",schemaPath:"#/$defs/uuid/pattern",keyword:"pattern",params:{pattern: "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},message:"must match pattern \""+"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"+"\""}]; +return false; +} +} +else { +validate35.errors = [{instancePath:instancePath+"/instance_id",schemaPath:"#/$defs/uuid/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs7 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.manifest_identity !== undefined && func0.call(data, "manifest_identity")){ +const _errs10 = errors; +if(!(validate23(data.manifest_identity, {instancePath:instancePath+"/manifest_identity",parentData:data,parentDataProperty:"manifest_identity",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate23.errors : vErrors.concat(validate23.errors); +errors = vErrors.length; +} +var valid0 = _errs10 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.classification !== undefined && func0.call(data, "classification")){ +let data5 = data.classification; +const _errs11 = errors; +if(!((((data5 === "public") || (data5 === "internal")) || (data5 === "confidential")) || (data5 === "restricted"))){ +validate35.errors = [{instancePath:instancePath+"/classification",schemaPath:"#/$defs/classification/enum",keyword:"enum",params:{allowedValues: schema41.enum},message:"must be equal to one of the allowed values"}]; +return false; +} +var valid0 = _errs11 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.purpose !== undefined && func0.call(data, "purpose")){ +let data6 = data.purpose; +const _errs13 = errors; +if(errors === _errs13){ +if(typeof data6 === "string"){ +if(func120(data6) > 4096){ +validate35.errors = [{instancePath:instancePath+"/purpose",schemaPath:"#/properties/purpose/maxLength",keyword:"maxLength",params:{limit: 4096},message:"must NOT have more than 4096 characters"}]; +return false; +} +else { +if(func120(data6) < 1){ +validate35.errors = [{instancePath:instancePath+"/purpose",schemaPath:"#/properties/purpose/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate35.errors = [{instancePath:instancePath+"/purpose",schemaPath:"#/properties/purpose/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs13 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.sections !== undefined && func0.call(data, "sections")){ +let data7 = data.sections; +const _errs15 = errors; +if(errors === _errs15){ +if(Array.isArray(data7)){ +if(data7.length > 256){ +validate35.errors = [{instancePath:instancePath+"/sections",schemaPath:"#/properties/sections/maxItems",keyword:"maxItems",params:{limit: 256},message:"must NOT have more than 256 items"}]; +return false; +} +else { +if(data7.length < 1){ +validate35.errors = [{instancePath:instancePath+"/sections",schemaPath:"#/properties/sections/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"}]; +return false; +} +else { +var valid3 = true; +const len0 = data7.length; +for(let i0=0; i0 128){ +validate35.errors = [{instancePath:instancePath+"/sections/" + i0,schemaPath:"#/properties/sections/items/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}]; +return false; +} +else { +if(func120(data8) < 1){ +validate35.errors = [{instancePath:instancePath+"/sections/" + i0,schemaPath:"#/properties/sections/items/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate35.errors = [{instancePath:instancePath+"/sections/" + i0,schemaPath:"#/properties/sections/items/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid3 = _errs17 === errors; +if(!valid3){ +break; +} +} +} +} +} +else { +validate35.errors = [{instancePath:instancePath+"/sections",schemaPath:"#/properties/sections/type",keyword:"type",params:{type: "array"},message:"must be array"}]; +return false; +} +} +var valid0 = _errs15 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.builder_result_identity !== undefined && func0.call(data, "builder_result_identity")){ +const _errs19 = errors; +if(!(validate23(data.builder_result_identity, {instancePath:instancePath+"/builder_result_identity",parentData:data,parentDataProperty:"builder_result_identity",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate23.errors : vErrors.concat(validate23.errors); +errors = vErrors.length; +} +var valid0 = _errs19 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.preparation_reference !== undefined && func0.call(data, "preparation_reference")){ +let data10 = data.preparation_reference; +const _errs20 = errors; +const _errs21 = errors; +if(errors === _errs21){ +if(typeof data10 === "string"){ +if(!pattern4.test(data10)){ +validate35.errors = [{instancePath:instancePath+"/preparation_reference",schemaPath:"#/$defs/uuid/pattern",keyword:"pattern",params:{pattern: "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},message:"must match pattern \""+"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"+"\""}]; +return false; +} +} +else { +validate35.errors = [{instancePath:instancePath+"/preparation_reference",schemaPath:"#/$defs/uuid/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs20 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.use_authorization_reference !== undefined && func0.call(data, "use_authorization_reference")){ +let data11 = data.use_authorization_reference; +const _errs23 = errors; +const _errs24 = errors; +if(errors === _errs24){ +if(typeof data11 === "string"){ +if(!pattern4.test(data11)){ +validate35.errors = [{instancePath:instancePath+"/use_authorization_reference",schemaPath:"#/$defs/uuid/pattern",keyword:"pattern",params:{pattern: "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},message:"must match pattern \""+"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"+"\""}]; +return false; +} +} +else { +validate35.errors = [{instancePath:instancePath+"/use_authorization_reference",schemaPath:"#/$defs/uuid/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs23 === errors; +} +else { +var valid0 = true; +} +} +} +} +} +} +} +} +} +} +} +} +} +} +else { +validate35.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +validate35.errors = vErrors; +return errors === 0; +} +validate35.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; + + +function validate32(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate32.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if((((((((data.binding_id === undefined) || (!(func0.call(data, "binding_id")))) && (missing0 = "binding_id")) || (((data.definition === undefined) || (!(func0.call(data, "definition")))) && (missing0 = "definition"))) || (((data.prompt_id === undefined) || (!(func0.call(data, "prompt_id")))) && (missing0 = "prompt_id"))) || (((data.prompt_version === undefined) || (!(func0.call(data, "prompt_version")))) && (missing0 = "prompt_version"))) || (((data.identity === undefined) || (!(func0.call(data, "identity")))) && (missing0 = "identity"))) || (((data.context === undefined) || (!(func0.call(data, "context")))) && (missing0 = "context"))){ +validate32.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs1 = errors; +for(const key0 of Object.keys(data)){ +if(!((((((key0 === "binding_id") || (key0 === "definition")) || (key0 === "prompt_id")) || (key0 === "prompt_version")) || (key0 === "identity")) || (key0 === "context"))){ +validate32.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs1 === errors){ +if(data.binding_id !== undefined && func0.call(data, "binding_id")){ +let data0 = data.binding_id; +const _errs2 = errors; +const _errs3 = errors; +if(errors === _errs3){ +if(typeof data0 === "string"){ +if(!pattern13.test(data0)){ +validate32.errors = [{instancePath:instancePath+"/binding_id",schemaPath:"#/$defs/name/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]{0,63}$"},message:"must match pattern \""+"^[a-z][a-z0-9-]{0,63}$"+"\""}]; +return false; +} +} +else { +validate32.errors = [{instancePath:instancePath+"/binding_id",schemaPath:"#/$defs/name/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs2 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.definition !== undefined && func0.call(data, "definition")){ +const _errs5 = errors; +if(!(validate27(data.definition, {instancePath:instancePath+"/definition",parentData:data,parentDataProperty:"definition",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate27.errors : vErrors.concat(validate27.errors); +errors = vErrors.length; +} +var valid0 = _errs5 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.prompt_id !== undefined && func0.call(data, "prompt_id")){ +let data2 = data.prompt_id; +const _errs6 = errors; +if(errors === _errs6){ +if(typeof data2 === "string"){ +if(func120(data2) > 200){ +validate32.errors = [{instancePath:instancePath+"/prompt_id",schemaPath:"#/properties/prompt_id/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"}]; +return false; +} +else { +if(func120(data2) < 1){ +validate32.errors = [{instancePath:instancePath+"/prompt_id",schemaPath:"#/properties/prompt_id/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate32.errors = [{instancePath:instancePath+"/prompt_id",schemaPath:"#/properties/prompt_id/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs6 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.prompt_version !== undefined && func0.call(data, "prompt_version")){ +let data3 = data.prompt_version; +const _errs8 = errors; +if(errors === _errs8){ +if(typeof data3 === "string"){ +if(!pattern9.test(data3)){ +validate32.errors = [{instancePath:instancePath+"/prompt_version",schemaPath:"#/properties/prompt_version/pattern",keyword:"pattern",params:{pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$"},message:"must match pattern \""+"^[0-9]+\\.[0-9]+\\.[0-9]+$"+"\""}]; +return false; +} +} +else { +validate32.errors = [{instancePath:instancePath+"/prompt_version",schemaPath:"#/properties/prompt_version/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs8 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.identity !== undefined && func0.call(data, "identity")){ +const _errs10 = errors; +if(!(validate23(data.identity, {instancePath:instancePath+"/identity",parentData:data,parentDataProperty:"identity",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate23.errors : vErrors.concat(validate23.errors); +errors = vErrors.length; +} +var valid0 = _errs10 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.context !== undefined && func0.call(data, "context")){ +let data5 = data.context; +const _errs11 = errors; +const _errs12 = errors; +let valid2 = false; +const _errs13 = errors; +if(!(validate35(data5, {instancePath:instancePath+"/context",parentData:data,parentDataProperty:"context",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate35.errors : vErrors.concat(validate35.errors); +errors = vErrors.length; +} +var _valid0 = _errs13 === errors; +valid2 = valid2 || _valid0; +const _errs14 = errors; +if(data5 !== null){ +const err0 = {instancePath:instancePath+"/context",schemaPath:"#/properties/context/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"}; +if(vErrors === null){ +vErrors = [err0]; +} +else { +vErrors.push(err0); +} +errors++; +} +var _valid0 = _errs14 === errors; +valid2 = valid2 || _valid0; +if(!valid2){ +const err1 = {instancePath:instancePath+"/context",schemaPath:"#/properties/context/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"}; +if(vErrors === null){ +vErrors = [err1]; +} +else { +vErrors.push(err1); +} +errors++; +validate32.errors = vErrors; +return false; +} +else { +errors = _errs12; +if(vErrors !== null){ +if(_errs12){ +vErrors.length = _errs12; +} +else { +vErrors = null; +} +} +} +var valid0 = _errs11 === errors; +} +else { +var valid0 = true; +} +} +} +} +} +} +} +} +} +else { +validate32.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +validate32.errors = vErrors; +return errors === 0; +} +validate32.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; + +const schema55 = {"type":"object","additionalProperties":false,"required":["asset_id","classification","reference","rights_notice"],"properties":{"asset_id":{"$ref":"#/$defs/name"},"classification":{"$ref":"#/$defs/classification"},"reference":{"oneOf":[{"type":"object","additionalProperties":false,"required":["kind","dependency"],"properties":{"kind":{"const":"public"},"dependency":{"$ref":"#/$defs/dependency"}}},{"type":"object","additionalProperties":false,"required":["kind","handle","media_type","byte_size","sha256"],"properties":{"kind":{"const":"protected"},"handle":{"$ref":"#/$defs/uuid"},"media_type":{"type":"string","minLength":1,"maxLength":128},"byte_size":{"$ref":"#/$defs/size"},"sha256":{"$ref":"#/$defs/digest"}}}]},"rights_notice":{"type":"string","minLength":1,"maxLength":4096}}}; + +function validate40(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate40.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if((((((data.asset_id === undefined) || (!(func0.call(data, "asset_id")))) && (missing0 = "asset_id")) || (((data.classification === undefined) || (!(func0.call(data, "classification")))) && (missing0 = "classification"))) || (((data.reference === undefined) || (!(func0.call(data, "reference")))) && (missing0 = "reference"))) || (((data.rights_notice === undefined) || (!(func0.call(data, "rights_notice")))) && (missing0 = "rights_notice"))){ +validate40.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs1 = errors; +for(const key0 of Object.keys(data)){ +if(!((((key0 === "asset_id") || (key0 === "classification")) || (key0 === "reference")) || (key0 === "rights_notice"))){ +validate40.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs1 === errors){ +if(data.asset_id !== undefined && func0.call(data, "asset_id")){ +let data0 = data.asset_id; +const _errs2 = errors; +const _errs3 = errors; +if(errors === _errs3){ +if(typeof data0 === "string"){ +if(!pattern13.test(data0)){ +validate40.errors = [{instancePath:instancePath+"/asset_id",schemaPath:"#/$defs/name/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]{0,63}$"},message:"must match pattern \""+"^[a-z][a-z0-9-]{0,63}$"+"\""}]; +return false; +} +} +else { +validate40.errors = [{instancePath:instancePath+"/asset_id",schemaPath:"#/$defs/name/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs2 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.classification !== undefined && func0.call(data, "classification")){ +let data1 = data.classification; +const _errs5 = errors; +if(!((((data1 === "public") || (data1 === "internal")) || (data1 === "confidential")) || (data1 === "restricted"))){ +validate40.errors = [{instancePath:instancePath+"/classification",schemaPath:"#/$defs/classification/enum",keyword:"enum",params:{allowedValues: schema41.enum},message:"must be equal to one of the allowed values"}]; +return false; +} +var valid0 = _errs5 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.reference !== undefined && func0.call(data, "reference")){ +let data2 = data.reference; +const _errs7 = errors; +const _errs8 = errors; +let valid3 = false; +let passing0 = null; +const _errs9 = errors; +if(errors === _errs9){ +if(data2 && typeof data2 == "object" && !Array.isArray(data2)){ +let missing1; +if((((data2.kind === undefined) || (!(func0.call(data2, "kind")))) && (missing1 = "kind")) || (((data2.dependency === undefined) || (!(func0.call(data2, "dependency")))) && (missing1 = "dependency"))){ +const err0 = {instancePath:instancePath+"/reference",schemaPath:"#/properties/reference/oneOf/0/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}; +if(vErrors === null){ +vErrors = [err0]; +} +else { +vErrors.push(err0); +} +errors++; +} +else { +const _errs11 = errors; +for(const key1 of Object.keys(data2)){ +if(!((key1 === "kind") || (key1 === "dependency"))){ +const err1 = {instancePath:instancePath+"/reference",schemaPath:"#/properties/reference/oneOf/0/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"}; +if(vErrors === null){ +vErrors = [err1]; +} +else { +vErrors.push(err1); +} +errors++; +break; +} +} +if(_errs11 === errors){ +if(data2.kind !== undefined && func0.call(data2, "kind")){ +const _errs12 = errors; +if("public" !== data2.kind){ +const err2 = {instancePath:instancePath+"/reference/kind",schemaPath:"#/properties/reference/oneOf/0/properties/kind/const",keyword:"const",params:{allowedValue: "public"},message:"must be equal to constant"}; +if(vErrors === null){ +vErrors = [err2]; +} +else { +vErrors.push(err2); +} +errors++; +} +var valid4 = _errs12 === errors; +} +else { +var valid4 = true; +} +if(valid4){ +if(data2.dependency !== undefined && func0.call(data2, "dependency")){ +const _errs13 = errors; +if(!(validate27(data2.dependency, {instancePath:instancePath+"/reference/dependency",parentData:data2,parentDataProperty:"dependency",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate27.errors : vErrors.concat(validate27.errors); +errors = vErrors.length; +} +var valid4 = _errs13 === errors; +} +else { +var valid4 = true; +} +} +} +} +} +else { +const err3 = {instancePath:instancePath+"/reference",schemaPath:"#/properties/reference/oneOf/0/type",keyword:"type",params:{type: "object"},message:"must be object"}; +if(vErrors === null){ +vErrors = [err3]; +} +else { +vErrors.push(err3); +} +errors++; +} +} +var _valid0 = _errs9 === errors; +if(_valid0){ +valid3 = true; +passing0 = 0; +var props0 = true; +} +const _errs14 = errors; +if(errors === _errs14){ +if(data2 && typeof data2 == "object" && !Array.isArray(data2)){ +let missing2; +if(((((((data2.kind === undefined) || (!(func0.call(data2, "kind")))) && (missing2 = "kind")) || (((data2.handle === undefined) || (!(func0.call(data2, "handle")))) && (missing2 = "handle"))) || (((data2.media_type === undefined) || (!(func0.call(data2, "media_type")))) && (missing2 = "media_type"))) || (((data2.byte_size === undefined) || (!(func0.call(data2, "byte_size")))) && (missing2 = "byte_size"))) || (((data2.sha256 === undefined) || (!(func0.call(data2, "sha256")))) && (missing2 = "sha256"))){ +const err4 = {instancePath:instancePath+"/reference",schemaPath:"#/properties/reference/oneOf/1/required",keyword:"required",params:{missingProperty: missing2},message:"must have required property '"+missing2+"'"}; +if(vErrors === null){ +vErrors = [err4]; +} +else { +vErrors.push(err4); +} +errors++; +} +else { +const _errs16 = errors; +for(const key2 of Object.keys(data2)){ +if(!(((((key2 === "kind") || (key2 === "handle")) || (key2 === "media_type")) || (key2 === "byte_size")) || (key2 === "sha256"))){ +const err5 = {instancePath:instancePath+"/reference",schemaPath:"#/properties/reference/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"}; +if(vErrors === null){ +vErrors = [err5]; +} +else { +vErrors.push(err5); +} +errors++; +break; +} +} +if(_errs16 === errors){ +if(data2.kind !== undefined && func0.call(data2, "kind")){ +const _errs17 = errors; +if("protected" !== data2.kind){ +const err6 = {instancePath:instancePath+"/reference/kind",schemaPath:"#/properties/reference/oneOf/1/properties/kind/const",keyword:"const",params:{allowedValue: "protected"},message:"must be equal to constant"}; +if(vErrors === null){ +vErrors = [err6]; +} +else { +vErrors.push(err6); +} +errors++; +} +var valid5 = _errs17 === errors; +} +else { +var valid5 = true; +} +if(valid5){ +if(data2.handle !== undefined && func0.call(data2, "handle")){ +let data6 = data2.handle; +const _errs18 = errors; +const _errs19 = errors; +if(errors === _errs19){ +if(typeof data6 === "string"){ +if(!pattern4.test(data6)){ +const err7 = {instancePath:instancePath+"/reference/handle",schemaPath:"#/$defs/uuid/pattern",keyword:"pattern",params:{pattern: "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},message:"must match pattern \""+"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"+"\""}; +if(vErrors === null){ +vErrors = [err7]; +} +else { +vErrors.push(err7); +} +errors++; +} +} +else { +const err8 = {instancePath:instancePath+"/reference/handle",schemaPath:"#/$defs/uuid/type",keyword:"type",params:{type: "string"},message:"must be string"}; +if(vErrors === null){ +vErrors = [err8]; +} +else { +vErrors.push(err8); +} +errors++; +} +} +var valid5 = _errs18 === errors; +} +else { +var valid5 = true; +} +if(valid5){ +if(data2.media_type !== undefined && func0.call(data2, "media_type")){ +let data7 = data2.media_type; +const _errs21 = errors; +if(errors === _errs21){ +if(typeof data7 === "string"){ +if(func120(data7) > 128){ +const err9 = {instancePath:instancePath+"/reference/media_type",schemaPath:"#/properties/reference/oneOf/1/properties/media_type/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}; +if(vErrors === null){ +vErrors = [err9]; +} +else { +vErrors.push(err9); +} +errors++; +} +else { +if(func120(data7) < 1){ +const err10 = {instancePath:instancePath+"/reference/media_type",schemaPath:"#/properties/reference/oneOf/1/properties/media_type/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}; +if(vErrors === null){ +vErrors = [err10]; +} +else { +vErrors.push(err10); +} +errors++; +} +} +} +else { +const err11 = {instancePath:instancePath+"/reference/media_type",schemaPath:"#/properties/reference/oneOf/1/properties/media_type/type",keyword:"type",params:{type: "string"},message:"must be string"}; +if(vErrors === null){ +vErrors = [err11]; +} +else { +vErrors.push(err11); +} +errors++; +} +} +var valid5 = _errs21 === errors; +} +else { +var valid5 = true; +} +if(valid5){ +if(data2.byte_size !== undefined && func0.call(data2, "byte_size")){ +let data8 = data2.byte_size; +const _errs23 = errors; +const _errs24 = errors; +if(!(((typeof data8 == "number") && (!(data8 % 1) && !isNaN(data8))) && (isFinite(data8)))){ +const err12 = {instancePath:instancePath+"/reference/byte_size",schemaPath:"#/$defs/size/type",keyword:"type",params:{type: "integer"},message:"must be integer"}; +if(vErrors === null){ +vErrors = [err12]; +} +else { +vErrors.push(err12); +} +errors++; +} +if(errors === _errs24){ +if((typeof data8 == "number") && (isFinite(data8))){ +if(data8 > 9007199254740991 || isNaN(data8)){ +const err13 = {instancePath:instancePath+"/reference/byte_size",schemaPath:"#/$defs/size/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"}; +if(vErrors === null){ +vErrors = [err13]; +} +else { +vErrors.push(err13); +} +errors++; +} +else { +if(data8 < 0 || isNaN(data8)){ +const err14 = {instancePath:instancePath+"/reference/byte_size",schemaPath:"#/$defs/size/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"}; +if(vErrors === null){ +vErrors = [err14]; +} +else { +vErrors.push(err14); +} +errors++; +} +} +} +} +var valid5 = _errs23 === errors; +} +else { +var valid5 = true; +} +if(valid5){ +if(data2.sha256 !== undefined && func0.call(data2, "sha256")){ +let data9 = data2.sha256; +const _errs26 = errors; +const _errs27 = errors; +if(errors === _errs27){ +if(typeof data9 === "string"){ +if(!pattern7.test(data9)){ +const err15 = {instancePath:instancePath+"/reference/sha256",schemaPath:"#/$defs/digest/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""}; +if(vErrors === null){ +vErrors = [err15]; +} +else { +vErrors.push(err15); +} +errors++; +} +} +else { +const err16 = {instancePath:instancePath+"/reference/sha256",schemaPath:"#/$defs/digest/type",keyword:"type",params:{type: "string"},message:"must be string"}; +if(vErrors === null){ +vErrors = [err16]; +} +else { +vErrors.push(err16); +} +errors++; +} +} +var valid5 = _errs26 === errors; +} +else { +var valid5 = true; +} +} +} +} +} +} +} +} +else { +const err17 = {instancePath:instancePath+"/reference",schemaPath:"#/properties/reference/oneOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"}; +if(vErrors === null){ +vErrors = [err17]; +} +else { +vErrors.push(err17); +} +errors++; +} +} +var _valid0 = _errs14 === errors; +if(_valid0 && valid3){ +valid3 = false; +passing0 = [passing0, 1]; +} +else { +if(_valid0){ +valid3 = true; +passing0 = 1; +if(props0 !== true){ +props0 = true; +} +} +} +if(!valid3){ +const err18 = {instancePath:instancePath+"/reference",schemaPath:"#/properties/reference/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"}; +if(vErrors === null){ +vErrors = [err18]; +} +else { +vErrors.push(err18); +} +errors++; +validate40.errors = vErrors; +return false; +} +else { +errors = _errs8; +if(vErrors !== null){ +if(_errs8){ +vErrors.length = _errs8; +} +else { +vErrors = null; +} +} +} +var valid0 = _errs7 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.rights_notice !== undefined && func0.call(data, "rights_notice")){ +let data10 = data.rights_notice; +const _errs29 = errors; +if(errors === _errs29){ +if(typeof data10 === "string"){ +if(func120(data10) > 4096){ +validate40.errors = [{instancePath:instancePath+"/rights_notice",schemaPath:"#/properties/rights_notice/maxLength",keyword:"maxLength",params:{limit: 4096},message:"must NOT have more than 4096 characters"}]; +return false; +} +else { +if(func120(data10) < 1){ +validate40.errors = [{instancePath:instancePath+"/rights_notice",schemaPath:"#/properties/rights_notice/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate40.errors = [{instancePath:instancePath+"/rights_notice",schemaPath:"#/properties/rights_notice/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs29 === errors; +} +else { +var valid0 = true; +} +} +} +} +} +} +} +else { +validate40.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +validate40.errors = vErrors; +return errors === 0; +} +validate40.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; + + +function validate26(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate26.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if((((((data.canon === undefined) || (!(func0.call(data, "canon")))) && (missing0 = "canon")) || (((data.dependencies === undefined) || (!(func0.call(data, "dependencies")))) && (missing0 = "dependencies"))) || (((data.prompts === undefined) || (!(func0.call(data, "prompts")))) && (missing0 = "prompts"))) || (((data.assets === undefined) || (!(func0.call(data, "assets")))) && (missing0 = "assets"))){ +validate26.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs1 = errors; +for(const key0 of Object.keys(data)){ +if(!((((key0 === "canon") || (key0 === "dependencies")) || (key0 === "prompts")) || (key0 === "assets"))){ +validate26.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs1 === errors){ +if(data.canon !== undefined && func0.call(data, "canon")){ +const _errs2 = errors; +if(!(validate27(data.canon, {instancePath:instancePath+"/canon",parentData:data,parentDataProperty:"canon",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate27.errors : vErrors.concat(validate27.errors); +errors = vErrors.length; +} +var valid0 = _errs2 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.dependencies !== undefined && func0.call(data, "dependencies")){ +let data1 = data.dependencies; +const _errs3 = errors; +if(errors === _errs3){ +if(Array.isArray(data1)){ +if(data1.length > 256){ +validate26.errors = [{instancePath:instancePath+"/dependencies",schemaPath:"#/properties/dependencies/maxItems",keyword:"maxItems",params:{limit: 256},message:"must NOT have more than 256 items"}]; +return false; +} +else { +if(data1.length < 1){ +validate26.errors = [{instancePath:instancePath+"/dependencies",schemaPath:"#/properties/dependencies/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"}]; +return false; +} +else { +var valid1 = true; +const len0 = data1.length; +for(let i0=0; i0 256){ +validate26.errors = [{instancePath:instancePath+"/prompts",schemaPath:"#/properties/prompts/maxItems",keyword:"maxItems",params:{limit: 256},message:"must NOT have more than 256 items"}]; +return false; +} +else { +if(data3.length < 0){ +validate26.errors = [{instancePath:instancePath+"/prompts",schemaPath:"#/properties/prompts/minItems",keyword:"minItems",params:{limit: 0},message:"must NOT have fewer than 0 items"}]; +return false; +} +else { +var valid2 = true; +const len1 = data3.length; +for(let i1=0; i1 256){ +validate26.errors = [{instancePath:instancePath+"/assets",schemaPath:"#/properties/assets/maxItems",keyword:"maxItems",params:{limit: 256},message:"must NOT have more than 256 items"}]; +return false; +} +else { +if(data5.length < 0){ +validate26.errors = [{instancePath:instancePath+"/assets",schemaPath:"#/properties/assets/minItems",keyword:"minItems",params:{limit: 0},message:"must NOT have fewer than 0 items"}]; +return false; +} +else { +var valid3 = true; +const len2 = data5.length; +for(let i2=0; i2 2048){ +const err0 = {instancePath:instancePath+"/artifact/artifact_uri",schemaPath:"#/$defs/uri/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"}; +if(vErrors === null){ +vErrors = [err0]; +} +else { +vErrors.push(err0); +} +errors++; +} +else { +if(!pattern11.test(data2)){ +const err1 = {instancePath:instancePath+"/artifact/artifact_uri",schemaPath:"#/$defs/uri/pattern",keyword:"pattern",params:{pattern: "^https://"},message:"must match pattern \""+"^https://"+"\""}; +if(vErrors === null){ +vErrors = [err1]; +} +else { +vErrors.push(err1); +} +errors++; +} +else { +if(!(formats0(data2))){ +const err2 = {instancePath:instancePath+"/artifact/artifact_uri",schemaPath:"#/$defs/uri/format",keyword:"format",params:{format: "uri"},message:"must match format \""+"uri"+"\""}; +if(vErrors === null){ +vErrors = [err2]; +} +else { +vErrors.push(err2); +} +errors++; +} +} +} +} +else { +const err3 = {instancePath:instancePath+"/artifact/artifact_uri",schemaPath:"#/$defs/uri/type",keyword:"type",params:{type: "string"},message:"must be string"}; +if(vErrors === null){ +vErrors = [err3]; +} +else { +vErrors.push(err3); +} +errors++; +} +} +} +var _valid0 = _errs10 === errors; +if(_valid0){ +valid3 = true; +passing0 = 0; +} +const _errs13 = errors; +const _errs14 = errors; +if(errors === _errs14){ +if(typeof data2 === "string"){ +if(!pattern4.test(data2)){ +const err4 = {instancePath:instancePath+"/artifact/artifact_uri",schemaPath:"#/$defs/uuid/pattern",keyword:"pattern",params:{pattern: "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},message:"must match pattern \""+"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"+"\""}; +if(vErrors === null){ +vErrors = [err4]; +} +else { +vErrors.push(err4); +} +errors++; +} +} +else { +const err5 = {instancePath:instancePath+"/artifact/artifact_uri",schemaPath:"#/$defs/uuid/type",keyword:"type",params:{type: "string"},message:"must be string"}; +if(vErrors === null){ +vErrors = [err5]; +} +else { +vErrors.push(err5); +} +errors++; +} +} +var _valid0 = _errs13 === errors; +if(_valid0 && valid3){ +valid3 = false; +passing0 = [passing0, 1]; +} +else { +if(_valid0){ +valid3 = true; +passing0 = 1; +} +} +if(!valid3){ +const err6 = {instancePath:instancePath+"/artifact/artifact_uri",schemaPath:"#/properties/artifact/properties/artifact_uri/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"}; +if(vErrors === null){ +vErrors = [err6]; +} +else { +vErrors.push(err6); +} +errors++; +validate44.errors = vErrors; +return false; +} +else { +errors = _errs9; +if(vErrors !== null){ +if(_errs9){ +vErrors.length = _errs9; +} +else { +vErrors = null; +} +} +} +var valid2 = _errs8 === errors; +} +else { +var valid2 = true; +} +if(valid2){ +if(data1.media_type !== undefined && func0.call(data1, "media_type")){ +let data3 = data1.media_type; +const _errs16 = errors; +if(errors === _errs16){ +if(typeof data3 === "string"){ +if(func120(data3) > 128){ +validate44.errors = [{instancePath:instancePath+"/artifact/media_type",schemaPath:"#/properties/artifact/properties/media_type/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}]; +return false; +} +else { +if(func120(data3) < 1){ +validate44.errors = [{instancePath:instancePath+"/artifact/media_type",schemaPath:"#/properties/artifact/properties/media_type/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate44.errors = [{instancePath:instancePath+"/artifact/media_type",schemaPath:"#/properties/artifact/properties/media_type/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid2 = _errs16 === errors; +} +else { +var valid2 = true; +} +if(valid2){ +if(data1.byte_size !== undefined && func0.call(data1, "byte_size")){ +let data4 = data1.byte_size; +const _errs18 = errors; +const _errs19 = errors; +if(!(((typeof data4 == "number") && (!(data4 % 1) && !isNaN(data4))) && (isFinite(data4)))){ +validate44.errors = [{instancePath:instancePath+"/artifact/byte_size",schemaPath:"#/$defs/size/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; +return false; +} +if(errors === _errs19){ +if((typeof data4 == "number") && (isFinite(data4))){ +if(data4 > 9007199254740991 || isNaN(data4)){ +validate44.errors = [{instancePath:instancePath+"/artifact/byte_size",schemaPath:"#/$defs/size/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"}]; +return false; +} +else { +if(data4 < 0 || isNaN(data4)){ +validate44.errors = [{instancePath:instancePath+"/artifact/byte_size",schemaPath:"#/$defs/size/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"}]; +return false; +} +} +} +} +var valid2 = _errs18 === errors; +} +else { +var valid2 = true; +} +if(valid2){ +if(data1.sha256 !== undefined && func0.call(data1, "sha256")){ +let data5 = data1.sha256; +const _errs21 = errors; +const _errs22 = errors; +if(errors === _errs22){ +if(typeof data5 === "string"){ +if(!pattern7.test(data5)){ +validate44.errors = [{instancePath:instancePath+"/artifact/sha256",schemaPath:"#/$defs/digest/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""}]; +return false; +} +} +else { +validate44.errors = [{instancePath:instancePath+"/artifact/sha256",schemaPath:"#/$defs/digest/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid2 = _errs21 === errors; +} +else { +var valid2 = true; +} +} +} +} +} +} +} +else { +validate44.errors = [{instancePath:instancePath+"/artifact",schemaPath:"#/properties/artifact/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +var valid0 = _errs5 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.profile !== undefined && func0.call(data, "profile")){ +let data6 = data.profile; +const _errs24 = errors; +const _errs25 = errors; +if(errors === _errs25){ +if(data6 && typeof data6 == "object" && !Array.isArray(data6)){ +let missing2; +if((((data6.profile_id === undefined) || (!(func0.call(data6, "profile_id")))) && (missing2 = "profile_id")) || (((data6.profile_version === undefined) || (!(func0.call(data6, "profile_version")))) && (missing2 = "profile_version"))){ +validate44.errors = [{instancePath:instancePath+"/profile",schemaPath:"#/$defs/renditionProfile/required",keyword:"required",params:{missingProperty: missing2},message:"must have required property '"+missing2+"'"}]; +return false; +} +else { +const _errs27 = errors; +for(const key2 of Object.keys(data6)){ +if(!((key2 === "profile_id") || (key2 === "profile_version"))){ +validate44.errors = [{instancePath:instancePath+"/profile",schemaPath:"#/$defs/renditionProfile/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs27 === errors){ +if(data6.profile_id !== undefined && func0.call(data6, "profile_id")){ +let data7 = data6.profile_id; +const _errs28 = errors; +if(!(((data7 === "comic-page-image") || (data7 === "comic-portable-document")) || (data7 === "comic-accessible-transcript"))){ +validate44.errors = [{instancePath:instancePath+"/profile/profile_id",schemaPath:"#/$defs/renditionProfile/properties/profile_id/enum",keyword:"enum",params:{allowedValues: schema67.properties.profile_id.enum},message:"must be equal to one of the allowed values"}]; +return false; +} +var valid9 = _errs28 === errors; +} +else { +var valid9 = true; +} +if(valid9){ +if(data6.profile_version !== undefined && func0.call(data6, "profile_version")){ +const _errs29 = errors; +if("1.0.0" !== data6.profile_version){ +validate44.errors = [{instancePath:instancePath+"/profile/profile_version",schemaPath:"#/$defs/renditionProfile/properties/profile_version/const",keyword:"const",params:{allowedValue: "1.0.0"},message:"must be equal to constant"}]; +return false; +} +var valid9 = _errs29 === errors; +} +else { +var valid9 = true; +} +} +} +} +} +else { +validate44.errors = [{instancePath:instancePath+"/profile",schemaPath:"#/$defs/renditionProfile/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +var valid0 = _errs24 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.dimensions !== undefined && func0.call(data, "dimensions")){ +let data9 = data.dimensions; +const _errs30 = errors; +const _errs32 = errors; +let valid11 = false; +const _errs33 = errors; +if(errors === _errs33){ +if(data9 && typeof data9 == "object" && !Array.isArray(data9)){ +let missing3; +if((((data9.width === undefined) || (!(func0.call(data9, "width")))) && (missing3 = "width")) || (((data9.height === undefined) || (!(func0.call(data9, "height")))) && (missing3 = "height"))){ +const err7 = {instancePath:instancePath+"/dimensions",schemaPath:"#/$defs/dimensions/anyOf/0/required",keyword:"required",params:{missingProperty: missing3},message:"must have required property '"+missing3+"'"}; +if(vErrors === null){ +vErrors = [err7]; +} +else { +vErrors.push(err7); +} +errors++; +} +else { +const _errs35 = errors; +for(const key3 of Object.keys(data9)){ +if(!((key3 === "width") || (key3 === "height"))){ +const err8 = {instancePath:instancePath+"/dimensions",schemaPath:"#/$defs/dimensions/anyOf/0/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"}; +if(vErrors === null){ +vErrors = [err8]; +} +else { +vErrors.push(err8); +} +errors++; +break; +} +} +if(_errs35 === errors){ +if(data9.width !== undefined && func0.call(data9, "width")){ +let data10 = data9.width; +const _errs36 = errors; +if(!(((typeof data10 == "number") && (!(data10 % 1) && !isNaN(data10))) && (isFinite(data10)))){ +const err9 = {instancePath:instancePath+"/dimensions/width",schemaPath:"#/$defs/dimensions/anyOf/0/properties/width/type",keyword:"type",params:{type: "integer"},message:"must be integer"}; +if(vErrors === null){ +vErrors = [err9]; +} +else { +vErrors.push(err9); +} +errors++; +} +if(errors === _errs36){ +if((typeof data10 == "number") && (isFinite(data10))){ +if(data10 > 32768 || isNaN(data10)){ +const err10 = {instancePath:instancePath+"/dimensions/width",schemaPath:"#/$defs/dimensions/anyOf/0/properties/width/maximum",keyword:"maximum",params:{comparison: "<=", limit: 32768},message:"must be <= 32768"}; +if(vErrors === null){ +vErrors = [err10]; +} +else { +vErrors.push(err10); +} +errors++; +} +else { +if(data10 < 1 || isNaN(data10)){ +const err11 = {instancePath:instancePath+"/dimensions/width",schemaPath:"#/$defs/dimensions/anyOf/0/properties/width/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"}; +if(vErrors === null){ +vErrors = [err11]; +} +else { +vErrors.push(err11); +} +errors++; +} +} +} +} +var valid12 = _errs36 === errors; +} +else { +var valid12 = true; +} +if(valid12){ +if(data9.height !== undefined && func0.call(data9, "height")){ +let data11 = data9.height; +const _errs38 = errors; +if(!(((typeof data11 == "number") && (!(data11 % 1) && !isNaN(data11))) && (isFinite(data11)))){ +const err12 = {instancePath:instancePath+"/dimensions/height",schemaPath:"#/$defs/dimensions/anyOf/0/properties/height/type",keyword:"type",params:{type: "integer"},message:"must be integer"}; +if(vErrors === null){ +vErrors = [err12]; +} +else { +vErrors.push(err12); +} +errors++; +} +if(errors === _errs38){ +if((typeof data11 == "number") && (isFinite(data11))){ +if(data11 > 32768 || isNaN(data11)){ +const err13 = {instancePath:instancePath+"/dimensions/height",schemaPath:"#/$defs/dimensions/anyOf/0/properties/height/maximum",keyword:"maximum",params:{comparison: "<=", limit: 32768},message:"must be <= 32768"}; +if(vErrors === null){ +vErrors = [err13]; +} +else { +vErrors.push(err13); +} +errors++; +} +else { +if(data11 < 1 || isNaN(data11)){ +const err14 = {instancePath:instancePath+"/dimensions/height",schemaPath:"#/$defs/dimensions/anyOf/0/properties/height/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"}; +if(vErrors === null){ +vErrors = [err14]; +} +else { +vErrors.push(err14); +} +errors++; +} +} +} +} +var valid12 = _errs38 === errors; +} +else { +var valid12 = true; +} +} +} +} +} +else { +const err15 = {instancePath:instancePath+"/dimensions",schemaPath:"#/$defs/dimensions/anyOf/0/type",keyword:"type",params:{type: "object"},message:"must be object"}; +if(vErrors === null){ +vErrors = [err15]; +} +else { +vErrors.push(err15); +} +errors++; +} +} +var _valid1 = _errs33 === errors; +valid11 = valid11 || _valid1; +const _errs40 = errors; +if(data9 !== null){ +const err16 = {instancePath:instancePath+"/dimensions",schemaPath:"#/$defs/dimensions/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"}; +if(vErrors === null){ +vErrors = [err16]; +} +else { +vErrors.push(err16); +} +errors++; +} +var _valid1 = _errs40 === errors; +valid11 = valid11 || _valid1; +if(!valid11){ +const err17 = {instancePath:instancePath+"/dimensions",schemaPath:"#/$defs/dimensions/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"}; +if(vErrors === null){ +vErrors = [err17]; +} +else { +vErrors.push(err17); +} +errors++; +validate44.errors = vErrors; +return false; +} +else { +errors = _errs32; +if(vErrors !== null){ +if(_errs32){ +vErrors.length = _errs32; +} +else { +vErrors = null; +} +} +} +var valid0 = _errs30 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.max_bytes !== undefined && func0.call(data, "max_bytes")){ +let data12 = data.max_bytes; +const _errs42 = errors; +if(!(((typeof data12 == "number") && (!(data12 % 1) && !isNaN(data12))) && (isFinite(data12)))){ +validate44.errors = [{instancePath:instancePath+"/max_bytes",schemaPath:"#/properties/max_bytes/type",keyword:"type",params:{type: "integer"},message:"must be integer"}]; +return false; +} +if(errors === _errs42){ +if((typeof data12 == "number") && (isFinite(data12))){ +if(data12 > 50000000 || isNaN(data12)){ +validate44.errors = [{instancePath:instancePath+"/max_bytes",schemaPath:"#/properties/max_bytes/maximum",keyword:"maximum",params:{comparison: "<=", limit: 50000000},message:"must be <= 50000000"}]; +return false; +} +else { +if(data12 < 1 || isNaN(data12)){ +validate44.errors = [{instancePath:instancePath+"/max_bytes",schemaPath:"#/properties/max_bytes/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"}]; +return false; +} +} +} +} +var valid0 = _errs42 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.rights_notice !== undefined && func0.call(data, "rights_notice")){ +let data13 = data.rights_notice; +const _errs44 = errors; +if(errors === _errs44){ +if(typeof data13 === "string"){ +if(func120(data13) > 4096){ +validate44.errors = [{instancePath:instancePath+"/rights_notice",schemaPath:"#/properties/rights_notice/maxLength",keyword:"maxLength",params:{limit: 4096},message:"must NOT have more than 4096 characters"}]; +return false; +} +else { +if(func120(data13) < 1){ +validate44.errors = [{instancePath:instancePath+"/rights_notice",schemaPath:"#/properties/rights_notice/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate44.errors = [{instancePath:instancePath+"/rights_notice",schemaPath:"#/properties/rights_notice/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs44 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.alt_text !== undefined && func0.call(data, "alt_text")){ +let data14 = data.alt_text; +const _errs46 = errors; +if(errors === _errs46){ +if(typeof data14 === "string"){ +if(func120(data14) > 4096){ +validate44.errors = [{instancePath:instancePath+"/alt_text",schemaPath:"#/properties/alt_text/maxLength",keyword:"maxLength",params:{limit: 4096},message:"must NOT have more than 4096 characters"}]; +return false; +} +else { +if(func120(data14) < 1){ +validate44.errors = [{instancePath:instancePath+"/alt_text",schemaPath:"#/properties/alt_text/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate44.errors = [{instancePath:instancePath+"/alt_text",schemaPath:"#/properties/alt_text/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs46 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.transcript !== undefined && func0.call(data, "transcript")){ +let data15 = data.transcript; +const _errs48 = errors; +if(errors === _errs48){ +if(typeof data15 === "string"){ +if(func120(data15) > 32768){ +validate44.errors = [{instancePath:instancePath+"/transcript",schemaPath:"#/properties/transcript/maxLength",keyword:"maxLength",params:{limit: 32768},message:"must NOT have more than 32768 characters"}]; +return false; +} +else { +if(func120(data15) < 1){ +validate44.errors = [{instancePath:instancePath+"/transcript",schemaPath:"#/properties/transcript/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate44.errors = [{instancePath:instancePath+"/transcript",schemaPath:"#/properties/transcript/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs48 === errors; +} +else { +var valid0 = true; +} +} +} +} +} +} +} +} +} +} +} +else { +validate44.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +validate44.errors = vErrors; +return errors === 0; +} +validate44.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; + +const schema69 = {"type":"object","additionalProperties":false,"required":["gate","disposition","evidence_reference","rationale"],"properties":{"gate":{"enum":["editorial","canon-continuity","visual-text","integrity","provenance","security-privacy","rights","accessibility","packaging"]},"disposition":{"enum":["pass","fail","inconclusive","not-run","not-applicable"]},"evidence_reference":{"$ref":"#/$defs/uuid"},"rationale":{"type":"string","minLength":1,"maxLength":4096}}}; + +function validate46(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate46.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if((((((data.gate === undefined) || (!(func0.call(data, "gate")))) && (missing0 = "gate")) || (((data.disposition === undefined) || (!(func0.call(data, "disposition")))) && (missing0 = "disposition"))) || (((data.evidence_reference === undefined) || (!(func0.call(data, "evidence_reference")))) && (missing0 = "evidence_reference"))) || (((data.rationale === undefined) || (!(func0.call(data, "rationale")))) && (missing0 = "rationale"))){ +validate46.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs1 = errors; +for(const key0 of Object.keys(data)){ +if(!((((key0 === "gate") || (key0 === "disposition")) || (key0 === "evidence_reference")) || (key0 === "rationale"))){ +validate46.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs1 === errors){ +if(data.gate !== undefined && func0.call(data, "gate")){ +let data0 = data.gate; +const _errs2 = errors; +if(!(((((((((data0 === "editorial") || (data0 === "canon-continuity")) || (data0 === "visual-text")) || (data0 === "integrity")) || (data0 === "provenance")) || (data0 === "security-privacy")) || (data0 === "rights")) || (data0 === "accessibility")) || (data0 === "packaging"))){ +validate46.errors = [{instancePath:instancePath+"/gate",schemaPath:"#/properties/gate/enum",keyword:"enum",params:{allowedValues: schema69.properties.gate.enum},message:"must be equal to one of the allowed values"}]; +return false; +} +var valid0 = _errs2 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.disposition !== undefined && func0.call(data, "disposition")){ +let data1 = data.disposition; +const _errs3 = errors; +if(!(((((data1 === "pass") || (data1 === "fail")) || (data1 === "inconclusive")) || (data1 === "not-run")) || (data1 === "not-applicable"))){ +validate46.errors = [{instancePath:instancePath+"/disposition",schemaPath:"#/properties/disposition/enum",keyword:"enum",params:{allowedValues: schema69.properties.disposition.enum},message:"must be equal to one of the allowed values"}]; +return false; +} +var valid0 = _errs3 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.evidence_reference !== undefined && func0.call(data, "evidence_reference")){ +let data2 = data.evidence_reference; +const _errs4 = errors; +const _errs5 = errors; +if(errors === _errs5){ +if(typeof data2 === "string"){ +if(!pattern4.test(data2)){ +validate46.errors = [{instancePath:instancePath+"/evidence_reference",schemaPath:"#/$defs/uuid/pattern",keyword:"pattern",params:{pattern: "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},message:"must match pattern \""+"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"+"\""}]; +return false; +} +} +else { +validate46.errors = [{instancePath:instancePath+"/evidence_reference",schemaPath:"#/$defs/uuid/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs4 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.rationale !== undefined && func0.call(data, "rationale")){ +let data3 = data.rationale; +const _errs7 = errors; +if(errors === _errs7){ +if(typeof data3 === "string"){ +if(func120(data3) > 4096){ +validate46.errors = [{instancePath:instancePath+"/rationale",schemaPath:"#/properties/rationale/maxLength",keyword:"maxLength",params:{limit: 4096},message:"must NOT have more than 4096 characters"}]; +return false; +} +else { +if(func120(data3) < 1){ +validate46.errors = [{instancePath:instancePath+"/rationale",schemaPath:"#/properties/rationale/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate46.errors = [{instancePath:instancePath+"/rationale",schemaPath:"#/properties/rationale/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs7 === errors; +} +else { +var valid0 = true; +} +} +} +} +} +} +} +else { +validate46.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +validate46.errors = vErrors; +return errors === 0; +} +validate46.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; + +const schema71 = {"type":"object","additionalProperties":false,"required":["tool","workflow_id","run_uri","started_at","finished_at","transformations","generation","reproducibility","limitations"],"properties":{"tool":{"$ref":"#/$defs/dependency"},"workflow_id":{"type":"string","minLength":1,"maxLength":200},"run_uri":{"anyOf":[{"$ref":"#/$defs/uri"},{"type":"null"}]},"started_at":{"$ref":"#/$defs/time"},"finished_at":{"$ref":"#/$defs/time"},"transformations":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["step_id","input_digests","output_digests","private_inputs_withheld","private_outputs_withheld"],"properties":{"step_id":{"$ref":"#/$defs/name"},"input_digests":{"type":"array","items":{"$ref":"#/$defs/digest"},"minItems":0,"maxItems":256},"output_digests":{"type":"array","items":{"$ref":"#/$defs/digest"},"minItems":0,"maxItems":256},"private_inputs_withheld":{"type":"boolean"},"private_outputs_withheld":{"type":"boolean"}}},"minItems":1,"maxItems":256},"generation":{"type":"array","items":{"$ref":"#/$defs/generation"},"minItems":0,"maxItems":256},"reproducibility":{"enum":["exact","partial","audit-only"]},"limitations":{"type":"string","minLength":1,"maxLength":4096}}}; +const schema73 = {"type":"string","format":"date-time","pattern":"Z$","maxLength":32}; +const schema78 = {"type":"object","additionalProperties":false,"required":["provider","model","parameters","evidence_state","limitations"],"properties":{"provider":{"type":"string","minLength":1,"maxLength":128},"model":{"type":"string","minLength":1,"maxLength":128},"parameters":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","value"],"properties":{"name":{"$ref":"#/$defs/name"},"value":{"type":"string","minLength":1,"maxLength":1024}}},"minItems":0,"maxItems":256},"evidence_state":{"enum":["recorded","unavailable","withheld"]},"limitations":{"type":"string","minLength":1,"maxLength":4096}}}; + +function validate50(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate50.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if(((((((data.provider === undefined) || (!(func0.call(data, "provider")))) && (missing0 = "provider")) || (((data.model === undefined) || (!(func0.call(data, "model")))) && (missing0 = "model"))) || (((data.parameters === undefined) || (!(func0.call(data, "parameters")))) && (missing0 = "parameters"))) || (((data.evidence_state === undefined) || (!(func0.call(data, "evidence_state")))) && (missing0 = "evidence_state"))) || (((data.limitations === undefined) || (!(func0.call(data, "limitations")))) && (missing0 = "limitations"))){ +validate50.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs1 = errors; +for(const key0 of Object.keys(data)){ +if(!(((((key0 === "provider") || (key0 === "model")) || (key0 === "parameters")) || (key0 === "evidence_state")) || (key0 === "limitations"))){ +validate50.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs1 === errors){ +if(data.provider !== undefined && func0.call(data, "provider")){ +let data0 = data.provider; +const _errs2 = errors; +if(errors === _errs2){ +if(typeof data0 === "string"){ +if(func120(data0) > 128){ +validate50.errors = [{instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}]; +return false; +} +else { +if(func120(data0) < 1){ +validate50.errors = [{instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate50.errors = [{instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs2 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.model !== undefined && func0.call(data, "model")){ +let data1 = data.model; +const _errs4 = errors; +if(errors === _errs4){ +if(typeof data1 === "string"){ +if(func120(data1) > 128){ +validate50.errors = [{instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}]; +return false; +} +else { +if(func120(data1) < 1){ +validate50.errors = [{instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate50.errors = [{instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs4 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.parameters !== undefined && func0.call(data, "parameters")){ +let data2 = data.parameters; +const _errs6 = errors; +if(errors === _errs6){ +if(Array.isArray(data2)){ +if(data2.length > 256){ +validate50.errors = [{instancePath:instancePath+"/parameters",schemaPath:"#/properties/parameters/maxItems",keyword:"maxItems",params:{limit: 256},message:"must NOT have more than 256 items"}]; +return false; +} +else { +if(data2.length < 0){ +validate50.errors = [{instancePath:instancePath+"/parameters",schemaPath:"#/properties/parameters/minItems",keyword:"minItems",params:{limit: 0},message:"must NOT have fewer than 0 items"}]; +return false; +} +else { +var valid1 = true; +const len0 = data2.length; +for(let i0=0; i0 1024){ +validate50.errors = [{instancePath:instancePath+"/parameters/" + i0+"/value",schemaPath:"#/properties/parameters/items/properties/value/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"}]; +return false; +} +else { +if(func120(data5) < 1){ +validate50.errors = [{instancePath:instancePath+"/parameters/" + i0+"/value",schemaPath:"#/properties/parameters/items/properties/value/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate50.errors = [{instancePath:instancePath+"/parameters/" + i0+"/value",schemaPath:"#/properties/parameters/items/properties/value/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid2 = _errs14 === errors; +} +else { +var valid2 = true; +} +} +} +} +} +else { +validate50.errors = [{instancePath:instancePath+"/parameters/" + i0,schemaPath:"#/properties/parameters/items/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +var valid1 = _errs8 === errors; +if(!valid1){ +break; +} +} +} +} +} +else { +validate50.errors = [{instancePath:instancePath+"/parameters",schemaPath:"#/properties/parameters/type",keyword:"type",params:{type: "array"},message:"must be array"}]; +return false; +} +} +var valid0 = _errs6 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.evidence_state !== undefined && func0.call(data, "evidence_state")){ +let data6 = data.evidence_state; +const _errs16 = errors; +if(!(((data6 === "recorded") || (data6 === "unavailable")) || (data6 === "withheld"))){ +validate50.errors = [{instancePath:instancePath+"/evidence_state",schemaPath:"#/properties/evidence_state/enum",keyword:"enum",params:{allowedValues: schema78.properties.evidence_state.enum},message:"must be equal to one of the allowed values"}]; +return false; +} +var valid0 = _errs16 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.limitations !== undefined && func0.call(data, "limitations")){ +let data7 = data.limitations; +const _errs17 = errors; +if(errors === _errs17){ +if(typeof data7 === "string"){ +if(func120(data7) > 4096){ +validate50.errors = [{instancePath:instancePath+"/limitations",schemaPath:"#/properties/limitations/maxLength",keyword:"maxLength",params:{limit: 4096},message:"must NOT have more than 4096 characters"}]; +return false; +} +else { +if(func120(data7) < 1){ +validate50.errors = [{instancePath:instancePath+"/limitations",schemaPath:"#/properties/limitations/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate50.errors = [{instancePath:instancePath+"/limitations",schemaPath:"#/properties/limitations/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs17 === errors; +} +else { +var valid0 = true; +} +} +} +} +} +} +} +} +else { +validate50.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +validate50.errors = vErrors; +return errors === 0; +} +validate50.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; + +const formats6 = require("ajv-formats/dist/formats").fullFormats["date-time"]; +const pattern27 = new RegExp("Z$", "u"); + +function validate48(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate48.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if(((((((((((data.tool === undefined) || (!(func0.call(data, "tool")))) && (missing0 = "tool")) || (((data.workflow_id === undefined) || (!(func0.call(data, "workflow_id")))) && (missing0 = "workflow_id"))) || (((data.run_uri === undefined) || (!(func0.call(data, "run_uri")))) && (missing0 = "run_uri"))) || (((data.started_at === undefined) || (!(func0.call(data, "started_at")))) && (missing0 = "started_at"))) || (((data.finished_at === undefined) || (!(func0.call(data, "finished_at")))) && (missing0 = "finished_at"))) || (((data.transformations === undefined) || (!(func0.call(data, "transformations")))) && (missing0 = "transformations"))) || (((data.generation === undefined) || (!(func0.call(data, "generation")))) && (missing0 = "generation"))) || (((data.reproducibility === undefined) || (!(func0.call(data, "reproducibility")))) && (missing0 = "reproducibility"))) || (((data.limitations === undefined) || (!(func0.call(data, "limitations")))) && (missing0 = "limitations"))){ +validate48.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs1 = errors; +for(const key0 of Object.keys(data)){ +if(!(func0.call(schema71.properties, key0))){ +validate48.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs1 === errors){ +if(data.tool !== undefined && func0.call(data, "tool")){ +const _errs2 = errors; +if(!(validate27(data.tool, {instancePath:instancePath+"/tool",parentData:data,parentDataProperty:"tool",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate27.errors : vErrors.concat(validate27.errors); +errors = vErrors.length; +} +var valid0 = _errs2 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.workflow_id !== undefined && func0.call(data, "workflow_id")){ +let data1 = data.workflow_id; +const _errs3 = errors; +if(errors === _errs3){ +if(typeof data1 === "string"){ +if(func120(data1) > 200){ +validate48.errors = [{instancePath:instancePath+"/workflow_id",schemaPath:"#/properties/workflow_id/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"}]; +return false; +} +else { +if(func120(data1) < 1){ +validate48.errors = [{instancePath:instancePath+"/workflow_id",schemaPath:"#/properties/workflow_id/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate48.errors = [{instancePath:instancePath+"/workflow_id",schemaPath:"#/properties/workflow_id/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs3 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.run_uri !== undefined && func0.call(data, "run_uri")){ +let data2 = data.run_uri; +const _errs5 = errors; +const _errs6 = errors; +let valid1 = false; +const _errs7 = errors; +const _errs8 = errors; +if(errors === _errs8){ +if(errors === _errs8){ +if(typeof data2 === "string"){ +if(func120(data2) > 2048){ +const err0 = {instancePath:instancePath+"/run_uri",schemaPath:"#/$defs/uri/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"}; +if(vErrors === null){ +vErrors = [err0]; +} +else { +vErrors.push(err0); +} +errors++; +} +else { +if(!pattern11.test(data2)){ +const err1 = {instancePath:instancePath+"/run_uri",schemaPath:"#/$defs/uri/pattern",keyword:"pattern",params:{pattern: "^https://"},message:"must match pattern \""+"^https://"+"\""}; +if(vErrors === null){ +vErrors = [err1]; +} +else { +vErrors.push(err1); +} +errors++; +} +else { +if(!(formats0(data2))){ +const err2 = {instancePath:instancePath+"/run_uri",schemaPath:"#/$defs/uri/format",keyword:"format",params:{format: "uri"},message:"must match format \""+"uri"+"\""}; +if(vErrors === null){ +vErrors = [err2]; +} +else { +vErrors.push(err2); +} +errors++; +} +} +} +} +else { +const err3 = {instancePath:instancePath+"/run_uri",schemaPath:"#/$defs/uri/type",keyword:"type",params:{type: "string"},message:"must be string"}; +if(vErrors === null){ +vErrors = [err3]; +} +else { +vErrors.push(err3); +} +errors++; +} +} +} +var _valid0 = _errs7 === errors; +valid1 = valid1 || _valid0; +const _errs10 = errors; +if(data2 !== null){ +const err4 = {instancePath:instancePath+"/run_uri",schemaPath:"#/properties/run_uri/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"}; +if(vErrors === null){ +vErrors = [err4]; +} +else { +vErrors.push(err4); +} +errors++; +} +var _valid0 = _errs10 === errors; +valid1 = valid1 || _valid0; +if(!valid1){ +const err5 = {instancePath:instancePath+"/run_uri",schemaPath:"#/properties/run_uri/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"}; +if(vErrors === null){ +vErrors = [err5]; +} +else { +vErrors.push(err5); +} +errors++; +validate48.errors = vErrors; +return false; +} +else { +errors = _errs6; +if(vErrors !== null){ +if(_errs6){ +vErrors.length = _errs6; +} +else { +vErrors = null; +} +} +} +var valid0 = _errs5 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.started_at !== undefined && func0.call(data, "started_at")){ +let data3 = data.started_at; +const _errs12 = errors; +const _errs13 = errors; +if(errors === _errs13){ +if(errors === _errs13){ +if(typeof data3 === "string"){ +if(func120(data3) > 32){ +validate48.errors = [{instancePath:instancePath+"/started_at",schemaPath:"#/$defs/time/maxLength",keyword:"maxLength",params:{limit: 32},message:"must NOT have more than 32 characters"}]; +return false; +} +else { +if(!pattern27.test(data3)){ +validate48.errors = [{instancePath:instancePath+"/started_at",schemaPath:"#/$defs/time/pattern",keyword:"pattern",params:{pattern: "Z$"},message:"must match pattern \""+"Z$"+"\""}]; +return false; +} +else { +if(!(formats6.validate(data3))){ +validate48.errors = [{instancePath:instancePath+"/started_at",schemaPath:"#/$defs/time/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""}]; +return false; +} +} +} +} +else { +validate48.errors = [{instancePath:instancePath+"/started_at",schemaPath:"#/$defs/time/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +} +var valid0 = _errs12 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.finished_at !== undefined && func0.call(data, "finished_at")){ +let data4 = data.finished_at; +const _errs15 = errors; +const _errs16 = errors; +if(errors === _errs16){ +if(errors === _errs16){ +if(typeof data4 === "string"){ +if(func120(data4) > 32){ +validate48.errors = [{instancePath:instancePath+"/finished_at",schemaPath:"#/$defs/time/maxLength",keyword:"maxLength",params:{limit: 32},message:"must NOT have more than 32 characters"}]; +return false; +} +else { +if(!pattern27.test(data4)){ +validate48.errors = [{instancePath:instancePath+"/finished_at",schemaPath:"#/$defs/time/pattern",keyword:"pattern",params:{pattern: "Z$"},message:"must match pattern \""+"Z$"+"\""}]; +return false; +} +else { +if(!(formats6.validate(data4))){ +validate48.errors = [{instancePath:instancePath+"/finished_at",schemaPath:"#/$defs/time/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""}]; +return false; +} +} +} +} +else { +validate48.errors = [{instancePath:instancePath+"/finished_at",schemaPath:"#/$defs/time/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +} +var valid0 = _errs15 === errors; +} +else { +var valid0 = true; +} +if(valid0){ +if(data.transformations !== undefined && func0.call(data, "transformations")){ +let data5 = data.transformations; +const _errs18 = errors; +if(errors === _errs18){ +if(Array.isArray(data5)){ +if(data5.length > 256){ +validate48.errors = [{instancePath:instancePath+"/transformations",schemaPath:"#/properties/transformations/maxItems",keyword:"maxItems",params:{limit: 256},message:"must NOT have more than 256 items"}]; +return false; +} +else { +if(data5.length < 1){ +validate48.errors = [{instancePath:instancePath+"/transformations",schemaPath:"#/properties/transformations/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"}]; +return false; +} +else { +var valid5 = true; +const len0 = data5.length; +for(let i0=0; i0 256){ +validate48.errors = [{instancePath:instancePath+"/transformations/" + i0+"/input_digests",schemaPath:"#/properties/transformations/items/properties/input_digests/maxItems",keyword:"maxItems",params:{limit: 256},message:"must NOT have more than 256 items"}]; +return false; +} +else { +if(data8.length < 0){ +validate48.errors = [{instancePath:instancePath+"/transformations/" + i0+"/input_digests",schemaPath:"#/properties/transformations/items/properties/input_digests/minItems",keyword:"minItems",params:{limit: 0},message:"must NOT have fewer than 0 items"}]; +return false; +} +else { +var valid8 = true; +const len1 = data8.length; +for(let i1=0; i1 256){ +validate48.errors = [{instancePath:instancePath+"/transformations/" + i0+"/output_digests",schemaPath:"#/properties/transformations/items/properties/output_digests/maxItems",keyword:"maxItems",params:{limit: 256},message:"must NOT have more than 256 items"}]; +return false; +} +else { +if(data10.length < 0){ +validate48.errors = [{instancePath:instancePath+"/transformations/" + i0+"/output_digests",schemaPath:"#/properties/transformations/items/properties/output_digests/minItems",keyword:"minItems",params:{limit: 0},message:"must NOT have fewer than 0 items"}]; +return false; +} +else { +var valid10 = true; +const len2 = data10.length; +for(let i2=0; i2 256){ +validate48.errors = [{instancePath:instancePath+"/generation",schemaPath:"#/properties/generation/maxItems",keyword:"maxItems",params:{limit: 256},message:"must NOT have more than 256 items"}]; +return false; +} +else { +if(data14.length < 0){ +validate48.errors = [{instancePath:instancePath+"/generation",schemaPath:"#/properties/generation/minItems",keyword:"minItems",params:{limit: 0},message:"must NOT have fewer than 0 items"}]; +return false; +} +else { +var valid12 = true; +const len3 = data14.length; +for(let i3=0; i3 4096){ +validate48.errors = [{instancePath:instancePath+"/limitations",schemaPath:"#/properties/limitations/maxLength",keyword:"maxLength",params:{limit: 4096},message:"must NOT have more than 4096 characters"}]; +return false; +} +else { +if(func120(data17) < 1){ +validate48.errors = [{instancePath:instancePath+"/limitations",schemaPath:"#/properties/limitations/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}]; +return false; +} +} +} +else { +validate48.errors = [{instancePath:instancePath+"/limitations",schemaPath:"#/properties/limitations/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid0 = _errs44 === errors; +} +else { +var valid0 = true; +} +} +} +} +} +} +} +} +} +} +} +} +else { +validate48.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}]; +return false; +} +} +validate48.errors = vErrors; +return errors === 0; +} +validate48.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; + + +function validate21(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ +let vErrors = null; +let errors = 0; +const evaluated0 = validate21.evaluated; +if(evaluated0.dynamicProps){ +evaluated0.props = undefined; +} +if(evaluated0.dynamicItems){ +evaluated0.items = undefined; +} +const _errs1 = errors; +const _errs2 = errors; +let valid1 = true; +const _errs3 = errors; +if(data && typeof data == "object" && !Array.isArray(data)){ +if(data.status !== undefined && func0.call(data, "status")){ +if("complete" !== data.status){ +const err0 = {}; +if(vErrors === null){ +vErrors = [err0]; +} +else { +vErrors.push(err0); +} +errors++; +} +} +} +var _valid0 = _errs3 === errors; +errors = _errs2; +if(vErrors !== null){ +if(_errs2){ +vErrors.length = _errs2; +} +else { +vErrors = null; +} +} +let ifClause0; +if(_valid0){ +const _errs5 = errors; +if(data && typeof data == "object" && !Array.isArray(data)){ +if(data.outputs !== undefined && func0.call(data, "outputs")){ +let data1 = data.outputs; +const _errs6 = errors; +if(Array.isArray(data1)){ +if(data1.length < 1){ +validate21.errors = [{instancePath:instancePath+"/outputs",schemaPath:"#/allOf/0/then/properties/outputs/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"}]; +return false; +} +} +var valid3 = _errs6 === errors; +} +else { +var valid3 = true; +} +if(valid3){ +if(data.diagnostics !== undefined && func0.call(data, "diagnostics")){ +let data2 = data.diagnostics; +const _errs7 = errors; +if(Array.isArray(data2)){ +if(data2.length > 0){ +validate21.errors = [{instancePath:instancePath+"/diagnostics",schemaPath:"#/allOf/0/then/properties/diagnostics/maxItems",keyword:"maxItems",params:{limit: 0},message:"must NOT have more than 0 items"}]; +return false; +} +} +var valid3 = _errs7 === errors; +} +else { +var valid3 = true; +} +} +} +var _valid0 = _errs5 === errors; +valid1 = _valid0; +if(valid1){ +var props0 = {}; +props0.outputs = true; +props0.diagnostics = true; +props0.status = true; +} +ifClause0 = "then"; +} +else { +const _errs8 = errors; +if(data && typeof data == "object" && !Array.isArray(data)){ +if(data.diagnostics !== undefined && func0.call(data, "diagnostics")){ +let data3 = data.diagnostics; +if(Array.isArray(data3)){ +if(data3.length < 1){ +validate21.errors = [{instancePath:instancePath+"/diagnostics",schemaPath:"#/allOf/0/else/properties/diagnostics/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"}]; +return false; +} +} +} +} +var _valid0 = _errs8 === errors; +valid1 = _valid0; +if(valid1){ +if(props0 !== true){ +props0 = props0 || {}; +props0.diagnostics = true; +} +} +ifClause0 = "else"; +} +if(!valid1){ +const err1 = {instancePath,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword: ifClause0},message:"must match \""+ifClause0+"\" schema"}; +if(vErrors === null){ +vErrors = [err1]; +} +else { +vErrors.push(err1); +} +errors++; +validate21.errors = vErrors; +return false; +} +var valid0 = _errs1 === errors; +if(valid0){ +const _errs10 = errors; +const _errs11 = errors; +let valid5 = true; +const _errs12 = errors; +if(data && typeof data == "object" && !Array.isArray(data)){ +if(data.execution !== undefined && func0.call(data, "execution")){ +let data4 = data.execution; +if(data4 && typeof data4 == "object" && !Array.isArray(data4)){ +if(data4.transformations !== undefined && func0.call(data4, "transformations")){ +let data5 = data4.transformations; +if(Array.isArray(data5)){ +const _errs15 = errors; +const len0 = data5.length; +for(let i0=0; i0 0){ +const err2 = {}; +if(vErrors === null){ +vErrors = [err2]; +} +else { +vErrors.push(err2); +} +errors++; +} +} +} +} +var valid8 = _errs16 === errors; +if(valid8){ +break; +} +} +if(!valid8){ +const err3 = {}; +if(vErrors === null){ +vErrors = [err3]; +} +else { +vErrors.push(err3); +} +errors++; +} +else { +errors = _errs15; +if(vErrors !== null){ +if(_errs15){ +vErrors.length = _errs15; +} +else { +vErrors = null; +} +} +} +} +} +} +} +} +var _valid1 = _errs12 === errors; +errors = _errs11; +if(vErrors !== null){ +if(_errs11){ +vErrors.length = _errs11; +} +else { +vErrors = null; +} +} +if(_valid1){ +const _errs18 = errors; +if(data && typeof data == "object" && !Array.isArray(data)){ +if(data.status !== undefined && func0.call(data, "status")){ +const _errs19 = errors; +if("failed" !== data.status){ +validate21.errors = [{instancePath:instancePath+"/status",schemaPath:"#/allOf/1/then/properties/status/const",keyword:"const",params:{allowedValue: "failed"},message:"must be equal to constant"}]; +return false; +} +var valid10 = _errs19 === errors; +} +else { +var valid10 = true; +} +if(valid10){ +if(data.outputs !== undefined && func0.call(data, "outputs")){ +let data9 = data.outputs; +const _errs20 = errors; +if(Array.isArray(data9)){ +if(data9.length > 0){ +validate21.errors = [{instancePath:instancePath+"/outputs",schemaPath:"#/allOf/1/then/properties/outputs/maxItems",keyword:"maxItems",params:{limit: 0},message:"must NOT have more than 0 items"}]; +return false; +} +} +var valid10 = _errs20 === errors; +} +else { +var valid10 = true; +} +if(valid10){ +if(data.diagnostics !== undefined && func0.call(data, "diagnostics")){ +const _errs21 = errors; +if(!func27(data.diagnostics, schema32.allOf[1].then.properties.diagnostics.const)){ +validate21.errors = [{instancePath:instancePath+"/diagnostics",schemaPath:"#/allOf/1/then/properties/diagnostics/const",keyword:"const",params:{allowedValue: schema32.allOf[1].then.properties.diagnostics.const},message:"must be equal to constant"}]; +return false; +} +var valid10 = _errs21 === errors; +} +else { +var valid10 = true; +} +if(valid10){ +if(data.execution !== undefined && func0.call(data, "execution")){ +let data11 = data.execution; +const _errs22 = errors; +if(data11 && typeof data11 == "object" && !Array.isArray(data11)){ +if(data11.transformations !== undefined && func0.call(data11, "transformations")){ +let data12 = data11.transformations; +if(Array.isArray(data12)){ +if(data12.length > 1){ +validate21.errors = [{instancePath:instancePath+"/execution/transformations",schemaPath:"#/allOf/1/then/properties/execution/properties/transformations/maxItems",keyword:"maxItems",params:{limit: 1},message:"must NOT have more than 1 items"}]; +return false; +} +else { +if(data12.length < 1){ +validate21.errors = [{instancePath:instancePath+"/execution/transformations",schemaPath:"#/allOf/1/then/properties/execution/properties/transformations/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"}]; +return false; +} +else { +var valid12 = true; +const len1 = data12.length; +for(let i1=0; i1 0){ +validate21.errors = [{instancePath:instancePath+"/execution/transformations/" + i1+"/output_digests",schemaPath:"#/allOf/1/then/properties/execution/properties/transformations/items/properties/output_digests/maxItems",keyword:"maxItems",params:{limit: 0},message:"must NOT have more than 0 items"}]; +return false; +} +} +var valid13 = _errs26 === errors; +} +else { +var valid13 = true; +} +if(valid13){ +if(data13.private_inputs_withheld !== undefined && func0.call(data13, "private_inputs_withheld")){ +const _errs27 = errors; +if(false !== data13.private_inputs_withheld){ +validate21.errors = [{instancePath:instancePath+"/execution/transformations/" + i1+"/private_inputs_withheld",schemaPath:"#/allOf/1/then/properties/execution/properties/transformations/items/properties/private_inputs_withheld/const",keyword:"const",params:{allowedValue: false},message:"must be equal to constant"}]; +return false; +} +var valid13 = _errs27 === errors; +} +else { +var valid13 = true; +} +if(valid13){ +if(data13.private_outputs_withheld !== undefined && func0.call(data13, "private_outputs_withheld")){ +const _errs28 = errors; +if(false !== data13.private_outputs_withheld){ +validate21.errors = [{instancePath:instancePath+"/execution/transformations/" + i1+"/private_outputs_withheld",schemaPath:"#/allOf/1/then/properties/execution/properties/transformations/items/properties/private_outputs_withheld/const",keyword:"const",params:{allowedValue: false},message:"must be equal to constant"}]; +return false; +} +var valid13 = _errs28 === errors; +} +else { +var valid13 = true; +} +} +} +} +} +var valid12 = _errs24 === errors; +if(!valid12){ +break; +} +} +} +} +} +} +} +var valid10 = _errs22 === errors; +} +else { +var valid10 = true; +} +} +} +} +} +var _valid1 = _errs18 === errors; +valid5 = _valid1; +if(valid5){ +var props1 = {}; +props1.status = true; +props1.outputs = true; +props1.diagnostics = true; +props1.execution = true; +} +} +if(!valid5){ +const err4 = {instancePath,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"}; +if(vErrors === null){ +vErrors = [err4]; +} +else { +vErrors.push(err4); +} +errors++; +validate21.errors = vErrors; +return false; +} +var valid0 = _errs10 === errors; +if(valid0){ +if(props0 !== true && props1 !== undefined){ +if(props1 === true){ +props0 = true; +} +else { +props0 = props0 || {}; +Object.assign(props0, props1); +} +} +} +} +if(errors === 0){ +if(data && typeof data == "object" && !Array.isArray(data)){ +let missing0; +if((((((((((((((data.kind === undefined) || (!(func0.call(data, "kind")))) && (missing0 = "kind")) || (((data.spec_version === undefined) || (!(func0.call(data, "spec_version")))) && (missing0 = "spec_version"))) || (((data.result_id === undefined) || (!(func0.call(data, "result_id")))) && (missing0 = "result_id"))) || (((data.attempt_id === undefined) || (!(func0.call(data, "attempt_id")))) && (missing0 = "attempt_id"))) || (((data.production === undefined) || (!(func0.call(data, "production")))) && (missing0 = "production"))) || (((data.classification === undefined) || (!(func0.call(data, "classification")))) && (missing0 = "classification"))) || (((data.inputs === undefined) || (!(func0.call(data, "inputs")))) && (missing0 = "inputs"))) || (((data.status === undefined) || (!(func0.call(data, "status")))) && (missing0 = "status"))) || (((data.outputs === undefined) || (!(func0.call(data, "outputs")))) && (missing0 = "outputs"))) || (((data.gates === undefined) || (!(func0.call(data, "gates")))) && (missing0 = "gates"))) || (((data.execution === undefined) || (!(func0.call(data, "execution")))) && (missing0 = "execution"))) || (((data.diagnostics === undefined) || (!(func0.call(data, "diagnostics")))) && (missing0 = "diagnostics"))){ +validate21.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}]; +return false; +} +else { +const _errs29 = errors; +for(const key0 of Object.keys(data)){ +if(!(func0.call(schema32.properties, key0))){ +validate21.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}]; +return false; +break; +} +} +if(_errs29 === errors){ +if(data.kind !== undefined && func0.call(data, "kind")){ +const _errs30 = errors; +if("comic-build-result" !== data.kind){ +validate21.errors = [{instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/const",keyword:"const",params:{allowedValue: "comic-build-result"},message:"must be equal to constant"}]; +return false; +} +var valid14 = _errs30 === errors; +} +else { +var valid14 = true; +} +if(valid14){ +if(data.spec_version !== undefined && func0.call(data, "spec_version")){ +const _errs31 = errors; +if("1.1.0" !== data.spec_version){ +validate21.errors = [{instancePath:instancePath+"/spec_version",schemaPath:"#/properties/spec_version/const",keyword:"const",params:{allowedValue: "1.1.0"},message:"must be equal to constant"}]; +return false; +} +var valid14 = _errs31 === errors; +} +else { +var valid14 = true; +} +if(valid14){ +if(data.result_id !== undefined && func0.call(data, "result_id")){ +let data20 = data.result_id; +const _errs32 = errors; +const _errs33 = errors; +if(errors === _errs33){ +if(typeof data20 === "string"){ +if(!pattern4.test(data20)){ +validate21.errors = [{instancePath:instancePath+"/result_id",schemaPath:"#/$defs/uuid/pattern",keyword:"pattern",params:{pattern: "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},message:"must match pattern \""+"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"+"\""}]; +return false; +} +} +else { +validate21.errors = [{instancePath:instancePath+"/result_id",schemaPath:"#/$defs/uuid/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid14 = _errs32 === errors; +} +else { +var valid14 = true; +} +if(valid14){ +if(data.attempt_id !== undefined && func0.call(data, "attempt_id")){ +let data21 = data.attempt_id; +const _errs35 = errors; +const _errs36 = errors; +if(errors === _errs36){ +if(typeof data21 === "string"){ +if(!pattern4.test(data21)){ +validate21.errors = [{instancePath:instancePath+"/attempt_id",schemaPath:"#/$defs/uuid/pattern",keyword:"pattern",params:{pattern: "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},message:"must match pattern \""+"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"+"\""}]; +return false; +} +} +else { +validate21.errors = [{instancePath:instancePath+"/attempt_id",schemaPath:"#/$defs/uuid/type",keyword:"type",params:{type: "string"},message:"must be string"}]; +return false; +} +} +var valid14 = _errs35 === errors; +} +else { +var valid14 = true; +} +if(valid14){ +if(data.production !== undefined && func0.call(data, "production")){ +const _errs38 = errors; +if(!(validate22(data.production, {instancePath:instancePath+"/production",parentData:data,parentDataProperty:"production",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate22.errors : vErrors.concat(validate22.errors); +errors = vErrors.length; +} +var valid14 = _errs38 === errors; +} +else { +var valid14 = true; +} +if(valid14){ +if(data.classification !== undefined && func0.call(data, "classification")){ +let data23 = data.classification; +const _errs39 = errors; +if(!((((data23 === "public") || (data23 === "internal")) || (data23 === "confidential")) || (data23 === "restricted"))){ +validate21.errors = [{instancePath:instancePath+"/classification",schemaPath:"#/$defs/classification/enum",keyword:"enum",params:{allowedValues: schema41.enum},message:"must be equal to one of the allowed values"}]; +return false; +} +var valid14 = _errs39 === errors; +} +else { +var valid14 = true; +} +if(valid14){ +if(data.inputs !== undefined && func0.call(data, "inputs")){ +const _errs41 = errors; +if(!(validate26(data.inputs, {instancePath:instancePath+"/inputs",parentData:data,parentDataProperty:"inputs",rootData,dynamicAnchors}))){ +vErrors = vErrors === null ? validate26.errors : vErrors.concat(validate26.errors); +errors = vErrors.length; +} +var valid14 = _errs41 === errors; +} +else { +var valid14 = true; +} +if(valid14){ +if(data.status !== undefined && func0.call(data, "status")){ +let data25 = data.status; +const _errs42 = errors; +if(!(((data25 === "complete") || (data25 === "partial")) || (data25 === "failed"))){ +validate21.errors = [{instancePath:instancePath+"/status",schemaPath:"#/properties/status/enum",keyword:"enum",params:{allowedValues: schema32.properties.status.enum},message:"must be equal to one of the allowed values"}]; +return false; +} +var valid14 = _errs42 === errors; +} +else { +var valid14 = true; +} +if(valid14){ +if(data.outputs !== undefined && func0.call(data, "outputs")){ +let data26 = data.outputs; +const _errs43 = errors; +if(errors === _errs43){ +if(Array.isArray(data26)){ +if(data26.length > 32){ +validate21.errors = [{instancePath:instancePath+"/outputs",schemaPath:"#/properties/outputs/maxItems",keyword:"maxItems",params:{limit: 32},message:"must NOT have more than 32 items"}]; +return false; +} +else { +if(data26.length < 0){ +validate21.errors = [{instancePath:instancePath+"/outputs",schemaPath:"#/properties/outputs/minItems",keyword:"minItems",params:{limit: 0},message:"must NOT have fewer than 0 items"}]; +return false; +} +else { +var valid18 = true; +const len2 = data26.length; +for(let i2=0; i2 9){ +validate21.errors = [{instancePath:instancePath+"/gates",schemaPath:"#/properties/gates/maxItems",keyword:"maxItems",params:{limit: 9},message:"must NOT have more than 9 items"}]; +return false; +} +else { +if(data28.length < 0){ +validate21.errors = [{instancePath:instancePath+"/gates",schemaPath:"#/properties/gates/minItems",keyword:"minItems",params:{limit: 0},message:"must NOT have fewer than 0 items"}]; +return false; +} +else { +var valid19 = true; +const len3 = data28.length; +for(let i3=0; i3 32){ +validate21.errors = [{instancePath:instancePath+"/diagnostics",schemaPath:"#/properties/diagnostics/maxItems",keyword:"maxItems",params:{limit: 32},message:"must NOT have more than 32 items"}]; +return false; +} +else { +if(data31.length < 0){ +validate21.errors = [{instancePath:instancePath+"/diagnostics",schemaPath:"#/properties/diagnostics/minItems",keyword:"minItems",params:{limit: 0},message:"must NOT have fewer than 0 items"}]; +return false; +} +else { +var valid20 = true; +const len4 = data31.length; +for(let i4=0; i4 ({ valid: false, diagnostics: [{ stage: 'candidate', code }] }); +const same = (a, b) => canonicalJson(a) === canonicalJson(b); + +/** Explicit, unreleased local candidate. The stable v1 entry point never selects it. */ +export function validateComicBuildResultCandidate(source, productionSource) { + const parsed = parseComicManifestJson(source); + if (!parsed.valid) return parsed; + try { + if (!schema(parsed.value)) return failure('SCHEMA_INVALID'); + } catch { return failure('SCHEMA_INVALID'); } + finally { schema.errors = null; } + const value = parsed.value; + const noOutput = value.execution.transformations.some(t => t.output_digests.length === 0); + const code = validateLocalSemantics(value, noOutput); + if (code) return failure(code); + const production = validateComicManifest(productionSource); + if (!production.valid || production.value.kind !== 'comic-production') return failure('PRODUCTION_INVALID'); + const p = production.value; + if (!same(value.production, { production_id: p.production_id, revision: p.revision, identity: production.identity }) + || !same(value.inputs, p.inputs)) return failure('PRODUCTION_LINK'); + if (['public', 'internal', 'confidential', 'restricted'].indexOf(value.classification) + < ['public', 'internal', 'confidential', 'restricted'].indexOf(p.classification)) return failure('CLASSIFICATION'); + if (noOutput && !same(value.execution.transformations[0].input_digests, + [p.inputs.canon.artifact.sha256, p.inputs.prompts[0].identity.sha256])) return failure('ACTUAL_INPUTS'); + const compatible = buildOutputCompatibility(production, { value }); + if (compatible) return compatible; + const canonical = canonicalJson(value); + return { valid: true, value, diagnostics: [], identity: { canonicalization: 'studio-json-v1', + byte_size: Buffer.byteLength(canonical), sha256: 'sha256:' + createHash('sha256').update(canonical).digest('hex') } }; +} diff --git a/src/comic-manifest/semantics.js b/src/comic-manifest/semantics.js index 6a3985b..9bac367 100644 --- a/src/comic-manifest/semantics.js +++ b/src/comic-manifest/semantics.js @@ -50,12 +50,12 @@ function inputs(input, classification) { } } } -function execution(e, isPublic) { +function execution(e, isPublic, noOutput = false) { dependency(e.tool); need(executionTime(e.started_at) <= executionTime(e.finished_at), 'TIME_ORDER'); unique(e.transformations.map(t => t.step_id), 'DUPLICATE_ID'); for (const t of e.transformations) { - if (!isPublic) need(t.input_digests.length > 0 && t.output_digests.length > 0 && !t.private_inputs_withheld && !t.private_outputs_withheld, 'TRANSFORMATION'); + if (!isPublic) need(t.input_digests.length > 0 && (t.output_digests.length > 0 || noOutput) && !t.private_inputs_withheld && !t.private_outputs_withheld, 'TRANSFORMATION'); else need((t.input_digests.length > 0 || t.private_inputs_withheld) && (t.output_digests.length > 0 || t.private_outputs_withheld), 'TRANSFORMATION'); } for (const g of e.generation) unique(g.parameters.map(p => p.name), 'DUPLICATE_ID'); @@ -76,11 +76,11 @@ function production(p) { need(p.renditions.some(r => r.required), 'REQUIRED_OUTPUT'); p.renditions.forEach(r => { dimensions(r); renditionProfile(r); }); } -function result(r) { +function result(r, noOutput = false) { inputs(r.inputs, r.classification); unique(r.outputs.map(x => x.rendition_id), 'DUPLICATE_ID'); unique(r.gates.map(x => x.gate), 'DUPLICATE_ID'); - r.outputs.forEach(output => { dimensions(output); renditionProfile(output); }); execution(r.execution, false); + r.outputs.forEach(output => { dimensions(output); renditionProfile(output); }); execution(r.execution, false, noOutput); need(r.inputs.dependencies.some(d => same(d, r.execution.tool)), 'TOOL_REFERENCE'); } function release(r) { @@ -112,7 +112,7 @@ function approval(a) { } const checks = { 'comic-production': production, 'comic-build-result': result, 'comic-public-release': release, 'comic-approval-binding': approval }; /** Only called with schema-valid, bounded, immutable parsed data. */ -export function validateLocalSemantics(value) { - try { checks[value.kind](value); return null; } +export function validateLocalSemantics(value, noOutput = false) { + try { checks[value.kind](value, noOutput); return null; } catch (code) { return typeof code === 'string' ? code : 'SEMANTIC_INVALID'; } } diff --git a/src/offline-orchestration-prototype/runner.js b/src/offline-orchestration-prototype/runner.js index 3ccdc1f..fcd461c 100644 --- a/src/offline-orchestration-prototype/runner.js +++ b/src/offline-orchestration-prototype/runner.js @@ -1,3 +1,4 @@ +import { validateComicBuildResultCandidate } from '../comic-manifest/result-candidate.js'; import { randomUUID, createHash } from 'node:crypto'; import { performance } from 'node:perf_hooks'; import { types } from 'node:util'; @@ -168,7 +169,7 @@ function createRequest(rendered, { executionId, idempotencyKey, correlationId }) }); } -function resultExecution(production, providerResult, outputDigest) { +function resultExecution(production, providerResult, outputDigest, noOutput = false) { const prompt = production.inputs.prompts[0]; return { tool: production.inputs.dependencies[0], @@ -176,10 +177,10 @@ function resultExecution(production, providerResult, outputDigest) { run_uri: null, started_at: providerResult.timing.started_at, finished_at: providerResult.timing.completed_at, - transformations: outputDigest ? [{ + transformations: outputDigest || noOutput ? [{ step_id: 'mock-transcript', input_digests: [production.inputs.canon.artifact.sha256, prompt.identity.sha256], - output_digests: [outputDigest], + output_digests: outputDigest ? [outputDigest] : [], private_inputs_withheld: false, private_outputs_withheld: false }] : [], @@ -190,7 +191,7 @@ function resultExecution(production, providerResult, outputDigest) { } function buildComicResult({ production, productionReference, attemptId, resultId, providerResult, - diagnostic, artifactUri, artifactBytes }) { + diagnostic, artifactUri, artifactBytes, noOutput = false }) { const requirement = production.renditions[0]; const successful = providerResult.status === 'succeeded' && artifactBytes !== undefined; const artifactDigest = successful ? digest(artifactBytes) : undefined; @@ -211,7 +212,7 @@ function buildComicResult({ production, productionReference, attemptId, resultId }] : []; const result = { kind: 'comic-build-result', - spec_version: '1.0.0', + spec_version: noOutput ? '1.1.0' : '1.0.0', result_id: resultId, attempt_id: attemptId, production: productionReference, @@ -223,7 +224,7 @@ function buildComicResult({ production, productionReference, attemptId, resultId gate: 'integrity', disposition: 'pass', evidence_reference: artifactUri, rationale: 'Synthetic artifact bytes were read back and matched their recorded identity.' }] : [], - execution: resultExecution(production, providerResult, artifactDigest), + execution: resultExecution(production, providerResult, artifactDigest, noOutput), diagnostics: successful ? [] : [diagnostic] }; return freezeDeep(result); @@ -423,10 +424,12 @@ function createRunner({ runtime = defaultRuntime, store = new InMemoryPrototypeS if (!appendConfirmed(store, job.jobId, terminalEvent)) return markUnresolved(job); attempt.terminalResult = result; - attempt.completedMonotonicMs = safeClock(runtime)?.now; + const terminalClock = safeClock(runtime); + attempt.completedMonotonicMs = terminalClock?.now; job.attempts.push(attempt); job.state = 'attempt-terminal'; - const isEligibleRetry = job.attempts.length === 1 && job.retryOpen && eligibleRateLimit(attempt.providerResult); + const isEligibleRetry = job.attempts.length === 1 && job.retryOpen && eligibleRateLimit(attempt.providerResult) + && terminalClock?.epochId === job.clockEpochId && terminalClock.now < job.deadlineMonotonicMs; if (!isEligibleRetry || job.attempts.length >= OFFLINE_ORCHESTRATION_LIMITS.maxAttemptsPerJob) { if (!closeIfTerminal(job, isEligibleRetry ? 'attempt-limit-reached' : 'no-eligible-retry')) return markUnresolved(job); } @@ -533,11 +536,10 @@ function createRunner({ runtime = defaultRuntime, store = new InMemoryPrototypeS return blockComicMapping('unsupported-normalized-result-mapping'); } - // Current Comic Manifest semantics require an internal transformation to - // identify a verified output digest. A no-output failed/cancelled result - // cannot satisfy that rule without inventing an output or changing the - // released candidate validator, so preserve the host outcome only. - if (!artifactBytes && job.production.value.classification !== 'public') { + // Only explicit candidate support plus protected no-action rate-limit proof + // permits the truthful no-output form. Stable v1 and other outcomes stay blocked. + const noOutput = job.noOutputResultVersion === '1.1.0' && eligibleRateLimit(providerResult); + if (!artifactBytes && !noOutput && job.production.value.classification !== 'public') { return blockComicMapping('no-output-result-not-representable-under-current-validator'); } @@ -563,11 +565,13 @@ function createRunner({ runtime = defaultRuntime, store = new InMemoryPrototypeS providerResult, diagnostic, artifactUri: artifact?.uri, - artifactBytes: artifact?.bytes + artifactBytes: artifact?.bytes, + noOutput }); const resultSource = canonicalJson(result); - const validation = validateComicManifest(resultSource); - const compatible = validateComicOutputCompatibility(job.production.canonical, resultSource); + const validation = noOutput + ? validateComicBuildResultCandidate(resultSource, job.production.canonical) : validateComicManifest(resultSource); + const compatible = noOutput ? validation : validateComicOutputCompatibility(job.production.canonical, resultSource); if (!validation.valid || !compatible.valid) { return blockComicMapping('comic-result-validation-rejected'); } @@ -578,13 +582,36 @@ function createRunner({ runtime = defaultRuntime, store = new InMemoryPrototypeS const terminal = persistResult(job, attempt, result, artifact); if (terminal.kind === 'terminal' && job.retryOpen && job.state === 'retry-eligible') { // Keep the exact original retry boundary in the job; no other attempt can start. - job.retryNotBefore = checkedAdd(attempt.completedMonotonicMs ?? safeClock(runtime).now, + job.retryNotBefore = checkedAdd(attempt.completedMonotonicMs, providerResult.error.retry_after_ms); } return terminal; } + function verifyRetryEvidence(job, prior) { + if (!prior?.terminalResult || !eligibleRateLimit(prior.providerResult)) return false; + const result = stableResult(prior.terminalResult); + const outcome = stableResult(prior.providerResult); + if (!validateComicBuildResultCandidate(result.source, job.production.canonical).valid + || !readBackBlob(`input:${job.jobId}`, Buffer.from(job.production.canonical), job.production.identity.sha256) + || !readBackBlob(`prompt:${job.jobId}`, job.promptBytes, job.renderedPrompt.sha256) + || !readBackBlob(`result:${prior.resultId}`, result.bytes, result.sha256) + || !readBackBlob(`provider-outcome:${prior.executionId}`, outcome.bytes, outcome.sha256)) return false; + let entries; + try { entries = store.readEvents(job.jobId); } catch { return false; } + if (!Array.isArray(entries) || entries.some(e => ['job-closed', 'contract-mapping-blocked'].includes(e.type))) return false; + const terminals = entries.filter(e => e.type === 'terminal' && e.attempt_id === prior.attemptId); + const outcomes = entries.filter(e => e.type === 'provider-outcome' && e.attempt_id === prior.attemptId); + return terminals.length === 1 && outcomes.length === 1 + && terminals[0].execution_id === prior.executionId && terminals[0].result_id === prior.resultId + && terminals[0].result_sha256 === result.sha256 && terminals[0].result_byte_size === result.bytes.length + && outcomes[0].execution_id === prior.executionId && outcomes[0].sha256 === outcome.sha256 + && outcomes[0].byte_size === outcome.bytes.length + && outcomes[0].payload_key === `provider-outcome:${prior.executionId}`; + } + async function performAttempt(job, { correlationId, mockOutcome, signal, retryOfAttemptId, preflight } = {}) { + const priorAttempt = retryOfAttemptId ? job.lastAttempt : undefined; const cancellation = cancellationSignal(signal); const now = safeClock(runtime); if (!now || now.epochId !== job.clockEpochId) return markUnresolved(job, 'deadline-unverifiable'); @@ -743,6 +770,12 @@ function createRunner({ runtime = defaultRuntime, store = new InMemoryPrototypeS throw new AdapterExecutionError({ category: 'cancelled', code: 'EXECUTION_CANCELLED', message: 'The offline attempt was cancelled before dispatch.', retryable: false, stage: 'preflight' }); } + if (priorAttempt && !verifyRetryEvidence(job, priorAttempt)) { + dispatchBlocked = true; + dispatchBlockReason = 'retry-evidence-unconfirmed'; + throw new AdapterExecutionError({ category: 'internal', code: 'RETRY_EVIDENCE_UNCONFIRMED', + message: 'Prior immutable retry evidence could not be confirmed.', retryable: false, stage: 'preflight' }); + } const dispatch = event(job.jobId, 'dispatch-started', { attempt_id: attemptId, execution_id: executionId, call_number: 1 }); @@ -842,9 +875,12 @@ function createRunner({ runtime = defaultRuntime, store = new InMemoryPrototypeS } async function submit(options = {}) { - const { productionSource, correlation_id: correlationIdInput, signal, mockOutcome } = optionValues( - options, new Set(['productionSource', 'correlation_id', 'signal', 'mockOutcome']), 'INVALID_SUBMIT_OPTIONS' + const { productionSource, correlation_id: correlationIdInput, signal, mockOutcome, noOutputResultVersion } = optionValues( + options, new Set(['productionSource', 'correlation_id', 'signal', 'mockOutcome', 'noOutputResultVersion']), 'INVALID_SUBMIT_OPTIONS' ); + if (noOutputResultVersion !== undefined && noOutputResultVersion !== '1.1.0') { + throw new OfflineOrchestrationError('UNSUPPORTED_RESULT_VERSION'); + } if (running) throw new OfflineOrchestrationError('JOB_ALREADY_ACTIVE'); if (openJob && !openJob.closed) throw new OfflineOrchestrationError('JOB_ALREADY_ACTIVE'); let storedJobIds; @@ -935,6 +971,7 @@ function createRunner({ runtime = defaultRuntime, store = new InMemoryPrototypeS job = { jobId, production, + noOutputResultVersion, renderedPrompt, promptBytes, ledger, @@ -967,6 +1004,7 @@ function createRunner({ runtime = defaultRuntime, store = new InMemoryPrototypeS } const admitted = event(jobId, 'admitted', { production: production.reference, + no_output_result_version: noOutputResultVersion ?? null, input_key: inputKey, input_byte_size: productionBytes.byteLength, input_sha256: production.identity.sha256, @@ -1030,6 +1068,7 @@ function createRunner({ runtime = defaultRuntime, store = new InMemoryPrototypeS if (!Number.isSafeInteger(job.retryNotBefore) || clock.now < job.retryNotBefore) { throw new OfflineOrchestrationError('RETRY_DELAY_NOT_ELAPSED'); } + if (!verifyRetryEvidence(job, job.lastAttempt)) return markUnresolved(job); running = true; try { // Identity is pinned in the job and cannot be replaced on retry. diff --git a/tests/comic-result-candidate.test.js b/tests/comic-result-candidate.test.js new file mode 100644 index 0000000..a400427 --- /dev/null +++ b/tests/comic-result-candidate.test.js @@ -0,0 +1,26 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { readFile } from 'node:fs/promises'; +import { validateComicBuildResultCandidate } from '../src/comic-manifest/result-candidate.js'; +import { validateComicManifest } from '../src/comic-manifest/index.js'; +const read = async name => JSON.parse(await readFile(new URL(`fixtures/${name}`, import.meta.url))); +const base = await read('comic-build-result-v1.1-candidate.json'); +const production = JSON.stringify(base.production); +test('explicit candidate validates actual no-output inputs, stable validator rejects the new exact version', () => { + assert.equal(validateComicBuildResultCandidate(JSON.stringify(base.result), production).valid, true); + assert.equal(validateComicManifest(JSON.stringify(base.result)).valid, false); +}); +for (const c of await read('comic-build-result-v1.1-candidate-cases.json')) test(`candidate rejects ${c.name}`, () => { + const r = structuredClone(base.result); + c.path.slice(0, -1).reduce((x, k) => x[k], r)[c.path.at(-1)] = c.value; + assert.equal(validateComicBuildResultCandidate(JSON.stringify(r), production).valid, false); +}); +for (const kind of ['changed-production', 'fabricated-input', 'changed-tool', 'withheld-input', 'invalid-time']) test(`candidate semantics rejects ${kind}`, () => { + const r = structuredClone(base.result); + if (kind === 'changed-production') r.production.revision++; + if (kind === 'fabricated-input') r.execution.transformations[0].input_digests[0] = 'sha256:' + 'a'.repeat(64); + if (kind === 'changed-tool') r.execution.tool.tag = 'wrong'; + if (kind === 'withheld-input') r.execution.transformations[0].private_inputs_withheld = true; + if (kind === 'invalid-time') r.execution.finished_at = '2000-01-01T00:00:00Z'; + assert.equal(validateComicBuildResultCandidate(JSON.stringify(r), production).valid, false); +}); diff --git a/tests/fixtures/comic-build-result-v1.1-candidate-cases.json b/tests/fixtures/comic-build-result-v1.1-candidate-cases.json new file mode 100644 index 0000000..a634984 --- /dev/null +++ b/tests/fixtures/comic-build-result-v1.1-candidate-cases.json @@ -0,0 +1,151 @@ +[ + { + "name": "complete cannot have no output", + "path": [ + "status" + ], + "value": "complete" + }, + { + "name": "partial cannot have no output", + "path": [ + "status" + ], + "value": "partial" + }, + { + "name": "diagnostic []", + "path": [ + "diagnostics" + ], + "value": [] + }, + { + "name": "diagnostic ['CANCELLED']", + "path": [ + "diagnostics" + ], + "value": [ + "CANCELLED" + ] + }, + { + "name": "diagnostic ['VALIDATION_FAILED']", + "path": [ + "diagnostics" + ], + "value": [ + "VALIDATION_FAILED" + ] + }, + { + "name": "diagnostic ['OUTPUT_MISSING', 'CANCELLED']", + "path": [ + "diagnostics" + ], + "value": [ + "OUTPUT_MISSING", + "CANCELLED" + ] + }, + { + "name": "input_digests", + "path": [ + "execution", + "transformations", + 0, + "input_digests" + ], + "value": [] + }, + { + "name": "private_inputs_withheld", + "path": [ + "execution", + "transformations", + 0, + "private_inputs_withheld" + ], + "value": true + }, + { + "name": "private_outputs_withheld", + "path": [ + "execution", + "transformations", + 0, + "private_outputs_withheld" + ], + "value": true + }, + { + "name": "missing transformation", + "path": [ + "execution", + "transformations" + ], + "value": [] + }, + { + "name": "multiple transformations", + "path": [ + "execution", + "transformations" + ], + "value": [ + { + "step_id": "mock", + "input_digests": [ + "sha256:a8198524f58e72b56283ab71ebddada22840f108b46ef7165bb3fca9919c5558", + "sha256:7d127a76b06a3db563f2935dc0f0d03efa2fcb5d8fe4a13492860497ee6b9064" + ], + "output_digests": [], + "private_inputs_withheld": false, + "private_outputs_withheld": false + }, + { + "step_id": "second", + "input_digests": [ + "sha256:a8198524f58e72b56283ab71ebddada22840f108b46ef7165bb3fca9919c5558", + "sha256:7d127a76b06a3db563f2935dc0f0d03efa2fcb5d8fe4a13492860497ee6b9064" + ], + "output_digests": [], + "private_inputs_withheld": false, + "private_outputs_withheld": false + } + ] + }, + { + "name": "produced output", + "path": [ + "outputs" + ], + "value": [ + { + "rendition_id": "transcript", + "artifact": { + "artifact_uri": "https://example.invalid/synthetic/transcript.txt", + "media_type": "text/plain", + "byte_size": 36, + "sha256": "sha256:5aa128a0dd0945b00ba3d71a5f7b5916e06f40c53048c31d74432eb03f4e764d" + }, + "dimensions": null, + "rights_notice": "Synthetic conformance fixture; Apache-2.0.", + "alt_text": "A blue cube, followed by a red sphere.", + "transcript": "Panel 1: A cube.\nPanel 2: A sphere.", + "profile": { + "profile_id": "comic-accessible-transcript", + "profile_version": "1.0.0" + }, + "max_bytes": 131072 + } + ] + }, + { + "name": "unsupported exact version", + "path": [ + "spec_version" + ], + "value": "1.2.0" + } +] diff --git a/tests/fixtures/comic-build-result-v1.1-candidate.json b/tests/fixtures/comic-build-result-v1.1-candidate.json new file mode 100644 index 0000000..eac404e --- /dev/null +++ b/tests/fixtures/comic-build-result-v1.1-candidate.json @@ -0,0 +1,293 @@ +{ + "production": { + "kind": "comic-production", + "spec_version": "1.0.0", + "production_id": "urn:uuid:10000000-0000-4000-8000-000000000001", + "revision": 1, + "previous": null, + "classification": "internal", + "title": "Synthetic Shapes", + "intent": "Offline conformance only; no Studio canon.", + "inputs": { + "canon": { + "repository": "synthetic/canon", + "version": "1.0.0", + "tag": "canon/v1.0.0", + "commit": "1111111111111111111111111111111111111111", + "artifact": { + "artifact_uri": "https://example.invalid/synthetic/canon", + "media_type": "application/json", + "byte_size": 18, + "sha256": "sha256:a8198524f58e72b56283ab71ebddada22840f108b46ef7165bb3fca9919c5558" + } + }, + "dependencies": [ + { + "repository": "synthetic/mock-tool", + "version": "1.0.0", + "tag": "mock-tool/v1.0.0", + "commit": "1111111111111111111111111111111111111111", + "artifact": { + "artifact_uri": "https://example.invalid/synthetic/mock-tool", + "media_type": "application/json", + "byte_size": 22, + "sha256": "sha256:b5b94381f12f81d18bc1fc6fed0b04254162f21361e4d999ab356cc14cc464cf" + } + }, + { + "repository": "synthetic/comic-manifest", + "version": "1.0.0", + "tag": "comic-manifest/v1.0.0", + "commit": "1111111111111111111111111111111111111111", + "artifact": { + "artifact_uri": "https://example.invalid/synthetic/comic-manifest", + "media_type": "application/json", + "byte_size": 29, + "sha256": "sha256:836b922aa06e1e4759a9ee86412b96b8502bfe992092a10bfc08d97e390ffa47" + } + } + ], + "prompts": [ + { + "binding_id": "description", + "definition": { + "repository": "synthetic/prompt", + "version": "1.0.0", + "tag": "prompt/v1.0.0", + "commit": "1111111111111111111111111111111111111111", + "artifact": { + "artifact_uri": "https://example.invalid/synthetic/prompt", + "media_type": "application/json", + "byte_size": 2629, + "sha256": "sha256:7d127a76b06a3db563f2935dc0f0d03efa2fcb5d8fe4a13492860497ee6b9064" + } + }, + "prompt_id": "prompt.reference.context-builder", + "prompt_version": "1.0.0", + "identity": { + "canonicalization": "studio-json-v1", + "byte_size": 2629, + "sha256": "sha256:7d127a76b06a3db563f2935dc0f0d03efa2fcb5d8fe4a13492860497ee6b9064" + }, + "context": { + "contract_version": "1.0.0", + "package_id": "context-package.reference.builder", + "package_version": "1.0.0", + "instance_id": "urn:uuid:00000000-0000-4000-8000-000000000064", + "manifest_identity": { + "canonicalization": "studio-json-v1", + "byte_size": 1769, + "sha256": "sha256:a287bcbe601550c2a4df68b296c64d622591fc91aa5713e8ea6e2e6119f04eab" + }, + "classification": "internal", + "purpose": "Prepare synthetic context for contract conformance.", + "sections": [ + "approved_notes", + "context_facts" + ], + "builder_result_identity": { + "canonicalization": "studio-json-v1", + "byte_size": 2848, + "sha256": "sha256:729ce7ad380821185cecb4166e6bdd681048097450aa9256505f18c3dafa48b4" + }, + "preparation_reference": "urn:uuid:00000000-0000-4000-8000-000000000063", + "use_authorization_reference": "urn:uuid:00000000-0000-4000-8000-000000000071" + } + } + ], + "assets": [] + }, + "panels": [ + { + "panel_id": "first", + "description": "A synthetic blue cube.", + "text": [ + { + "text_id": "caption-one", + "kind": "caption", + "speaker": null, + "text": "A cube." + } + ], + "asset_ids": [], + "prompt_bindings": [ + "description" + ] + }, + { + "panel_id": "second", + "description": "A synthetic red sphere.", + "text": [ + { + "text_id": "caption-two", + "kind": "caption", + "speaker": null, + "text": "A sphere." + } + ], + "asset_ids": [], + "prompt_bindings": [] + } + ], + "renditions": [ + { + "rendition_id": "transcript", + "required": true, + "media_type": "text/plain", + "dimensions": null, + "alt_text": "A blue cube, followed by a red sphere.", + "transcript": "Panel 1: A cube.\nPanel 2: A sphere.", + "rights_notice": "Synthetic conformance fixture; Apache-2.0.", + "profile": { + "profile_id": "comic-accessible-transcript", + "profile_version": "1.0.0" + }, + "max_bytes": 131072 + } + ] + }, + "result": { + "kind": "comic-build-result", + "spec_version": "1.1.0", + "result_id": "urn:uuid:10000000-0000-4000-8000-000000000002", + "attempt_id": "urn:uuid:10000000-0000-4000-8000-000000000003", + "production": { + "production_id": "urn:uuid:10000000-0000-4000-8000-000000000001", + "revision": 1, + "identity": { + "canonicalization": "studio-json-v1", + "byte_size": 3459, + "sha256": "sha256:9250217ad23125b0356a9e7002f57a55dacf9d982f069caa403b89f8c6c234dc" + } + }, + "classification": "internal", + "inputs": { + "canon": { + "repository": "synthetic/canon", + "version": "1.0.0", + "tag": "canon/v1.0.0", + "commit": "1111111111111111111111111111111111111111", + "artifact": { + "artifact_uri": "https://example.invalid/synthetic/canon", + "media_type": "application/json", + "byte_size": 18, + "sha256": "sha256:a8198524f58e72b56283ab71ebddada22840f108b46ef7165bb3fca9919c5558" + } + }, + "dependencies": [ + { + "repository": "synthetic/mock-tool", + "version": "1.0.0", + "tag": "mock-tool/v1.0.0", + "commit": "1111111111111111111111111111111111111111", + "artifact": { + "artifact_uri": "https://example.invalid/synthetic/mock-tool", + "media_type": "application/json", + "byte_size": 22, + "sha256": "sha256:b5b94381f12f81d18bc1fc6fed0b04254162f21361e4d999ab356cc14cc464cf" + } + }, + { + "repository": "synthetic/comic-manifest", + "version": "1.0.0", + "tag": "comic-manifest/v1.0.0", + "commit": "1111111111111111111111111111111111111111", + "artifact": { + "artifact_uri": "https://example.invalid/synthetic/comic-manifest", + "media_type": "application/json", + "byte_size": 29, + "sha256": "sha256:836b922aa06e1e4759a9ee86412b96b8502bfe992092a10bfc08d97e390ffa47" + } + } + ], + "prompts": [ + { + "binding_id": "description", + "definition": { + "repository": "synthetic/prompt", + "version": "1.0.0", + "tag": "prompt/v1.0.0", + "commit": "1111111111111111111111111111111111111111", + "artifact": { + "artifact_uri": "https://example.invalid/synthetic/prompt", + "media_type": "application/json", + "byte_size": 2629, + "sha256": "sha256:7d127a76b06a3db563f2935dc0f0d03efa2fcb5d8fe4a13492860497ee6b9064" + } + }, + "prompt_id": "prompt.reference.context-builder", + "prompt_version": "1.0.0", + "identity": { + "canonicalization": "studio-json-v1", + "byte_size": 2629, + "sha256": "sha256:7d127a76b06a3db563f2935dc0f0d03efa2fcb5d8fe4a13492860497ee6b9064" + }, + "context": { + "contract_version": "1.0.0", + "package_id": "context-package.reference.builder", + "package_version": "1.0.0", + "instance_id": "urn:uuid:00000000-0000-4000-8000-000000000064", + "manifest_identity": { + "canonicalization": "studio-json-v1", + "byte_size": 1769, + "sha256": "sha256:a287bcbe601550c2a4df68b296c64d622591fc91aa5713e8ea6e2e6119f04eab" + }, + "classification": "internal", + "purpose": "Prepare synthetic context for contract conformance.", + "sections": [ + "approved_notes", + "context_facts" + ], + "builder_result_identity": { + "canonicalization": "studio-json-v1", + "byte_size": 2848, + "sha256": "sha256:729ce7ad380821185cecb4166e6bdd681048097450aa9256505f18c3dafa48b4" + }, + "preparation_reference": "urn:uuid:00000000-0000-4000-8000-000000000063", + "use_authorization_reference": "urn:uuid:00000000-0000-4000-8000-000000000071" + } + } + ], + "assets": [] + }, + "status": "failed", + "outputs": [], + "gates": [], + "execution": { + "tool": { + "repository": "synthetic/mock-tool", + "version": "1.0.0", + "tag": "mock-tool/v1.0.0", + "commit": "1111111111111111111111111111111111111111", + "artifact": { + "artifact_uri": "https://example.invalid/synthetic/mock-tool", + "media_type": "application/json", + "byte_size": 22, + "sha256": "sha256:b5b94381f12f81d18bc1fc6fed0b04254162f21361e4d999ab356cc14cc464cf" + } + }, + "workflow_id": "synthetic-offline", + "run_uri": null, + "started_at": "2026-09-15T12:00:00Z", + "finished_at": "2026-09-15T12:00:01Z", + "transformations": [ + { + "step_id": "mock", + "input_digests": [ + "sha256:a8198524f58e72b56283ab71ebddada22840f108b46ef7165bb3fca9919c5558", + "sha256:7d127a76b06a3db563f2935dc0f0d03efa2fcb5d8fe4a13492860497ee6b9064" + ], + "output_digests": [], + "private_inputs_withheld": false, + "private_outputs_withheld": false + } + ], + "generation": [], + "reproducibility": "exact", + "limitations": "Fixed synthetic text only; no external generation." + }, + "diagnostics": [ + "OUTPUT_MISSING" + ] + } +} diff --git a/tests/offline-orchestration-prototype/runner.test.js b/tests/offline-orchestration-prototype/runner.test.js index c12eb7d..c6a6be3 100644 --- a/tests/offline-orchestration-prototype/runner.test.js +++ b/tests/offline-orchestration-prototype/runner.test.js @@ -841,3 +841,143 @@ test('lifecycle metadata enforces per-entry and per-job entry ceilings', () => { assert.equal(store.readEvents('job-test').length, 32); assert.throws(() => store.append({ job_id: 'job-test', type: 'entry-over' }), /LIFECYCLE_METADATA_LIMIT/); }); + +const candidateOptions = { productionSource, noOutputResultVersion: '1.1.0', mockOutcome: { kind: 'rate-limit', retry_after_ms: 10 } }; +test('explicit candidate enables one delayed caller-authorized retry with immutable history and fresh identities', async () => { + const clock = createRuntime(); const h = runner({ runtime: clock.runtime }); + const first = await h.value.submit(candidateOptions); + assert.equal(first.kind, 'terminal'); assert.equal(first.retry_eligible, true); + assert.equal(first.result.spec_version, '1.1.0'); assert.equal(first.result.status, 'failed'); + assert.deepEqual(first.result.outputs, []); assert.deepEqual(first.result.diagnostics, ['OUTPUT_MISSING']); + assert.deepEqual(first.result.execution.transformations[0].output_digests, []); + assert.equal(validateComicManifest(JSON.stringify(first.result)).valid, false); + const original = h.store.readImmutable(`result:${first.result.result_id}`); + const eventsBefore = h.store.readEvents(first.job_id); + await assert.rejects(() => h.value.retry(), e => e.code === 'EXPLICIT_RETRY_AUTHORIZATION_REQUIRED'); + await assert.rejects(() => h.value.retry({ authorizeRetry: true }), e => e.code === 'RETRY_DELAY_NOT_ELAPSED'); + assert.deepEqual(h.store.readEvents(first.job_id), eventsBefore); + clock.advance(10); + const second = await h.value.retry({ authorizeRetry: true }); + assert.equal(second.kind, 'terminal'); assert.equal(second.result.status, 'complete'); + assert.equal(second.retry_eligible, false); assert.equal(second.result.spec_version, '1.0.0'); + for (const field of ['attempt_id', 'execution_id']) assert.notEqual(first[field], second[field]); + assert.notEqual(first.result.result_id, second.result.result_id); + assert.deepEqual(second.result.production, first.result.production); + assert.deepEqual(h.store.readImmutable(`result:${first.result.result_id}`), original); + const events = h.store.readEvents(first.job_id); + assert.equal(events.filter(e => e.type === 'dispatch-started').length, 2); + assert.equal(events.filter(e => e.type === 'prepared')[1].retry_of_attempt_id, first.attempt_id); + assert.equal(events.at(-1).type, 'job-closed'); + await assert.rejects(() => h.value.retry({ authorizeRetry: true }), e => e.code === 'RETRY_NOT_AVAILABLE'); +}); + +test('second rate limit is terminal and cannot open a third attempt', async () => { + const clock = createRuntime(); const h = runner({ runtime: clock.runtime }); + const first = await h.value.submit(candidateOptions); clock.advance(10); + const second = await h.value.retry({ authorizeRetry: true, mockOutcome: candidateOptions.mockOutcome }); + assert.equal(second.result.status, 'failed'); assert.equal(second.retry_eligible, false); + await assert.rejects(() => h.value.retry({ authorizeRetry: true }), e => e.code === 'RETRY_NOT_AVAILABLE'); + assert.equal(h.store.readEvents(first.job_id).filter(e => e.type === 'dispatch-started').length, 2); +}); + +for (const kind of ['timeout', 'output-validation']) test(`candidate does not map or retry ${kind}`, async () => { + const h = runner(); const r = await h.value.submit({ ...candidateOptions, mockOutcome: { kind } }); + assert.equal(r.status, 'contract-mapping-blocked'); + assert.equal(h.store.readEvents(r.job_id).some(e => e.type === 'terminal'), false); + await assert.rejects(() => h.value.retry({ authorizeRetry: true }), e => e.code === 'RETRY_NOT_AVAILABLE'); +}); + +test('candidate refuses unsupported versions before admission', async () => { + const h = runner(); + await assert.rejects(() => h.value.submit({ ...candidateOptions, noOutputResultVersion: '1.2.0' }), e => e.code === 'UNSUPPORTED_RESULT_VERSION'); + assert.equal(h.store.blobCount, 0); assert.equal(h.store.eventCount, 0); +}); + +test('eligible retry expires within the original deadline and permits explicit close', async () => { + const clock = createRuntime(); const h = runner({ runtime: clock.runtime }); + const r = await h.value.submit({ ...candidateOptions, mockOutcome: { kind: 'rate-limit', retry_after_ms: 86_400_000 } }); + assert.equal(r.retry_eligible, true); clock.advance(300_000); + assert.equal((await h.value.retry({ authorizeRetry: true })).status, 'budget-exhausted'); + assert.equal(h.store.readEvents(r.job_id).filter(e => e.type === 'dispatch-started').length, 1); + const another = runner(); await another.value.submit(candidateOptions); + assert.equal(another.value.closeJob().status, 'closed-without-retry'); +}); + +for (const target of ['input:', 'prompt:', 'result:', 'provider-outcome:']) test(`retry rechecks ${target} immutable evidence`, async () => { + let breakRead = false; + const store = new InMemoryPrototypeStore({ unknownBlob: key => breakRead && key.startsWith(target) }); + const clock = createRuntime(); const h = runner({ store, runtime: clock.runtime }); + const r = await h.value.submit(candidateOptions); assert.equal(r.kind, 'terminal'); + breakRead = true; clock.advance(10); + assert.equal((await h.value.retry({ authorizeRetry: true })).status, 'reconciliation-required'); + assert.equal(store.readEvents(r.job_id).filter(e => e.type === 'dispatch-started').length, 1); +}); + +for (const phase of ['result-prepared', 'persisting', 'terminal']) test(`unconfirmed ${phase} never authorizes retry`, async () => { + const store = new InMemoryPrototypeStore({ beforeAppend: e => e.type === phase }); + const h = runner({ store }); const r = await h.value.submit(candidateOptions); + assert.equal(r.status, 'reconciliation-required'); + await assert.rejects(() => h.value.retry({ authorizeRetry: true }), e => e.code === 'RETRY_NOT_AVAILABLE'); + assert.equal(store.readEvents(r.job_id).filter(e => e.type === 'dispatch-started').length, 1); +}); + +test('candidate cancellation during dispatch remains unmapped and cannot retry', async () => { + const controller = new AbortController(); + const h = runner({ onMockCall({ phase }) { if (phase === 'dispatch-confirmed') setImmediate(() => controller.abort()); } }); + const r = await h.value.submit({ ...candidateOptions, signal: controller.signal, mockOutcome: { kind: 'success', delay_ms: 5000 } }); + assert.equal(r.status, 'contract-mapping-blocked'); + await assert.rejects(() => h.value.retry({ authorizeRetry: true }), e => e.code === 'RETRY_NOT_AVAILABLE'); +}); + +test('recovery of a candidate terminal attempt is read-only and cannot resume a retry', async () => { + const h = runner(); const r = await h.value.submit(candidateOptions); + const counts = [h.store.blobCount, h.store.eventCount]; + const restarted = createOfflineOrchestrationPrototypeForTest({ store: h.store, runtime: h.runtime }); + assert.equal(restarted.inspectRecovery(r.job_id).read_only, true); + await assert.rejects(() => restarted.retry({ authorizeRetry: true }), e => e.code === 'RETRY_NOT_AVAILABLE'); + assert.deepEqual([h.store.blobCount, h.store.eventCount], counts); +}); + +test('candidate retry rechecks proof after asynchronous mock preflight', async () => { + let breakRead = false; let descriptions = 0; + const store = new InMemoryPrototypeStore({ unknownBlob: key => breakRead && key.startsWith('provider-outcome:') }); + class ChangingMock extends MockTextAdapter { + async describe() { if (++descriptions === 2) breakRead = true; return super.describe(); } + } + const clock = createRuntime(); const h = runner({ store, runtime: clock.runtime, mockAdapterFactory: config => new ChangingMock(config) }); + const r = await h.value.submit(candidateOptions); clock.advance(10); + assert.equal((await h.value.retry({ authorizeRetry: true })).status, 'reconciliation-required'); + assert.equal(store.readEvents(r.job_id).filter(e => e.type === 'dispatch-started').length, 1); +}); + +for (const [name, error] of [ + ['missing safe proof', { category: 'rate-limit', retryable: true, retry_after_ms: 10 }], + ['different safe proof', { category: 'rate-limit', retryable: true, retry_after_ms: 10, provider: { code: 'REQUEST_MAY_HAVE_STARTED' } }], + ['not retryable', { category: 'rate-limit', retryable: false, provider: { code: 'RATE_LIMITED_BEFORE_ACCEPTANCE' } }], + ['missing delay', { category: 'rate-limit', retryable: true, provider: { code: 'RATE_LIMITED_BEFORE_ACCEPTANCE' } }], + ['wrong category', { category: 'transport', retryable: true, retry_after_ms: 10, provider: { code: 'RATE_LIMITED_BEFORE_ACCEPTANCE' } }] +]) test(`protected outcome ${name} never authorizes a terminal no-output result`, async () => { + const h = runner({ mockAdapterFactory: config => new MockTextAdapter({ ...config, error: { ...error, code: 'SYNTHETIC_REJECTED', message: 'Synthetic failure.', stage: 'provider' } }) }); + const r = await h.value.submit(candidateOptions); + assert.equal(r.status, 'contract-mapping-blocked'); + assert.equal(h.store.readEvents(r.job_id).some(e => e.type === 'terminal'), false); + await assert.rejects(() => h.value.retry({ authorizeRetry: true }), e => e.code === 'RETRY_NOT_AVAILABLE'); +}); + +test('unknown terminal links after commitment prevent retry without allocating new IDs', async () => { + let hideEvents = false; let allocated = 0; const nextId = idFactory(); + const store = new InMemoryPrototypeStore({ unknownEvents: () => hideEvents }); + const clock = createRuntime(); const h = runner({ store, runtime: clock.runtime, idFactory: () => { allocated++; return nextId(); } }); + await h.value.submit(candidateOptions); const before = allocated; hideEvents = true; clock.advance(10); + assert.equal((await h.value.retry({ authorizeRetry: true })).status, 'reconciliation-required'); + assert.equal(allocated, before); +}); + +test('cancelled retry authorization does not consume a second attempt', async () => { + const clock = createRuntime(); const h = runner({ runtime: clock.runtime }); + const r = await h.value.submit(candidateOptions); clock.advance(10); + const controller = new AbortController(); controller.abort(); + await assert.rejects(() => h.value.retry({ authorizeRetry: true, signal: controller.signal }), e => e.code === 'RETRY_CANCELLED'); + assert.equal(h.store.readEvents(r.job_id).filter(e => e.type === 'dispatch-started').length, 1); + assert.equal((await h.value.retry({ authorizeRetry: true })).result.status, 'complete'); +});