omnius 1.0.923 → 1.0.925
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{providerRegistry.d.ts → _types/backend-vllm/providerRegistry.d.ts} +0 -1
- package/dist/_types/backend-vllm/types.d.ts +209 -0
- package/dist/_types/execution/av/media-capability.d.ts +94 -0
- package/dist/_types/execution/delegation-contract.d.ts +102 -0
- package/dist/_types/execution/evidence.d.ts +68 -0
- package/dist/_types/execution/html-source-evidence.d.ts +65 -0
- package/dist/_types/execution/mcp/types.d.ts +169 -0
- package/dist/_types/execution/mutation-contract.d.ts +102 -0
- package/dist/_types/execution/nol/artifacts.d.ts +39 -0
- package/dist/_types/execution/nol/checkpoint-edits.d.ts +98 -0
- package/dist/_types/execution/nol/distributions.d.ts +128 -0
- package/dist/_types/execution/nol/gguf-checkpoint-edits.d.ts +194 -0
- package/dist/_types/execution/nol/gguf-control-reader.d.ts +224 -0
- package/dist/_types/execution/nol/lora-exports.d.ts +129 -0
- package/dist/_types/execution/nol/neuronary.d.ts +212 -0
- package/dist/_types/execution/nol/pytorch-control-reader.d.ts +143 -0
- package/dist/_types/execution/nol/qwen35-head-sites.d.ts +61 -0
- package/dist/_types/execution/nol/worker-assets.d.ts +82 -0
- package/dist/_types/execution/nol/worker-protocol.d.ts +94 -0
- package/dist/_types/execution/page-content-source.d.ts +40 -0
- package/dist/_types/execution/rapid-computer-use/artifact-store.d.ts +21 -0
- package/dist/_types/execution/rapid-computer-use/contracts.d.ts +320 -0
- package/dist/_types/execution/rapid-computer-use/decision.d.ts +70 -0
- package/dist/_types/execution/rapid-computer-use/desktop-verification.d.ts +23 -0
- package/dist/_types/execution/rapid-computer-use/geometry.d.ts +57 -0
- package/dist/_types/execution/rapid-computer-use/planner.d.ts +78 -0
- package/dist/_types/execution/rapid-computer-use/trace.d.ts +80 -0
- package/dist/_types/execution/rapid-computer-use/visual.d.ts +48 -0
- package/dist/_types/execution/shell-runs.d.ts +78 -0
- package/dist/_types/execution/streamed-web-source.d.ts +64 -0
- package/dist/_types/execution/tools/browser-page-fallback.d.ts +25 -0
- package/dist/_types/execution/tools/network-egress-policy.d.ts +30 -0
- package/dist/_types/execution/tools/pdf-native-tables.d.ts +46 -0
- package/dist/_types/execution/tools/todo-store.d.ts +133 -0
- package/dist/_types/execution/tools/web-fetch.d.ts +57 -0
- package/dist/_types/execution/tools/workboard.d.ts +1223 -0
- package/dist/_types/execution/types.d.ts +549 -0
- package/dist/_types/execution/web-source.d.ts +14 -0
- package/dist/_types/memory/artifactReviewSourceIndex.d.ts +133 -0
- package/dist/_types/memory/contextMemoryLedger.d.ts +213 -0
- package/dist/_types/memory/db.d.ts +12 -0
- package/dist/_types/memory/embeddings.d.ts +36 -0
- package/dist/_types/memory/immutableEvidenceStore.d.ts +165 -0
- package/dist/_types/memory/memoryIngestion.d.ts +65 -0
- package/dist/_types/memory/memoryTypes.d.ts +312 -0
- package/dist/_types/memory/sourceCorpusStore.d.ts +331 -0
- package/dist/_types/memory/structuredMemoryStore.d.ts +105 -0
- package/dist/_types/memory/unifiedMemoryStore.d.ts +127 -0
- package/dist/_types/memory/virtualMemory.d.ts +187 -0
- package/dist/_types/orchestrator/agentic-page-content-receipt.d.ts +20 -0
- package/dist/_types/orchestrator/agentic-web-fetch-receipt.d.ts +20 -0
- package/dist/_types/orchestrator/agenticRunner.d.ts +5219 -0
- package/dist/_types/orchestrator/app-state.d.ts +171 -0
- package/dist/_types/orchestrator/artifactClaimCritic.d.ts +63 -0
- package/dist/_types/orchestrator/artifactQuality.d.ts +15 -0
- package/dist/_types/orchestrator/artifactSemanticIntegrity.d.ts +203 -0
- package/dist/_types/orchestrator/canonical-context-projection.d.ts +254 -0
- package/dist/_types/orchestrator/canonical-source-body-projection.d.ts +51 -0
- package/dist/_types/orchestrator/completion-review-pending.d.ts +24 -0
- package/dist/_types/orchestrator/completionContract.d.ts +103 -0
- package/dist/_types/orchestrator/completionFinalization.d.ts +224 -0
- package/dist/_types/orchestrator/completionLedger.d.ts +429 -0
- package/dist/_types/orchestrator/completionReadiness.d.ts +234 -0
- package/dist/_types/orchestrator/context-admission.d.ts +93 -0
- package/dist/_types/orchestrator/context-dump-retention.d.ts +25 -0
- package/dist/_types/orchestrator/context-fabric.d.ts +133 -0
- package/dist/_types/orchestrator/contextEngine.d.ts +68 -0
- package/dist/_types/orchestrator/contextWindowDump.d.ts +327 -0
- package/dist/_types/orchestrator/convergence-breaker.d.ts +225 -0
- package/dist/_types/orchestrator/convergence-progress.d.ts +66 -0
- package/dist/_types/orchestrator/deliveryCoverage.d.ts +181 -0
- package/dist/_types/orchestrator/document-persistence-goal-binding.d.ts +106 -0
- package/dist/_types/orchestrator/durable-document-worker.d.ts +85 -0
- package/dist/_types/orchestrator/evidenceBranch.d.ts +291 -0
- package/dist/_types/orchestrator/expected-inference-response.d.ts +55 -0
- package/dist/_types/orchestrator/expectedOutcomeContract.d.ts +58 -0
- package/dist/_types/orchestrator/failure-taxonomy.d.ts +36 -0
- package/dist/_types/orchestrator/focusSupervisor.d.ts +436 -0
- package/dist/_types/orchestrator/forced-update-requirement-recovery.d.ts +105 -0
- package/dist/_types/orchestrator/hooks.d.ts +100 -0
- package/dist/_types/orchestrator/inference-pressure.d.ts +61 -0
- package/dist/_types/orchestrator/integrationClosure.d.ts +89 -0
- package/dist/_types/orchestrator/interruption-lifecycle.d.ts +154 -0
- package/dist/_types/orchestrator/live-memory-passages.d.ts +51 -0
- package/dist/_types/orchestrator/liveVirtualContext.d.ts +84 -0
- package/dist/_types/orchestrator/memory-compiler.d.ts +254 -0
- package/dist/_types/orchestrator/memory-consolidation.d.ts +134 -0
- package/dist/_types/orchestrator/model-router.d.ts +17 -0
- package/dist/_types/orchestrator/modelResponseDiagnostics.d.ts +71 -0
- package/dist/_types/orchestrator/nativeRequirementAmendment.d.ts +63 -0
- package/dist/_types/orchestrator/nol/coordinator.d.ts +204 -0
- package/dist/_types/orchestrator/nol/datasets.d.ts +58 -0
- package/dist/_types/orchestrator/nol/discovery.d.ts +286 -0
- package/dist/_types/orchestrator/nol/evaluation.d.ts +59 -0
- package/dist/_types/orchestrator/nol/model-validation.d.ts +198 -0
- package/dist/_types/orchestrator/nol/statistics.d.ts +142 -0
- package/dist/_types/orchestrator/nol/store.d.ts +133 -0
- package/dist/_types/orchestrator/nol/variant-registry.d.ts +292 -0
- package/dist/_types/orchestrator/ollama-context-policy.d.ts +34 -0
- package/dist/_types/orchestrator/personality.d.ts +66 -0
- package/dist/_types/orchestrator/prompt-cache.d.ts +24 -0
- package/dist/_types/orchestrator/remote-inference-fallback.d.ts +224 -0
- package/dist/_types/orchestrator/remote-inference-policy.d.ts +58 -0
- package/dist/_types/orchestrator/request-budget.d.ts +75 -0
- package/dist/_types/orchestrator/requirementCoverage.d.ts +69 -0
- package/dist/_types/orchestrator/reviewedInterpretation.d.ts +111 -0
- package/dist/_types/orchestrator/runEvents.d.ts +115 -0
- package/dist/_types/orchestrator/runtime-rollout.d.ts +63 -0
- package/dist/_types/orchestrator/semanticVerification.d.ts +135 -0
- package/dist/_types/orchestrator/source-wide-extraction.d.ts +202 -0
- package/dist/_types/orchestrator/steeringIntake.d.ts +123 -0
- package/dist/_types/orchestrator/structured-memory-extraction-worker.d.ts +89 -0
- package/dist/_types/orchestrator/structuredMemoryInference.d.ts +62 -0
- package/dist/_types/orchestrator/successful-procedure-memory.d.ts +127 -0
- package/dist/_types/orchestrator/supportedAnswer.d.ts +68 -0
- package/dist/_types/orchestrator/taskEffectEvidence.d.ts +38 -0
- package/dist/_types/orchestrator/taskExecutionSnapshot.d.ts +67 -0
- package/dist/_types/orchestrator/taskObjective.d.ts +310 -0
- package/dist/_types/orchestrator/taskObjectiveContinuation.d.ts +134 -0
- package/dist/_types/orchestrator/taskRequirementReview.d.ts +246 -0
- package/dist/_types/orchestrator/taskRequirements.d.ts +80 -0
- package/dist/_types/orchestrator/taskSemanticAdmission.d.ts +159 -0
- package/dist/_types/orchestrator/taskWorkDelegation.d.ts +147 -0
- package/dist/_types/orchestrator/taskWorkPlan.d.ts +177 -0
- package/dist/_types/orchestrator/telegram-passive-history.d.ts +42 -0
- package/dist/_types/orchestrator/terminalTaskReport.d.ts +91 -0
- package/dist/_types/orchestrator/todoObservability.d.ts +147 -0
- package/dist/_types/orchestrator/tool-exposure-policy.d.ts +100 -0
- package/dist/_types/orchestrator/trajectory-checkpoint.d.ts +159 -0
- package/dist/_types/orchestrator/types.d.ts +185 -0
- package/dist/_types/schemas/dispatch.d.ts +53 -0
- package/dist/_types/schemas/feature-workflow.d.ts +362 -0
- package/dist/_types/schemas/messages.d.ts +15 -0
- package/dist/_types/schemas/nol-assets.d.ts +955 -0
- package/dist/_types/schemas/nol-json.d.ts +2 -0
- package/dist/_types/schemas/nol.d.ts +3995 -0
- package/dist/_types/schemas/patch.d.ts +47 -0
- package/dist/_types/schemas/plan.d.ts +47 -0
- package/dist/_types/schemas/repoProfile.d.ts +116 -0
- package/dist/_types/schemas/retrieval.d.ts +44 -0
- package/dist/_types/schemas/task.d.ts +57 -0
- package/dist/_types/schemas/tools.d.ts +16 -0
- package/dist/_types/schemas/verification.d.ts +31 -0
- package/dist/api/py-embed.js +3353 -1829
- package/dist/assets/nol-checkpoint-editor.py +701 -0
- package/dist/assets/nol-gguf-checkpoint-editor.py +785 -0
- package/dist/assets/nol-gguf-control-reader.py +428 -0
- package/dist/assets/nol-gne-tools-worker.py +425 -0
- package/dist/assets/nol-gne-worker.py +1081 -0
- package/dist/assets/nol-lora-exporter.py +349 -0
- package/dist/assets/nol-pytorch-control-reader.py +470 -0
- package/dist/assets/nol-transformers-nnsight-worker.py +512 -0
- package/dist/assets/nol-transformers-peft-validation-worker.py +385 -0
- package/dist/assets/nol-transformers-peft-worker.py +488 -0
- package/dist/assets/nol-transformers-research-worker.py +472 -0
- package/dist/assets/nol-transformers-worker.py +920 -0
- package/dist/assets/nol-vllm-owned-worker.py +803 -0
- package/dist/assets/nol-vllm-runtime.py +695 -0
- package/dist/assets/nol-vllm-tokenizer.py +93 -0
- package/dist/assets/nol-vllm-worker.py +201 -0
- package/dist/computer-use/configured-planner.d.ts +37 -0
- package/dist/computer-use/configured-point.d.ts +35 -0
- package/dist/computer-use/host-session.d.ts +60 -0
- package/dist/computer-use/runner-ui-port.d.ts +37 -0
- package/dist/computer-use/session-review.d.ts +14 -0
- package/dist/computer-use/task-spec.d.ts +84 -0
- package/dist/discovery.d.ts +16 -2
- package/dist/index.js +2 -2
- package/dist/library.d.ts +94 -10
- package/dist/library.js +144003 -87414
- package/dist/memory-maintenance-worker.js +1676 -511
- package/dist/nol/cpu-control-reader-profile.d.ts +93 -0
- package/dist/nol/cpu-control-reader-service.d.ts +87 -0
- package/dist/nol/cuda-lease.d.ts +111 -0
- package/dist/nol/cuda-mutations.d.ts +34 -0
- package/dist/nol/export-runtime-config.d.ts +114 -0
- package/dist/nol/export-service.d.ts +143 -0
- package/dist/nol/facade.d.ts +147 -0
- package/dist/nol/gguf-cpu-control-reader-profile.d.ts +106 -0
- package/dist/nol/gguf-cpu-control-reader-service.d.ts +91 -0
- package/dist/nol/gguf-model-control-verifier.d.ts +120 -0
- package/dist/nol/gguf-parameter-inventory.d.ts +28 -0
- package/dist/nol/gne-adapter.d.ts +134 -0
- package/dist/nol/gne-agent-evaluation.d.ts +84 -0
- package/dist/nol/gne-profile.d.ts +124 -0
- package/dist/nol/gne-tools-profile.d.ts +148 -0
- package/dist/nol/gne-tools-transport.d.ts +194 -0
- package/dist/nol/model-actions.d.ts +662 -0
- package/dist/nol/model-control-verifier.d.ts +135 -0
- package/dist/nol/model-json-scorer.d.ts +13 -0
- package/dist/nol/model-runtime-config.d.ts +830 -0
- package/dist/nol/model-serving.d.ts +130 -0
- package/dist/nol/model-subject-adapter.d.ts +72 -0
- package/dist/nol/model-validation-factory.d.ts +113 -0
- package/dist/nol/neuronary-catalog.d.ts +130 -0
- package/dist/nol/orphan-custody.d.ts +72 -0
- package/dist/nol/peft-conformance.d.ts +48 -0
- package/dist/nol/peft-control-types.d.ts +137 -0
- package/dist/nol/peft-control-verifier.d.ts +8 -0
- package/dist/nol/peft-model-actions.d.ts +41 -0
- package/dist/nol/peft-model-authority.d.ts +146 -0
- package/dist/nol/peft-model-controls.d.ts +20 -0
- package/dist/nol/peft-model-host.d.ts +47 -0
- package/dist/nol/peft-model-profile.d.ts +161 -0
- package/dist/nol/peft-model-runtime-config.d.ts +174 -0
- package/dist/nol/peft-model-subject-adapter.d.ts +36 -0
- package/dist/nol/peft-validation.d.ts +105 -0
- package/dist/nol/persistent-parameter-inventory.d.ts +32 -0
- package/dist/nol/runtime.d.ts +100 -0
- package/dist/nol/sqlite-store.d.ts +80 -0
- package/dist/nol/transformers-adapter.d.ts +119 -0
- package/dist/nol/transformers-nnsight.d.ts +87 -0
- package/dist/nol/transformers-peft.d.ts +107 -0
- package/dist/nol/transformers-research.d.ts +114 -0
- package/dist/nol/variant-service.d.ts +143 -0
- package/dist/nol/variant-store.d.ts +51 -0
- package/dist/nol/vllm-actions.d.ts +774 -0
- package/dist/nol/vllm-adapter.d.ts +1473 -0
- package/dist/nol/vllm-authority.d.ts +55 -0
- package/dist/nol/vllm-conformance.d.ts +662 -0
- package/dist/nol/vllm-profile.d.ts +850 -0
- package/dist/nol/vllm-protocol.d.ts +1505 -0
- package/dist/nol/vllm-runtime-config.d.ts +120 -0
- package/dist/nol/vllm-runtime.d.ts +34 -0
- package/dist/nol/vllm-startup.d.ts +235 -0
- package/dist/omni-setup-worker.js +3433 -1909
- package/dist/service-version.d.ts +0 -1
- package/dist/tui/async-process.d.ts +27 -0
- package/dist/tui/native/worker.js +3 -1
- package/dist/tui/telegram-action-session-registry.d.ts +136 -0
- package/dist/tui/telegram-cognition-queue.d.ts +154 -0
- package/dist/tui/telegram-context-packet-v2.d.ts +99 -0
- package/dist/tui/telegram-input-ownership.d.ts +78 -0
- package/dist/tui/telegram-turn-contract-v2.d.ts +62 -0
- package/dist/update-worker-runtime.js +4216 -2603
- package/docs/DISCOVERY.json +389 -0
- package/docs/DISCOVERY.md +4 -0
- package/npm-shrinkwrap.json +28 -12
- package/package.json +3 -2
|
@@ -692,32 +692,32 @@ var FeatureWorkflowPlanSchema = z.object({
|
|
|
692
692
|
}).strict()).min(4).max(256),
|
|
693
693
|
cards: z.array(FeatureWorkflowCardSchema).min(6).max(128)
|
|
694
694
|
}).strict().superRefine((plan, ctx) => {
|
|
695
|
-
const
|
|
696
|
-
const
|
|
695
|
+
const fail2 = (message) => ctx.addIssue({ code: "custom", message });
|
|
696
|
+
const unique2 = (values, label) => {
|
|
697
697
|
if (new Set(values).size !== values.length)
|
|
698
|
-
|
|
698
|
+
fail2(`duplicate ${label}`);
|
|
699
699
|
};
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
700
|
+
unique2(plan.cards.map((c) => c.id), "card id");
|
|
701
|
+
unique2(plan.slots.map((s) => s.id), "slot id");
|
|
702
|
+
unique2(plan.sources.map((s) => s.id), "source id");
|
|
703
|
+
unique2(plan.requirements.map((r) => r.id), "requirement id");
|
|
704
704
|
const cards = new Map(plan.cards.map((c) => [c.id, c]));
|
|
705
705
|
const slots = new Map(plan.slots.map((s) => [s.id, s]));
|
|
706
706
|
const sources = new Set(plan.sources.map((s) => s.id));
|
|
707
707
|
const assertions = new Map(plan.requirements.map((r) => [r.id, 0]));
|
|
708
708
|
for (const phase of FEATURE_WORKFLOW_PHASES)
|
|
709
709
|
if (!plan.cards.some((c) => c.phase === phase))
|
|
710
|
-
|
|
710
|
+
fail2(`missing phase ${phase}`);
|
|
711
711
|
for (const slot of plan.slots) {
|
|
712
712
|
if (slot.id.startsWith("source:"))
|
|
713
|
-
|
|
713
|
+
fail2(`reserved source namespace ${slot.id}`);
|
|
714
714
|
const producer = cards.get(slot.cardId);
|
|
715
715
|
if (!producer)
|
|
716
|
-
|
|
716
|
+
fail2(`unknown producer ${slot.cardId}`);
|
|
717
717
|
if (slot.requiresReview && !plan.cards.some((c) => c.role === "reviewer" && c.reviewSlots.includes(slot.id)))
|
|
718
|
-
|
|
718
|
+
fail2(`missing independent review for ${slot.id}`);
|
|
719
719
|
if (slot.requiresReview && producer && plan.cards.some((c) => c.reviewSlots.includes(slot.id) && c.phase !== producer.phase))
|
|
720
|
-
|
|
720
|
+
fail2(`review must occur in producer phase ${slot.id}`);
|
|
721
721
|
}
|
|
722
722
|
for (const kind of [
|
|
723
723
|
"research",
|
|
@@ -726,13 +726,13 @@ var FeatureWorkflowPlanSchema = z.object({
|
|
|
726
726
|
"handoff"
|
|
727
727
|
]) {
|
|
728
728
|
if (!plan.slots.some((s) => s.kind === kind && cards.get(s.cardId)?.phase === kind))
|
|
729
|
-
|
|
729
|
+
fail2(`missing ${kind} artifact`);
|
|
730
730
|
}
|
|
731
731
|
if (!plan.slots.some((s) => s.kind === "specification" && s.requiresReview))
|
|
732
|
-
|
|
732
|
+
fail2("specification requires independent review");
|
|
733
733
|
for (const card of plan.cards) {
|
|
734
734
|
if (card.role !== "reviewer" && card.role !== "verifier" && !plan.slots.some((slot) => slot.cardId === card.id))
|
|
735
|
-
|
|
735
|
+
fail2(`work card requires an artifact slot ${card.id}`);
|
|
736
736
|
for (const [label, values] of Object.entries({
|
|
737
737
|
dependency: card.dependsOn,
|
|
738
738
|
source: card.sourceIds,
|
|
@@ -740,53 +740,53 @@ var FeatureWorkflowPlanSchema = z.object({
|
|
|
740
740
|
review: card.reviewSlots,
|
|
741
741
|
acceptance: card.acceptanceIds
|
|
742
742
|
}))
|
|
743
|
-
|
|
743
|
+
unique2(values, `${label} in ${card.id}`);
|
|
744
744
|
for (const dep of card.dependsOn)
|
|
745
745
|
if (!cards.has(dep))
|
|
746
|
-
|
|
746
|
+
fail2(`unknown dependency ${dep}`);
|
|
747
747
|
for (const source of card.sourceIds)
|
|
748
748
|
if (!sources.has(source))
|
|
749
|
-
|
|
749
|
+
fail2(`unknown source ${source}`);
|
|
750
750
|
for (const slotId of [...card.inputSlots, ...card.reviewSlots]) {
|
|
751
751
|
const slot = slots.get(slotId);
|
|
752
752
|
if (!slot) {
|
|
753
|
-
|
|
753
|
+
fail2(`unknown slot ${slotId}`);
|
|
754
754
|
continue;
|
|
755
755
|
}
|
|
756
756
|
const producer = cards.get(slot.cardId);
|
|
757
757
|
if (slot.cardId === card.id)
|
|
758
|
-
|
|
758
|
+
fail2(`self-dependent slot ${slotId}`);
|
|
759
759
|
if (producer && FEATURE_WORKFLOW_PHASES.indexOf(producer.phase) > FEATURE_WORKFLOW_PHASES.indexOf(card.phase))
|
|
760
|
-
|
|
760
|
+
fail2(`future slot ${slotId}`);
|
|
761
761
|
}
|
|
762
762
|
for (const dep of card.dependsOn) {
|
|
763
763
|
const source = cards.get(dep);
|
|
764
764
|
if (source && FEATURE_WORKFLOW_PHASES.indexOf(source.phase) > FEATURE_WORKFLOW_PHASES.indexOf(card.phase))
|
|
765
|
-
|
|
765
|
+
fail2(`future dependency ${dep}`);
|
|
766
766
|
}
|
|
767
767
|
if (card.role === "reviewer" !== card.reviewSlots.length > 0)
|
|
768
|
-
|
|
768
|
+
fail2(`review role/slots mismatch ${card.id}`);
|
|
769
769
|
if (card.phase === "acceptance" && (card.role !== "verifier" || !card.verifier || card.acceptanceIds.length === 0))
|
|
770
|
-
|
|
770
|
+
fail2(`acceptance needs explicit verifier ${card.id}`);
|
|
771
771
|
if (card.phase !== "acceptance" && (card.verifier || card.acceptanceIds.length))
|
|
772
|
-
|
|
772
|
+
fail2(`acceptance authority outside acceptance phase ${card.id}`);
|
|
773
773
|
if (card.phase === "implementation" && card.role !== "reviewer" && (card.role !== "implementer" || card.ownedFiles.length === 0))
|
|
774
|
-
|
|
774
|
+
fail2(`implementation needs owned files ${card.id}`);
|
|
775
775
|
for (const assertion of card.acceptanceIds) {
|
|
776
776
|
if (!assertions.has(assertion))
|
|
777
|
-
|
|
777
|
+
fail2(`unknown acceptance ${assertion}`);
|
|
778
778
|
else
|
|
779
779
|
assertions.set(assertion, assertions.get(assertion) + 1);
|
|
780
780
|
}
|
|
781
781
|
}
|
|
782
|
-
for (const [assertion,
|
|
783
|
-
if (
|
|
784
|
-
|
|
782
|
+
for (const [assertion, count2] of assertions)
|
|
783
|
+
if (count2 !== 1)
|
|
784
|
+
fail2(`acceptance ${assertion} must have exactly one owner`);
|
|
785
785
|
const visiting = /* @__PURE__ */ new Set();
|
|
786
786
|
const visited = /* @__PURE__ */ new Set();
|
|
787
787
|
const visit = (cardId) => {
|
|
788
788
|
if (visiting.has(cardId)) {
|
|
789
|
-
|
|
789
|
+
fail2(`dependency cycle ${cardId}`);
|
|
790
790
|
return;
|
|
791
791
|
}
|
|
792
792
|
if (visited.has(cardId))
|
|
@@ -852,44 +852,1209 @@ var FeatureWorkflowToolInputSchema = z.discriminatedUnion("action", [
|
|
|
852
852
|
]);
|
|
853
853
|
var FeatureWorkflowToolJsonSchema = z.toJSONSchema(FeatureWorkflowToolInputSchema, { reused: "ref", unrepresentable: "any" });
|
|
854
854
|
|
|
855
|
-
// packages/schemas/dist/
|
|
855
|
+
// packages/schemas/dist/nol.js
|
|
856
856
|
import { z as z2 } from "zod";
|
|
857
|
-
var
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
857
|
+
var NolSha256Schema = z2.string().regex(/^[a-f0-9]{64}$/);
|
|
858
|
+
var NolIdSchema = z2.string().regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$/);
|
|
859
|
+
var text2 = z2.string().min(1).max(4096).refine((value) => value === value.trim(), "text must not contain outer whitespace");
|
|
860
|
+
var count = z2.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
861
|
+
var positive = count.min(1);
|
|
862
|
+
var uint32 = count.max(4294967295);
|
|
863
|
+
var finite = z2.number().finite();
|
|
864
|
+
var probability = finite.gt(0).lt(1);
|
|
865
|
+
var timestamp = z2.string().datetime();
|
|
866
|
+
var fail = (ctx, message) => ctx.addIssue({ code: "custom", message });
|
|
867
|
+
var unique = (values, ctx, label) => {
|
|
868
|
+
if (new Set(values).size !== values.length)
|
|
869
|
+
fail(ctx, `duplicate ${label}`);
|
|
870
|
+
};
|
|
871
|
+
var NolArtifactRefSchema = z2.object({
|
|
872
|
+
uri: z2.string().regex(/^omnius-artifact:\/\/sha256\/[a-f0-9]{64}$/),
|
|
873
|
+
sha256: NolSha256Schema,
|
|
874
|
+
sizeBytes: count,
|
|
875
|
+
mediaType: z2.string().min(1).max(200).refine((value) => value === value.trim(), "media type must not contain outer whitespace")
|
|
876
|
+
}).strict().superRefine((value, ctx) => {
|
|
877
|
+
if (value.uri !== `omnius-artifact://sha256/${value.sha256}`)
|
|
878
|
+
fail(ctx, "artifact URI/hash mismatch");
|
|
864
879
|
});
|
|
880
|
+
var tensorDtype = z2.enum([
|
|
881
|
+
"f16",
|
|
882
|
+
"bf16",
|
|
883
|
+
"f32",
|
|
884
|
+
"f64",
|
|
885
|
+
"i8",
|
|
886
|
+
"i16",
|
|
887
|
+
"i32",
|
|
888
|
+
"i64",
|
|
889
|
+
"u8",
|
|
890
|
+
"bool",
|
|
891
|
+
"quantized"
|
|
892
|
+
]);
|
|
893
|
+
var tensorShape = z2.array(positive).max(8).refine((shape) => Number.isSafeInteger(shape.reduce((size, dimension) => size * dimension, 1)), "tensor element count exceeds safe integer bounds");
|
|
894
|
+
var NolTensorArtifactSchema = z2.object({
|
|
895
|
+
artifact: NolArtifactRefSchema,
|
|
896
|
+
shape: tensorShape,
|
|
897
|
+
dtype: tensorDtype
|
|
898
|
+
}).strict();
|
|
899
|
+
var NolModelFormatSchema = z2.enum([
|
|
900
|
+
"gguf",
|
|
901
|
+
"safetensors",
|
|
902
|
+
"pytorch",
|
|
903
|
+
"hf",
|
|
904
|
+
"gguf_adapter",
|
|
905
|
+
"safetensors_adapter",
|
|
906
|
+
"pytorch_adapter",
|
|
907
|
+
"lora"
|
|
908
|
+
]);
|
|
909
|
+
var NolTensorSiteKindSchema = z2.enum([
|
|
910
|
+
"mlp_intermediate",
|
|
911
|
+
"residual",
|
|
912
|
+
"attention_head",
|
|
913
|
+
"expert_output",
|
|
914
|
+
"router_logits",
|
|
915
|
+
"parameter"
|
|
916
|
+
]);
|
|
917
|
+
var NolTensorSiteSchema = z2.discriminatedUnion("kind", [
|
|
918
|
+
z2.object({
|
|
919
|
+
id: NolIdSchema,
|
|
920
|
+
kind: z2.literal("mlp_intermediate"),
|
|
921
|
+
layer: count,
|
|
922
|
+
width: positive
|
|
923
|
+
}).strict(),
|
|
924
|
+
z2.object({
|
|
925
|
+
id: NolIdSchema,
|
|
926
|
+
kind: z2.literal("residual"),
|
|
927
|
+
layer: count,
|
|
928
|
+
width: positive
|
|
929
|
+
}).strict(),
|
|
930
|
+
z2.object({
|
|
931
|
+
id: NolIdSchema,
|
|
932
|
+
kind: z2.literal("attention_head"),
|
|
933
|
+
layer: count,
|
|
934
|
+
headCount: positive,
|
|
935
|
+
width: positive
|
|
936
|
+
}).strict(),
|
|
937
|
+
z2.object({
|
|
938
|
+
id: NolIdSchema,
|
|
939
|
+
kind: z2.literal("expert_output"),
|
|
940
|
+
layer: count,
|
|
941
|
+
expertCount: positive,
|
|
942
|
+
width: positive
|
|
943
|
+
}).strict(),
|
|
944
|
+
z2.object({
|
|
945
|
+
id: NolIdSchema,
|
|
946
|
+
kind: z2.literal("router_logits"),
|
|
947
|
+
layer: count,
|
|
948
|
+
expertCount: positive
|
|
949
|
+
}).strict(),
|
|
950
|
+
z2.object({
|
|
951
|
+
id: NolIdSchema,
|
|
952
|
+
kind: z2.literal("parameter"),
|
|
953
|
+
name: text2,
|
|
954
|
+
layer: count.optional(),
|
|
955
|
+
shape: tensorShape,
|
|
956
|
+
dtype: tensorDtype,
|
|
957
|
+
role: z2.enum([
|
|
958
|
+
"ffn",
|
|
959
|
+
"attention",
|
|
960
|
+
"embedding",
|
|
961
|
+
"router",
|
|
962
|
+
"bias",
|
|
963
|
+
"norm",
|
|
964
|
+
"other"
|
|
965
|
+
])
|
|
966
|
+
}).strict()
|
|
967
|
+
]);
|
|
968
|
+
var NolModelManifestSchema = z2.object({
|
|
969
|
+
schema: z2.literal("omnius.nol.model.v1"),
|
|
970
|
+
id: NolIdSchema,
|
|
971
|
+
modelDigest: NolSha256Schema,
|
|
972
|
+
format: NolModelFormatSchema,
|
|
973
|
+
files: z2.array(z2.object({
|
|
974
|
+
path: z2.string().min(1).max(1024).refine((value) => !value.startsWith("/") && !/^[A-Za-z]:/.test(value) && !value.includes("\0") && !value.includes("\\") && value.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== ".."), "model paths must be normalized relative paths"),
|
|
975
|
+
role: z2.enum([
|
|
976
|
+
"weights",
|
|
977
|
+
"tokenizer",
|
|
978
|
+
"config",
|
|
979
|
+
"chat_template",
|
|
980
|
+
"adapter",
|
|
981
|
+
"other"
|
|
982
|
+
]),
|
|
983
|
+
artifact: NolArtifactRefSchema
|
|
984
|
+
}).strict()).min(1).max(1e5),
|
|
985
|
+
parents: z2.array(z2.object({ modelDigest: NolSha256Schema, revision: text2.optional() }).strict()).max(128),
|
|
986
|
+
architecture: z2.object({ family: text2, layers: positive, hiddenSize: positive }).strict(),
|
|
987
|
+
architectureMapDigest: NolSha256Schema,
|
|
988
|
+
tensorSites: z2.array(NolTensorSiteSchema).min(1).max(1e5),
|
|
989
|
+
quantization: z2.object({
|
|
990
|
+
method: text2,
|
|
991
|
+
bits: finite.gt(0).max(64).optional(),
|
|
992
|
+
groupSize: positive.optional(),
|
|
993
|
+
configDigest: NolSha256Schema.optional()
|
|
994
|
+
}).strict(),
|
|
995
|
+
tokenizerDigest: NolSha256Schema,
|
|
996
|
+
specialTokens: z2.record(z2.string(), count),
|
|
997
|
+
chatTemplateDigest: NolSha256Schema,
|
|
998
|
+
contextLength: positive
|
|
999
|
+
}).strict().superRefine((value, ctx) => {
|
|
1000
|
+
unique(value.files.map((file) => file.path), ctx, "model file path");
|
|
1001
|
+
unique(value.parents.map((parent) => parent.modelDigest), ctx, "model parent");
|
|
1002
|
+
unique(value.tensorSites.map((site) => site.id), ctx, "tensor site");
|
|
1003
|
+
unique(value.tensorSites.filter((site) => site.kind === "parameter").map((site) => site.name), ctx, "parameter name");
|
|
1004
|
+
if (!value.files.some((file) => file.role === "weights" || file.role === "adapter"))
|
|
1005
|
+
fail(ctx, "model requires weights or adapter files");
|
|
1006
|
+
if (value.files.some((file) => (file.role === "weights" || file.role === "adapter") && file.artifact.sizeBytes === 0))
|
|
1007
|
+
fail(ctx, "weight/adapter files cannot be empty");
|
|
1008
|
+
if (value.parents.some((parent) => parent.modelDigest === value.modelDigest))
|
|
1009
|
+
fail(ctx, "model cannot parent itself");
|
|
1010
|
+
for (const site of value.tensorSites)
|
|
1011
|
+
if (site.layer !== void 0 && site.layer >= value.architecture.layers)
|
|
1012
|
+
fail(ctx, `site ${site.id} layer is out of bounds`);
|
|
1013
|
+
});
|
|
1014
|
+
var NolRuntimeBindingSchema = z2.object({
|
|
1015
|
+
schema: z2.literal("omnius.nol.runtime.v1"),
|
|
1016
|
+
id: NolIdSchema,
|
|
1017
|
+
backend: z2.enum([
|
|
1018
|
+
"gne",
|
|
1019
|
+
"llama_cpp",
|
|
1020
|
+
"transformers",
|
|
1021
|
+
"nnsight",
|
|
1022
|
+
"ollama",
|
|
1023
|
+
"vllm",
|
|
1024
|
+
"other"
|
|
1025
|
+
]),
|
|
1026
|
+
modelDigest: NolSha256Schema,
|
|
1027
|
+
architectureMapDigest: NolSha256Schema,
|
|
1028
|
+
runtimeBuildDigest: NolSha256Schema,
|
|
1029
|
+
dependencyLockDigest: NolSha256Schema,
|
|
1030
|
+
tokenizerDigest: NolSha256Schema,
|
|
1031
|
+
chatTemplateDigest: NolSha256Schema,
|
|
1032
|
+
contextLimit: positive
|
|
1033
|
+
}).strict();
|
|
1034
|
+
var NolCalibrationSchema = z2.object({
|
|
1035
|
+
schema: z2.literal("omnius.nol.calibration.v1"),
|
|
1036
|
+
id: NolIdSchema,
|
|
1037
|
+
modelDigest: NolSha256Schema,
|
|
1038
|
+
architectureMapDigest: NolSha256Schema,
|
|
1039
|
+
units: z2.enum(["raw", "residual_norm", "activation_std"]),
|
|
1040
|
+
definitionDigest: NolSha256Schema,
|
|
1041
|
+
corpusDigest: NolSha256Schema.optional(),
|
|
1042
|
+
tokenPositionsDigest: NolSha256Schema.optional(),
|
|
1043
|
+
statistics: NolArtifactRefSchema.optional(),
|
|
1044
|
+
siteScales: z2.array(z2.object({ siteId: NolIdSchema, scale: finite.gt(0) }).strict()).max(1e5)
|
|
1045
|
+
}).strict().superRefine((value, ctx) => {
|
|
1046
|
+
unique(value.siteScales.map((site) => site.siteId), ctx, "calibration site");
|
|
1047
|
+
if (value.units !== "raw" && (!value.corpusDigest || !value.tokenPositionsDigest || !value.statistics || !value.siteScales.length))
|
|
1048
|
+
fail(ctx, "normalized calibration requires corpus, positions, statistics and site scales");
|
|
1049
|
+
});
|
|
1050
|
+
var NolTokenScopeSchema = z2.discriminatedUnion("kind", [
|
|
1051
|
+
z2.object({ kind: z2.literal("all") }).strict(),
|
|
1052
|
+
z2.object({ kind: z2.literal("prompt") }).strict(),
|
|
1053
|
+
z2.object({ kind: z2.literal("generated") }).strict(),
|
|
1054
|
+
z2.object({
|
|
1055
|
+
kind: z2.literal("positions"),
|
|
1056
|
+
positions: z2.array(count).min(1).max(1e5)
|
|
1057
|
+
}).strict()
|
|
1058
|
+
]).superRefine((value, ctx) => {
|
|
1059
|
+
if (value.kind === "positions")
|
|
1060
|
+
unique(value.positions.map(String), ctx, "edited computation position");
|
|
1061
|
+
});
|
|
1062
|
+
var NOL_OPERATIONS = [
|
|
1063
|
+
"NEURON_ADD",
|
|
1064
|
+
"NEURON_GAIN",
|
|
1065
|
+
"NEURON_REPLACE",
|
|
1066
|
+
"RESIDUAL_ADD",
|
|
1067
|
+
"DIRECTION_PROJECT",
|
|
1068
|
+
"ATTENTION_HEAD_GAIN",
|
|
1069
|
+
"EXPERT_GAIN",
|
|
1070
|
+
"EXPERT_ROUTING_BIAS",
|
|
1071
|
+
"WEIGHT_ADD",
|
|
1072
|
+
"WEIGHT_GAIN",
|
|
1073
|
+
"WEIGHT_REPLACE",
|
|
1074
|
+
"WEIGHT_PROJECT",
|
|
1075
|
+
"LOW_RANK_UPDATE",
|
|
1076
|
+
"WEIGHT_MERGE"
|
|
1077
|
+
];
|
|
1078
|
+
var NolOperationKindSchema = z2.enum(NOL_OPERATIONS);
|
|
1079
|
+
var operationBase = {
|
|
1080
|
+
id: NolIdSchema,
|
|
1081
|
+
siteId: NolIdSchema,
|
|
1082
|
+
tokenScope: NolTokenScopeSchema
|
|
1083
|
+
};
|
|
1084
|
+
var calibrated = {
|
|
1085
|
+
units: z2.enum(["raw", "residual_norm", "activation_std"]),
|
|
1086
|
+
calibrationId: NolIdSchema.optional()
|
|
1087
|
+
};
|
|
1088
|
+
var tensorOrScalar = z2.discriminatedUnion("kind", [
|
|
1089
|
+
z2.object({ kind: z2.literal("scalar"), value: finite }).strict(),
|
|
1090
|
+
z2.object({ kind: z2.literal("tensor"), tensor: NolTensorArtifactSchema }).strict()
|
|
1091
|
+
]);
|
|
1092
|
+
var NolOperationSchema = z2.discriminatedUnion("operation", [
|
|
1093
|
+
z2.object({
|
|
1094
|
+
...operationBase,
|
|
1095
|
+
operation: z2.literal("NEURON_ADD"),
|
|
1096
|
+
neuron: count,
|
|
1097
|
+
amount: finite,
|
|
1098
|
+
...calibrated
|
|
1099
|
+
}).strict(),
|
|
1100
|
+
z2.object({
|
|
1101
|
+
...operationBase,
|
|
1102
|
+
operation: z2.literal("NEURON_GAIN"),
|
|
1103
|
+
neuron: count,
|
|
1104
|
+
factor: finite
|
|
1105
|
+
}).strict(),
|
|
1106
|
+
z2.object({
|
|
1107
|
+
...operationBase,
|
|
1108
|
+
operation: z2.literal("NEURON_REPLACE"),
|
|
1109
|
+
neuron: count,
|
|
1110
|
+
replacement: tensorOrScalar,
|
|
1111
|
+
...calibrated
|
|
1112
|
+
}).strict(),
|
|
1113
|
+
z2.object({
|
|
1114
|
+
...operationBase,
|
|
1115
|
+
operation: z2.literal("RESIDUAL_ADD"),
|
|
1116
|
+
vector: NolTensorArtifactSchema,
|
|
1117
|
+
scale: finite,
|
|
1118
|
+
...calibrated
|
|
1119
|
+
}).strict(),
|
|
1120
|
+
z2.object({
|
|
1121
|
+
...operationBase,
|
|
1122
|
+
operation: z2.literal("DIRECTION_PROJECT"),
|
|
1123
|
+
basis: NolTensorArtifactSchema,
|
|
1124
|
+
strength: finite,
|
|
1125
|
+
normalization: z2.literal("orthonormal")
|
|
1126
|
+
}).strict(),
|
|
1127
|
+
z2.object({
|
|
1128
|
+
...operationBase,
|
|
1129
|
+
operation: z2.literal("ATTENTION_HEAD_GAIN"),
|
|
1130
|
+
head: count,
|
|
1131
|
+
factor: finite
|
|
1132
|
+
}).strict(),
|
|
1133
|
+
z2.object({
|
|
1134
|
+
...operationBase,
|
|
1135
|
+
operation: z2.literal("EXPERT_GAIN"),
|
|
1136
|
+
expert: count,
|
|
1137
|
+
factor: finite
|
|
1138
|
+
}).strict(),
|
|
1139
|
+
z2.object({
|
|
1140
|
+
...operationBase,
|
|
1141
|
+
operation: z2.literal("EXPERT_ROUTING_BIAS"),
|
|
1142
|
+
expert: count,
|
|
1143
|
+
amount: finite,
|
|
1144
|
+
...calibrated
|
|
1145
|
+
}).strict(),
|
|
1146
|
+
z2.object({
|
|
1147
|
+
...operationBase,
|
|
1148
|
+
operation: z2.literal("WEIGHT_ADD"),
|
|
1149
|
+
delta: tensorOrScalar
|
|
1150
|
+
}).strict(),
|
|
1151
|
+
z2.object({
|
|
1152
|
+
...operationBase,
|
|
1153
|
+
operation: z2.literal("WEIGHT_GAIN"),
|
|
1154
|
+
gain: z2.discriminatedUnion("kind", [
|
|
1155
|
+
z2.object({ kind: z2.literal("scalar"), factor: finite }).strict(),
|
|
1156
|
+
z2.object({
|
|
1157
|
+
kind: z2.literal("axis"),
|
|
1158
|
+
axis: count,
|
|
1159
|
+
factors: NolTensorArtifactSchema
|
|
1160
|
+
}).strict()
|
|
1161
|
+
])
|
|
1162
|
+
}).strict(),
|
|
1163
|
+
z2.object({
|
|
1164
|
+
...operationBase,
|
|
1165
|
+
operation: z2.literal("WEIGHT_REPLACE"),
|
|
1166
|
+
replacement: NolTensorArtifactSchema
|
|
1167
|
+
}).strict(),
|
|
1168
|
+
z2.object({
|
|
1169
|
+
...operationBase,
|
|
1170
|
+
operation: z2.literal("WEIGHT_PROJECT"),
|
|
1171
|
+
side: z2.enum(["left", "right"]),
|
|
1172
|
+
basis: NolTensorArtifactSchema,
|
|
1173
|
+
strength: finite,
|
|
1174
|
+
normalization: z2.literal("orthonormal")
|
|
1175
|
+
}).strict(),
|
|
1176
|
+
// delta W = scale * (alpha / rank) * B @ A; both scalars are explicit.
|
|
1177
|
+
z2.object({
|
|
1178
|
+
...operationBase,
|
|
1179
|
+
operation: z2.literal("LOW_RANK_UPDATE"),
|
|
1180
|
+
a: NolTensorArtifactSchema,
|
|
1181
|
+
b: NolTensorArtifactSchema,
|
|
1182
|
+
rank: positive,
|
|
1183
|
+
alpha: finite,
|
|
1184
|
+
scale: finite,
|
|
1185
|
+
scaling: z2.literal("alpha_over_rank")
|
|
1186
|
+
}).strict(),
|
|
1187
|
+
// W' = sum(source.weight * W_source). No implicit base contribution/normalization.
|
|
1188
|
+
z2.object({
|
|
1189
|
+
...operationBase,
|
|
1190
|
+
operation: z2.literal("WEIGHT_MERGE"),
|
|
1191
|
+
sources: z2.array(z2.object({
|
|
1192
|
+
modelDigest: NolSha256Schema,
|
|
1193
|
+
siteId: NolIdSchema,
|
|
1194
|
+
weight: finite
|
|
1195
|
+
}).strict()).min(1).max(128)
|
|
1196
|
+
}).strict()
|
|
1197
|
+
]);
|
|
1198
|
+
var NolRecipeRevisionSchema = z2.object({
|
|
1199
|
+
schema: z2.literal("omnius.nol.recipe.v1"),
|
|
1200
|
+
id: NolIdSchema,
|
|
1201
|
+
revision: positive,
|
|
1202
|
+
recipeDigest: NolSha256Schema,
|
|
1203
|
+
modelDigest: NolSha256Schema,
|
|
1204
|
+
architectureMapDigest: NolSha256Schema,
|
|
1205
|
+
approximateLoweringAcknowledged: z2.literal(true).optional(),
|
|
1206
|
+
parentModelDigests: z2.array(NolSha256Schema).min(1).max(128),
|
|
1207
|
+
operations: z2.array(NolOperationSchema).min(1).max(1e4),
|
|
1208
|
+
calibrations: z2.array(NolCalibrationSchema).max(1e4),
|
|
1209
|
+
createdAt: timestamp,
|
|
1210
|
+
provenance: z2.array(z2.object({
|
|
1211
|
+
source: text2,
|
|
1212
|
+
uri: text2.optional(),
|
|
1213
|
+
sourceDigest: NolSha256Schema.optional(),
|
|
1214
|
+
license: text2.optional(),
|
|
1215
|
+
/** Explicit immutable proof; uri alone remains a metadata locator. */
|
|
1216
|
+
artifact: NolArtifactRefSchema.optional()
|
|
1217
|
+
}).strict().superRefine((value, ctx) => {
|
|
1218
|
+
if (value.artifact && value.uri?.startsWith("omnius-artifact://") && value.uri !== value.artifact.uri)
|
|
1219
|
+
fail(ctx, "internal provenance URI must match its artifact reference");
|
|
1220
|
+
})).max(1e3)
|
|
1221
|
+
}).strict().superRefine((value, ctx) => {
|
|
1222
|
+
unique(value.operations.map((operation) => operation.id), ctx, "operation id");
|
|
1223
|
+
unique(value.calibrations.map((calibration) => calibration.id), ctx, "calibration id");
|
|
1224
|
+
unique(value.parentModelDigests, ctx, "recipe parent");
|
|
1225
|
+
if (!value.parentModelDigests.includes(value.modelDigest))
|
|
1226
|
+
fail(ctx, "recipe must declare its exact base parent");
|
|
1227
|
+
const calibrations = new Map(value.calibrations.map((calibration) => [calibration.id, calibration]));
|
|
1228
|
+
for (const calibration of value.calibrations)
|
|
1229
|
+
if (calibration.modelDigest !== value.modelDigest || calibration.architectureMapDigest !== value.architectureMapDigest)
|
|
1230
|
+
fail(ctx, "calibration/model binding mismatch");
|
|
1231
|
+
for (const operation of value.operations) {
|
|
1232
|
+
if (operation.tokenScope.kind === "positions")
|
|
1233
|
+
unique(operation.tokenScope.positions.map(String), ctx, "edited computation position");
|
|
1234
|
+
if (isWeightOperation(operation.operation) && operation.tokenScope.kind !== "all")
|
|
1235
|
+
fail(ctx, "parameter edits require all-token scope");
|
|
1236
|
+
if ("units" in operation) {
|
|
1237
|
+
const calibration = operation.calibrationId ? calibrations.get(operation.calibrationId) : void 0;
|
|
1238
|
+
if (operation.units !== "raw" && !calibration)
|
|
1239
|
+
fail(ctx, "normalized operation requires a known calibration");
|
|
1240
|
+
if (operation.calibrationId && !calibration)
|
|
1241
|
+
fail(ctx, "unknown operation calibration");
|
|
1242
|
+
if (calibration && calibration.units !== operation.units)
|
|
1243
|
+
fail(ctx, "operation/calibration units mismatch");
|
|
1244
|
+
if (calibration && operation.units !== "raw" && !calibration.siteScales.some((site) => site.siteId === operation.siteId))
|
|
1245
|
+
fail(ctx, "calibration does not cover operation site");
|
|
1246
|
+
}
|
|
1247
|
+
if (operation.operation === "LOW_RANK_UPDATE" && (operation.a.shape.length !== 2 || operation.b.shape.length !== 2 || operation.a.shape[0] !== operation.rank || operation.b.shape[1] !== operation.rank))
|
|
1248
|
+
fail(ctx, "low-rank A/B shapes do not match rank");
|
|
1249
|
+
if (operation.operation === "LOW_RANK_UPDATE" && !Number.isFinite(operation.scale * (operation.alpha / operation.rank)))
|
|
1250
|
+
fail(ctx, "effective low-rank scale is nonfinite");
|
|
1251
|
+
if (operation.operation === "WEIGHT_MERGE") {
|
|
1252
|
+
unique(operation.sources.map((source) => `${source.modelDigest}:${source.siteId}`), ctx, "merge source");
|
|
1253
|
+
for (const source of operation.sources)
|
|
1254
|
+
if (!value.parentModelDigests.includes(source.modelDigest))
|
|
1255
|
+
fail(ctx, "merge source must be an exact declared parent");
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
var NolVariantManifestSchema = z2.object({
|
|
1260
|
+
schema: z2.literal("omnius.nol.variant.v1"),
|
|
1261
|
+
id: NolIdSchema,
|
|
1262
|
+
variantDigest: NolSha256Schema,
|
|
1263
|
+
modelDigest: NolSha256Schema,
|
|
1264
|
+
parentModelDigests: z2.array(NolSha256Schema).min(1).max(128),
|
|
1265
|
+
recipeDigest: NolSha256Schema.optional(),
|
|
1266
|
+
runtimeBuildDigest: NolSha256Schema,
|
|
1267
|
+
architectureMapDigest: NolSha256Schema,
|
|
1268
|
+
implementationDigest: NolSha256Schema,
|
|
1269
|
+
calibrationDigests: z2.array(NolSha256Schema).max(1e4),
|
|
1270
|
+
adapterArtifacts: z2.array(NolArtifactRefSchema).max(1e3),
|
|
1271
|
+
checkpointArtifacts: z2.array(NolArtifactRefSchema).max(1e5),
|
|
1272
|
+
createdAt: timestamp
|
|
1273
|
+
}).strict().superRefine((value, ctx) => {
|
|
1274
|
+
unique(value.parentModelDigests, ctx, "variant parent");
|
|
1275
|
+
unique(value.calibrationDigests, ctx, "variant calibration");
|
|
1276
|
+
unique([...value.adapterArtifacts, ...value.checkpointArtifacts].map((artifact) => artifact.sha256), ctx, "variant artifact");
|
|
1277
|
+
if (!value.recipeDigest && !value.adapterArtifacts.length && !value.checkpointArtifacts.length)
|
|
1278
|
+
fail(ctx, "variant requires a recipe, adapter or checkpoint");
|
|
1279
|
+
});
|
|
1280
|
+
var equivalence = z2.enum(["exact", "validated_equivalent", "approximate"]);
|
|
1281
|
+
var NolBackendCapabilitiesSchema = z2.object({
|
|
1282
|
+
schema: z2.literal("omnius.nol.capabilities.v1"),
|
|
1283
|
+
capabilitiesDigest: NolSha256Schema,
|
|
1284
|
+
binding: NolRuntimeBindingSchema,
|
|
1285
|
+
operations: z2.array(z2.object({
|
|
1286
|
+
operation: NolOperationKindSchema,
|
|
1287
|
+
siteKinds: z2.array(NolTensorSiteKindSchema).min(1).max(6),
|
|
1288
|
+
tokenScopes: z2.array(z2.enum(["all", "prompt", "generated", "positions"])).min(1).max(4),
|
|
1289
|
+
implementation: text2,
|
|
1290
|
+
implementationDigest: NolSha256Schema,
|
|
1291
|
+
equivalence,
|
|
1292
|
+
validationReceiptDigest: NolSha256Schema.optional()
|
|
1293
|
+
}).strict()).max(1e3),
|
|
1294
|
+
orderedOperations: z2.boolean(),
|
|
1295
|
+
observations: z2.array(z2.enum([
|
|
1296
|
+
"activation_summary",
|
|
1297
|
+
"activations",
|
|
1298
|
+
"logits",
|
|
1299
|
+
"full_distribution",
|
|
1300
|
+
"gradients"
|
|
1301
|
+
])).max(5),
|
|
1302
|
+
generation: z2.object({
|
|
1303
|
+
text: z2.boolean(),
|
|
1304
|
+
nativeTools: z2.boolean(),
|
|
1305
|
+
structuredOutput: z2.boolean(),
|
|
1306
|
+
streaming: z2.boolean(),
|
|
1307
|
+
cancellation: z2.boolean(),
|
|
1308
|
+
reset: z2.boolean()
|
|
1309
|
+
}).strict(),
|
|
1310
|
+
exports: z2.array(z2.object({
|
|
1311
|
+
format: NolModelFormatSchema,
|
|
1312
|
+
operations: z2.array(NolOperationKindSchema).min(1).max(14),
|
|
1313
|
+
tokenScopes: z2.array(z2.literal("all")).min(1).max(1)
|
|
1314
|
+
}).strict()).max(32)
|
|
1315
|
+
}).strict().superRefine((value, ctx) => {
|
|
1316
|
+
unique(value.operations.map((operation) => `${operation.operation}:${operation.implementationDigest}`), ctx, "capability implementation");
|
|
1317
|
+
unique(value.observations, ctx, "observation capability");
|
|
1318
|
+
for (const operation of value.operations) {
|
|
1319
|
+
unique(operation.siteKinds, ctx, "capability site kind");
|
|
1320
|
+
unique(operation.tokenScopes, ctx, "capability token scope");
|
|
1321
|
+
if (operation.equivalence === "validated_equivalent" && !operation.validationReceiptDigest)
|
|
1322
|
+
fail(ctx, "equivalent lowering requires a validation receipt");
|
|
1323
|
+
if (isWeightOperation(operation.operation) && operation.tokenScopes.some((scope) => scope !== "all"))
|
|
1324
|
+
fail(ctx, "parameter edit capability cannot claim token-masked semantics");
|
|
1325
|
+
if (value.binding.backend === "gne" && operation.operation === "NEURON_GAIN" && operation.tokenScopes.some((scope) => scope !== "all"))
|
|
1326
|
+
fail(ctx, "GNE LoRA gain supports all-token scope only");
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1329
|
+
var NolImplementationReceiptSchema = z2.object({
|
|
1330
|
+
schema: z2.literal("omnius.nol.implementation.v1"),
|
|
1331
|
+
id: NolIdSchema,
|
|
1332
|
+
binding: NolRuntimeBindingSchema,
|
|
1333
|
+
capabilitiesDigest: NolSha256Schema,
|
|
1334
|
+
recipeDigest: NolSha256Schema.optional(),
|
|
1335
|
+
operations: z2.array(z2.object({
|
|
1336
|
+
operationId: NolIdSchema,
|
|
1337
|
+
operation: NolOperationKindSchema,
|
|
1338
|
+
siteId: NolIdSchema,
|
|
1339
|
+
implementation: text2,
|
|
1340
|
+
implementationDigest: NolSha256Schema,
|
|
1341
|
+
equivalence,
|
|
1342
|
+
validationReceiptDigest: NolSha256Schema.optional(),
|
|
1343
|
+
calibrationId: NolIdSchema.optional(),
|
|
1344
|
+
tokenScope: NolTokenScopeSchema,
|
|
1345
|
+
editedPositions: NolArtifactRefSchema
|
|
1346
|
+
}).strict()).max(1e4),
|
|
1347
|
+
activeAdapters: z2.array(z2.object({ artifact: NolArtifactRefSchema, scale: finite }).strict()).max(1e3),
|
|
1348
|
+
cache: z2.object({
|
|
1349
|
+
mode: z2.enum(["cold", "isolated"]),
|
|
1350
|
+
keyDigest: NolSha256Schema
|
|
1351
|
+
}).strict(),
|
|
1352
|
+
reset: z2.discriminatedUnion("status", [
|
|
1353
|
+
z2.object({ status: z2.literal("verified"), proof: NolArtifactRefSchema }).strict(),
|
|
1354
|
+
z2.object({ status: z2.literal("failed"), reason: text2 }).strict(),
|
|
1355
|
+
z2.object({ status: z2.literal("not_attempted"), reason: text2 }).strict()
|
|
1356
|
+
]),
|
|
1357
|
+
observedArtifacts: z2.array(NolTensorArtifactSchema).max(1e4),
|
|
1358
|
+
recordedAt: timestamp
|
|
1359
|
+
}).strict().superRefine((value, ctx) => {
|
|
1360
|
+
unique(value.operations.map((operation) => operation.operationId), ctx, "receipt operation");
|
|
1361
|
+
if (value.operations.length && !value.recipeDigest)
|
|
1362
|
+
fail(ctx, "intervened receipt requires recipe identity");
|
|
1363
|
+
for (const operation of value.operations)
|
|
1364
|
+
if (operation.equivalence === "validated_equivalent" && !operation.validationReceiptDigest)
|
|
1365
|
+
fail(ctx, "receipt equivalent lowering lacks validation");
|
|
1366
|
+
});
|
|
1367
|
+
var NolDatasetSplitManifestSchema = z2.object({
|
|
1368
|
+
schema: z2.literal("omnius.nol.dataset.v1"),
|
|
1369
|
+
id: NolIdSchema,
|
|
1370
|
+
datasetDigest: NolSha256Schema,
|
|
1371
|
+
createdAt: timestamp,
|
|
1372
|
+
tasks: z2.array(z2.object({
|
|
1373
|
+
taskId: NolIdSchema,
|
|
1374
|
+
sourceIds: z2.array(NolIdSchema).min(1).max(1e3),
|
|
1375
|
+
templateId: NolIdSchema.optional(),
|
|
1376
|
+
nearDuplicateGroupIds: z2.array(NolIdSchema).max(1e3),
|
|
1377
|
+
familyId: NolIdSchema,
|
|
1378
|
+
leakageGroupId: NolIdSchema,
|
|
1379
|
+
clusterId: NolIdSchema,
|
|
1380
|
+
split: z2.enum(["discovery", "development", "final_test"]),
|
|
1381
|
+
prompt: NolArtifactRefSchema,
|
|
1382
|
+
expected: NolArtifactRefSchema,
|
|
1383
|
+
graderId: NolIdSchema,
|
|
1384
|
+
derivedFromTaskIds: z2.array(NolIdSchema).max(1e3)
|
|
1385
|
+
}).strict()).min(1).max(1e5)
|
|
1386
|
+
}).strict().superRefine((value, ctx) => {
|
|
1387
|
+
unique(value.tasks.map((task) => task.taskId), ctx, "task id");
|
|
1388
|
+
const tasks = new Map(value.tasks.map((task) => [task.taskId, task]));
|
|
1389
|
+
for (const field of ["clusterId", "leakageGroupId"]) {
|
|
1390
|
+
const splits = /* @__PURE__ */ new Map();
|
|
1391
|
+
for (const task of value.tasks) {
|
|
1392
|
+
if (splits.has(task[field]) && splits.get(task[field]) !== task.split)
|
|
1393
|
+
fail(ctx, `${field} leaks across protected splits`);
|
|
1394
|
+
splits.set(task[field], task.split);
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
const roots = new Map(value.tasks.map((task) => [task.taskId, task.taskId]));
|
|
1398
|
+
const root = (id2) => {
|
|
1399
|
+
let current = id2;
|
|
1400
|
+
while (roots.get(current) !== current)
|
|
1401
|
+
current = roots.get(current);
|
|
1402
|
+
let next = id2;
|
|
1403
|
+
while (roots.get(next) !== next) {
|
|
1404
|
+
const parent = roots.get(next);
|
|
1405
|
+
roots.set(next, current);
|
|
1406
|
+
next = parent;
|
|
1407
|
+
}
|
|
1408
|
+
return current;
|
|
1409
|
+
};
|
|
1410
|
+
const links = /* @__PURE__ */ new Map();
|
|
1411
|
+
for (const task of value.tasks) {
|
|
1412
|
+
unique(task.sourceIds, ctx, "task source");
|
|
1413
|
+
unique(task.nearDuplicateGroupIds, ctx, "near-duplicate group");
|
|
1414
|
+
for (const link of [
|
|
1415
|
+
...task.sourceIds.map((id2) => `source:${id2}`),
|
|
1416
|
+
...task.nearDuplicateGroupIds.map((id2) => `duplicate:${id2}`),
|
|
1417
|
+
...task.templateId ? [`template:${task.templateId}`] : [],
|
|
1418
|
+
`prompt:${task.prompt.sha256}`
|
|
1419
|
+
]) {
|
|
1420
|
+
const prior = links.get(link);
|
|
1421
|
+
if (prior)
|
|
1422
|
+
roots.set(root(task.taskId), root(prior));
|
|
1423
|
+
else
|
|
1424
|
+
links.set(link, task.taskId);
|
|
1425
|
+
}
|
|
1426
|
+
unique(task.derivedFromTaskIds, ctx, "task derivation");
|
|
1427
|
+
for (const parentId of task.derivedFromTaskIds) {
|
|
1428
|
+
const parent = tasks.get(parentId);
|
|
1429
|
+
if (!parent || parentId === task.taskId)
|
|
1430
|
+
fail(ctx, "invalid task derivation parent");
|
|
1431
|
+
else {
|
|
1432
|
+
roots.set(root(task.taskId), root(parentId));
|
|
1433
|
+
if (parent.clusterId !== task.clusterId)
|
|
1434
|
+
fail(ctx, "derived tasks must retain parent statistical cluster");
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1439
|
+
for (const task of value.tasks) {
|
|
1440
|
+
const id2 = root(task.taskId), group = groups.get(id2);
|
|
1441
|
+
if (group && (group.split !== task.split || group.leakageGroupId !== task.leakageGroupId || group.clusterId !== task.clusterId))
|
|
1442
|
+
fail(ctx, "transitive source/template/duplicate/derivation group leaks or has inconsistent leakage/statistical identity");
|
|
1443
|
+
groups.set(id2, {
|
|
1444
|
+
split: task.split,
|
|
1445
|
+
leakageGroupId: task.leakageGroupId,
|
|
1446
|
+
clusterId: task.clusterId
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
const childCounts = new Map(value.tasks.map((task) => [
|
|
1450
|
+
task.taskId,
|
|
1451
|
+
task.derivedFromTaskIds.filter((id2) => tasks.has(id2)).length
|
|
1452
|
+
]));
|
|
1453
|
+
const descendants = /* @__PURE__ */ new Map();
|
|
1454
|
+
for (const task of value.tasks)
|
|
1455
|
+
for (const parent of task.derivedFromTaskIds)
|
|
1456
|
+
descendants.set(parent, [
|
|
1457
|
+
...descendants.get(parent) ?? [],
|
|
1458
|
+
task.taskId
|
|
1459
|
+
]);
|
|
1460
|
+
const ready = value.tasks.filter((task) => childCounts.get(task.taskId) === 0).map((task) => task.taskId);
|
|
1461
|
+
for (let index = 0; index < ready.length; index++)
|
|
1462
|
+
for (const child of descendants.get(ready[index]) ?? []) {
|
|
1463
|
+
const remaining = childCounts.get(child) - 1;
|
|
1464
|
+
childCounts.set(child, remaining);
|
|
1465
|
+
if (remaining === 0)
|
|
1466
|
+
ready.push(child);
|
|
1467
|
+
}
|
|
1468
|
+
if (ready.length !== tasks.size)
|
|
1469
|
+
fail(ctx, "cyclic task derivation");
|
|
1470
|
+
});
|
|
1471
|
+
var NolBudgetSchema = z2.object({
|
|
1472
|
+
maxTrials: positive,
|
|
1473
|
+
maxTasks: positive,
|
|
1474
|
+
maxSeeds: positive,
|
|
1475
|
+
maxControls: count,
|
|
1476
|
+
maxTokens: positive,
|
|
1477
|
+
maxTokensPerTrial: positive,
|
|
1478
|
+
maxDurationMs: positive,
|
|
1479
|
+
maxTensorBytes: positive,
|
|
1480
|
+
maxArtifactBytes: positive,
|
|
1481
|
+
maxParallelWorkers: positive,
|
|
1482
|
+
maxRetries: count
|
|
1483
|
+
}).strict().superRefine((value, ctx) => {
|
|
1484
|
+
if (value.maxTokensPerTrial > value.maxTokens)
|
|
1485
|
+
fail(ctx, "per-trial token budget exceeds total budget");
|
|
1486
|
+
if (value.maxTensorBytes > value.maxArtifactBytes)
|
|
1487
|
+
fail(ctx, "tensor budget exceeds artifact budget");
|
|
1488
|
+
if (value.maxParallelWorkers > value.maxTrials)
|
|
1489
|
+
fail(ctx, "worker budget exceeds trial budget");
|
|
1490
|
+
});
|
|
1491
|
+
var NolObjectiveSchema = z2.object({
|
|
1492
|
+
primaryMetricId: NolIdSchema,
|
|
1493
|
+
minimumUsefulEffect: finite.nonnegative(),
|
|
1494
|
+
absoluteTarget: z2.object({ direction: z2.enum(["at_least", "at_most"]), value: finite }).strict().optional(),
|
|
1495
|
+
metrics: z2.array(z2.object({
|
|
1496
|
+
id: NolIdSchema,
|
|
1497
|
+
direction: z2.enum(["maximize", "minimize"]),
|
|
1498
|
+
unit: text2,
|
|
1499
|
+
grader: z2.object({ id: NolIdSchema, digest: NolSha256Schema }).strict(),
|
|
1500
|
+
weight: finite.nonnegative()
|
|
1501
|
+
}).strict()).min(1).max(1e3),
|
|
1502
|
+
guards: z2.array(z2.object({
|
|
1503
|
+
id: NolIdSchema,
|
|
1504
|
+
metricId: NolIdSchema,
|
|
1505
|
+
kind: z2.enum(["minimum", "maximum", "non_inferiority"]),
|
|
1506
|
+
threshold: finite
|
|
1507
|
+
}).strict()).max(1e3)
|
|
1508
|
+
}).strict().superRefine((value, ctx) => {
|
|
1509
|
+
unique(value.metrics.map((metric) => metric.id), ctx, "metric id");
|
|
1510
|
+
unique(value.guards.map((guard) => guard.id), ctx, "guard id");
|
|
1511
|
+
const ids = new Set(value.metrics.map((metric) => metric.id));
|
|
1512
|
+
if (!ids.has(value.primaryMetricId))
|
|
1513
|
+
fail(ctx, "unknown primary metric");
|
|
1514
|
+
for (const guard of value.guards) {
|
|
1515
|
+
if (!ids.has(guard.metricId))
|
|
1516
|
+
fail(ctx, "guard references unknown metric");
|
|
1517
|
+
if (guard.kind === "non_inferiority" && guard.threshold < 0)
|
|
1518
|
+
fail(ctx, "non-inferiority margin must be nonnegative");
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
var NolExperimentManifestSchema = z2.object({
|
|
1522
|
+
schema: z2.literal("omnius.nol.experiment.v1"),
|
|
1523
|
+
id: NolIdSchema,
|
|
1524
|
+
experimentDigest: NolSha256Schema,
|
|
1525
|
+
createdAt: timestamp,
|
|
1526
|
+
modelDigest: NolSha256Schema,
|
|
1527
|
+
baselineBinding: NolRuntimeBindingSchema,
|
|
1528
|
+
recipeDigests: z2.array(NolSha256Schema).min(1).max(1e4),
|
|
1529
|
+
datasetDigest: NolSha256Schema,
|
|
1530
|
+
harnessDigest: NolSha256Schema,
|
|
1531
|
+
objective: NolObjectiveSchema,
|
|
1532
|
+
budgets: NolBudgetSchema,
|
|
1533
|
+
seeds: z2.array(count).min(1).max(1e4),
|
|
1534
|
+
allowedOperations: z2.array(NolOperationKindSchema).min(1).max(14),
|
|
1535
|
+
searchConstraints: z2.object({
|
|
1536
|
+
allowedSiteIds: z2.array(NolIdSchema).min(1).max(1e5),
|
|
1537
|
+
maxAbsScalar: finite.gt(0),
|
|
1538
|
+
maxVectorNorm: finite.gt(0),
|
|
1539
|
+
maxOperationsPerRecipe: positive,
|
|
1540
|
+
maxCandidates: positive,
|
|
1541
|
+
maxCombinations: positive
|
|
1542
|
+
}).strict(),
|
|
1543
|
+
controls: z2.object({
|
|
1544
|
+
sham: z2.literal(true),
|
|
1545
|
+
randomSeeds: z2.array(count).min(1).max(1e4),
|
|
1546
|
+
normalization: z2.literal("norm_matched")
|
|
1547
|
+
}).strict(),
|
|
1548
|
+
decoding: z2.object({
|
|
1549
|
+
temperature: finite.nonnegative(),
|
|
1550
|
+
topP: finite.gt(0).max(1),
|
|
1551
|
+
topK: count,
|
|
1552
|
+
maxTokens: positive,
|
|
1553
|
+
constrainedDecoding: z2.enum(["none", "json", "schema"]),
|
|
1554
|
+
schemaDigest: NolSha256Schema.optional()
|
|
1555
|
+
}).strict(),
|
|
1556
|
+
statistics: z2.object({
|
|
1557
|
+
method: z2.literal("paired_cluster_bootstrap"),
|
|
1558
|
+
clusterUnit: z2.literal("source_family"),
|
|
1559
|
+
confidenceLevel: probability,
|
|
1560
|
+
bootstrapIterations: positive,
|
|
1561
|
+
bootstrapSeed: uint32,
|
|
1562
|
+
missingPairPolicy: z2.enum(["inconclusive", "fail"]),
|
|
1563
|
+
minTasks: positive,
|
|
1564
|
+
minClusters: count.min(2),
|
|
1565
|
+
decisionPoint: z2.enum(["development", "final_test"]),
|
|
1566
|
+
weighting: z2.enum(["equal_tasks", "equal_clusters"]),
|
|
1567
|
+
maxIntervalWidth: finite.gt(0).optional(),
|
|
1568
|
+
jointErrorPolicy: z2.literal("bonferroni"),
|
|
1569
|
+
multiplicity: z2.object({
|
|
1570
|
+
method: z2.enum(["none", "bonferroni"]),
|
|
1571
|
+
comparisons: positive
|
|
1572
|
+
}).strict(),
|
|
1573
|
+
analysisSchedule: z2.array(positive).min(1).max(1),
|
|
1574
|
+
pairOrder: z2.enum(["randomized", "counterbalanced"])
|
|
1575
|
+
}).strict()
|
|
1576
|
+
}).strict().superRefine((value, ctx) => {
|
|
1577
|
+
unique(value.recipeDigests, ctx, "experiment recipe");
|
|
1578
|
+
unique(value.seeds.map(String), ctx, "seed");
|
|
1579
|
+
unique(value.allowedOperations, ctx, "allowed operation");
|
|
1580
|
+
unique(value.searchConstraints.allowedSiteIds, ctx, "allowed site");
|
|
1581
|
+
unique(value.controls.randomSeeds.map(String), ctx, "random control seed");
|
|
1582
|
+
if (value.modelDigest !== value.baselineBinding.modelDigest)
|
|
1583
|
+
fail(ctx, "baseline/model binding mismatch");
|
|
1584
|
+
if (value.seeds.length > value.budgets.maxSeeds)
|
|
1585
|
+
fail(ctx, "seed count exceeds budget");
|
|
1586
|
+
if (value.controls.randomSeeds.length + 1 > value.budgets.maxControls)
|
|
1587
|
+
fail(ctx, "control arms exceed budget");
|
|
1588
|
+
if (value.recipeDigests.length > value.searchConstraints.maxCandidates)
|
|
1589
|
+
fail(ctx, "candidate count exceeds search constraint");
|
|
1590
|
+
if (value.decoding.maxTokens > value.budgets.maxTokensPerTrial || value.decoding.maxTokens > value.baselineBinding.contextLimit)
|
|
1591
|
+
fail(ctx, "decoding exceeds token/context budget");
|
|
1592
|
+
if (value.decoding.constrainedDecoding === "schema" && !value.decoding.schemaDigest)
|
|
1593
|
+
fail(ctx, "schema-constrained decoding requires schema identity");
|
|
1594
|
+
if (value.decoding.constrainedDecoding !== "schema" && value.decoding.schemaDigest)
|
|
1595
|
+
fail(ctx, "unexpected decoding schema identity");
|
|
1596
|
+
const schedule = value.statistics.analysisSchedule;
|
|
1597
|
+
for (let index = 0; index < schedule.length; index++)
|
|
1598
|
+
if (schedule[index] > value.budgets.maxTrials || index > 0 && schedule[index] <= schedule[index - 1])
|
|
1599
|
+
fail(ctx, "analysis schedule must be increasing and within trial budget");
|
|
1600
|
+
if (value.statistics.minClusters > value.statistics.minTasks || value.statistics.minTasks > value.budgets.maxTasks)
|
|
1601
|
+
fail(ctx, "precision task/cluster requirements exceed budget");
|
|
1602
|
+
if (value.statistics.multiplicity.method === "none" && value.statistics.multiplicity.comparisons !== 1)
|
|
1603
|
+
fail(ctx, "multiple candidate comparisons require multiplicity accounting");
|
|
1604
|
+
if (value.statistics.multiplicity.comparisons < value.recipeDigests.length)
|
|
1605
|
+
fail(ctx, "comparison multiplicity omits candidate variants");
|
|
1606
|
+
});
|
|
1607
|
+
var NolTrialResultSchema = z2.object({
|
|
1608
|
+
schema: z2.literal("omnius.nol.trial.v1"),
|
|
1609
|
+
id: NolIdSchema,
|
|
1610
|
+
experimentDigest: NolSha256Schema,
|
|
1611
|
+
taskId: NolIdSchema,
|
|
1612
|
+
clusterId: NolIdSchema,
|
|
1613
|
+
seed: count,
|
|
1614
|
+
variantDigest: NolSha256Schema,
|
|
1615
|
+
arm: z2.enum(["baseline", "candidate", "random", "sham"]),
|
|
1616
|
+
attempt: positive,
|
|
1617
|
+
status: z2.enum(["completed", "failed", "interrupted", "inconclusive"]),
|
|
1618
|
+
failureClass: z2.enum([
|
|
1619
|
+
"malformed_output",
|
|
1620
|
+
"schema_invalid",
|
|
1621
|
+
"semantic_failure",
|
|
1622
|
+
"tool_selection",
|
|
1623
|
+
"tool_execution",
|
|
1624
|
+
"infrastructure",
|
|
1625
|
+
"cancelled",
|
|
1626
|
+
"capacity",
|
|
1627
|
+
"identity",
|
|
1628
|
+
"unsupported"
|
|
1629
|
+
]).optional(),
|
|
1630
|
+
finishReason: text2,
|
|
1631
|
+
rawArtifacts: z2.array(NolArtifactRefSchema).max(1e4),
|
|
1632
|
+
scores: z2.array(z2.object({ metricId: NolIdSchema, value: finite }).strict()).max(1e3),
|
|
1633
|
+
timing: z2.object({
|
|
1634
|
+
startedAt: timestamp,
|
|
1635
|
+
finishedAt: timestamp,
|
|
1636
|
+
durationMs: finite.nonnegative()
|
|
1637
|
+
}).strict(),
|
|
1638
|
+
usage: z2.object({ promptTokens: count, completionTokens: count }).strict(),
|
|
1639
|
+
hardware: z2.object({
|
|
1640
|
+
gpuUuids: z2.array(z2.string().regex(/^GPU-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i)).max(128),
|
|
1641
|
+
driver: text2,
|
|
1642
|
+
placementProof: NolArtifactRefSchema
|
|
1643
|
+
}).strict().optional(),
|
|
1644
|
+
implementationReceipt: NolImplementationReceiptSchema.optional(),
|
|
1645
|
+
/** Observational performance; independent of scientific acceptance. */
|
|
1646
|
+
performance: NolArtifactRefSchema.optional()
|
|
1647
|
+
}).strict().superRefine((value, ctx) => {
|
|
1648
|
+
unique(value.scores.map((score) => score.metricId), ctx, "trial score");
|
|
1649
|
+
if (value.performance && !value.rawArtifacts.some((ref) => ref.uri === value.performance.uri && ref.sha256 === value.performance.sha256 && ref.sizeBytes === value.performance.sizeBytes && ref.mediaType === value.performance.mediaType))
|
|
1650
|
+
fail(ctx, "performance artifact must be retained among raw artifacts");
|
|
1651
|
+
if (Date.parse(value.timing.finishedAt) < Date.parse(value.timing.startedAt))
|
|
1652
|
+
fail(ctx, "trial finished before it started");
|
|
1653
|
+
if (value.status === "completed" && (!value.implementationReceipt || value.implementationReceipt.reset.status !== "verified"))
|
|
1654
|
+
fail(ctx, "completed trial requires a verified-reset implementation receipt");
|
|
1655
|
+
if (value.status === "completed" && value.failureClass)
|
|
1656
|
+
fail(ctx, "completed trial cannot have a failure class");
|
|
1657
|
+
if (value.status !== "completed" && !value.failureClass)
|
|
1658
|
+
fail(ctx, "unsuccessful trial requires a failure class");
|
|
1659
|
+
if (value.arm === "baseline" && value.implementationReceipt && (value.implementationReceipt.operations.length || value.implementationReceipt.activeAdapters.length))
|
|
1660
|
+
fail(ctx, "baseline cannot retain intervention operations/adapters");
|
|
1661
|
+
});
|
|
1662
|
+
var verdict = z2.enum(["passed", "failed", "inconclusive"]);
|
|
1663
|
+
var interval = z2.object({ lower: finite, upper: finite, level: probability }).strict().superRefine((value, ctx) => {
|
|
1664
|
+
if (value.lower > value.upper)
|
|
1665
|
+
fail(ctx, "confidence interval bounds are reversed");
|
|
1666
|
+
});
|
|
1667
|
+
var NolComparisonReportSchema = z2.object({
|
|
1668
|
+
schema: z2.literal("omnius.nol.comparison.v1"),
|
|
1669
|
+
id: NolIdSchema,
|
|
1670
|
+
comparisonDigest: NolSha256Schema,
|
|
1671
|
+
experimentDigest: NolSha256Schema,
|
|
1672
|
+
baselineVariantDigest: NolSha256Schema,
|
|
1673
|
+
candidateVariantDigest: NolSha256Schema,
|
|
1674
|
+
counts: z2.object({
|
|
1675
|
+
pairs: count,
|
|
1676
|
+
tasks: count,
|
|
1677
|
+
clusters: count,
|
|
1678
|
+
repetitions: count,
|
|
1679
|
+
invalidPairs: count
|
|
1680
|
+
}).strict(),
|
|
1681
|
+
metricEffects: z2.array(z2.object({
|
|
1682
|
+
metricId: NolIdSchema,
|
|
1683
|
+
baselineMean: finite,
|
|
1684
|
+
candidateMean: finite,
|
|
1685
|
+
effect: finite,
|
|
1686
|
+
interval
|
|
1687
|
+
}).strict()).max(1e3),
|
|
1688
|
+
guardResults: z2.array(z2.object({
|
|
1689
|
+
guardId: NolIdSchema,
|
|
1690
|
+
verdict,
|
|
1691
|
+
evidence: NolArtifactRefSchema
|
|
1692
|
+
}).strict()).max(1e3),
|
|
1693
|
+
tails: z2.array(z2.object({
|
|
1694
|
+
metricId: NolIdSchema,
|
|
1695
|
+
quantile: finite.min(0).max(1),
|
|
1696
|
+
baseline: finite,
|
|
1697
|
+
candidate: finite
|
|
1698
|
+
}).strict()).max(1e3),
|
|
1699
|
+
frontierVariantDigests: z2.array(NolSha256Schema).max(1e4),
|
|
1700
|
+
rawResults: NolArtifactRefSchema,
|
|
1701
|
+
verdict,
|
|
1702
|
+
recordedAt: timestamp
|
|
1703
|
+
}).strict().superRefine((value, ctx) => {
|
|
1704
|
+
unique(value.metricEffects.map((metric) => metric.metricId), ctx, "comparison metric");
|
|
1705
|
+
unique(value.guardResults.map((guard) => guard.guardId), ctx, "comparison guard");
|
|
1706
|
+
unique(value.frontierVariantDigests, ctx, "frontier variant");
|
|
1707
|
+
if (value.counts.clusters > value.counts.tasks || value.counts.tasks > value.counts.pairs)
|
|
1708
|
+
fail(ctx, "comparison counts are inconsistent");
|
|
1709
|
+
if (value.verdict === "passed" && (!value.counts.pairs || !value.counts.tasks || !value.counts.clusters || !value.metricEffects.length || value.guardResults.some((guard) => guard.verdict !== "passed")))
|
|
1710
|
+
fail(ctx, "passed comparison requires evidence and every guard passed");
|
|
1711
|
+
});
|
|
1712
|
+
var NolValidationReceiptSchema = z2.object({
|
|
1713
|
+
schema: z2.literal("omnius.nol.validation.v1"),
|
|
1714
|
+
id: NolIdSchema,
|
|
1715
|
+
validationDigest: NolSha256Schema,
|
|
1716
|
+
experimentDigest: NolSha256Schema,
|
|
1717
|
+
variantDigest: NolSha256Schema,
|
|
1718
|
+
comparisonDigest: NolSha256Schema,
|
|
1719
|
+
finalTestDatasetDigest: NolSha256Schema,
|
|
1720
|
+
binding: NolRuntimeBindingSchema,
|
|
1721
|
+
capabilitiesDigest: NolSha256Schema,
|
|
1722
|
+
gateResults: z2.array(z2.object({
|
|
1723
|
+
id: NolIdSchema,
|
|
1724
|
+
verdict,
|
|
1725
|
+
evidence: z2.array(NolArtifactRefSchema).min(1).max(1e3)
|
|
1726
|
+
}).strict()).min(1).max(1e3),
|
|
1727
|
+
verdict,
|
|
1728
|
+
limitations: z2.array(text2).max(1e3),
|
|
1729
|
+
recordedAt: timestamp
|
|
1730
|
+
}).strict().superRefine((value, ctx) => {
|
|
1731
|
+
unique(value.gateResults.map((gate) => gate.id), ctx, "validation gate");
|
|
1732
|
+
if (value.verdict === "passed" && value.gateResults.some((gate) => gate.verdict !== "passed"))
|
|
1733
|
+
fail(ctx, "validation cannot pass an unresolved gate");
|
|
1734
|
+
});
|
|
1735
|
+
var NolPromotionRecordSchema = z2.object({
|
|
1736
|
+
schema: z2.literal("omnius.nol.promotion.v1"),
|
|
1737
|
+
id: NolIdSchema,
|
|
1738
|
+
promotionDigest: NolSha256Schema,
|
|
1739
|
+
candidateVariantDigest: NolSha256Schema,
|
|
1740
|
+
validationDigest: NolSha256Schema,
|
|
1741
|
+
level: z2.enum(["retain_recipe", "export", "register", "activate"]),
|
|
1742
|
+
targetBindingId: NolIdSchema,
|
|
1743
|
+
previousVariantDigest: NolSha256Schema,
|
|
1744
|
+
transactionId: NolIdSchema,
|
|
1745
|
+
authorization: z2.object({
|
|
1746
|
+
id: NolIdSchema,
|
|
1747
|
+
actor: text2,
|
|
1748
|
+
scope: z2.enum(["retain_recipe", "export", "register", "activate"]),
|
|
1749
|
+
variantDigest: NolSha256Schema,
|
|
1750
|
+
validationDigest: NolSha256Schema,
|
|
1751
|
+
authorizedAt: timestamp,
|
|
1752
|
+
expiresAt: timestamp
|
|
1753
|
+
}).strict(),
|
|
1754
|
+
status: z2.enum([
|
|
1755
|
+
"authorized",
|
|
1756
|
+
"activating",
|
|
1757
|
+
"active",
|
|
1758
|
+
"rolled_back",
|
|
1759
|
+
"failed"
|
|
1760
|
+
]),
|
|
1761
|
+
rollback: z2.object({
|
|
1762
|
+
parentVariantDigest: NolSha256Schema,
|
|
1763
|
+
verified: z2.boolean(),
|
|
1764
|
+
proof: NolArtifactRefSchema.optional()
|
|
1765
|
+
}).strict(),
|
|
1766
|
+
createdAt: timestamp,
|
|
1767
|
+
updatedAt: timestamp
|
|
1768
|
+
}).strict().superRefine((value, ctx) => {
|
|
1769
|
+
if (value.authorization.scope !== value.level || value.authorization.variantDigest !== value.candidateVariantDigest || value.authorization.validationDigest !== value.validationDigest)
|
|
1770
|
+
fail(ctx, "promotion authorization binding mismatch");
|
|
1771
|
+
if (Date.parse(value.authorization.expiresAt) <= Date.parse(value.authorization.authorizedAt))
|
|
1772
|
+
fail(ctx, "invalid authorization lifetime");
|
|
1773
|
+
if (value.rollback.parentVariantDigest !== value.previousVariantDigest)
|
|
1774
|
+
fail(ctx, "rollback parent mismatch");
|
|
1775
|
+
if (value.rollback.verified && !value.rollback.proof)
|
|
1776
|
+
fail(ctx, "verified rollback requires proof");
|
|
1777
|
+
if (value.status === "rolled_back" && !value.rollback.verified)
|
|
1778
|
+
fail(ctx, "rolled-back promotion requires verified rollback");
|
|
1779
|
+
if (Date.parse(value.updatedAt) < Date.parse(value.createdAt))
|
|
1780
|
+
fail(ctx, "promotion timestamps are reversed");
|
|
1781
|
+
});
|
|
1782
|
+
var NolRecordSchema = z2.union([
|
|
1783
|
+
NolModelManifestSchema,
|
|
1784
|
+
NolRuntimeBindingSchema,
|
|
1785
|
+
NolCalibrationSchema,
|
|
1786
|
+
NolRecipeRevisionSchema,
|
|
1787
|
+
NolVariantManifestSchema,
|
|
1788
|
+
NolBackendCapabilitiesSchema,
|
|
1789
|
+
NolImplementationReceiptSchema,
|
|
1790
|
+
NolDatasetSplitManifestSchema,
|
|
1791
|
+
NolExperimentManifestSchema,
|
|
1792
|
+
NolTrialResultSchema,
|
|
1793
|
+
NolComparisonReportSchema,
|
|
1794
|
+
NolValidationReceiptSchema,
|
|
1795
|
+
NolPromotionRecordSchema
|
|
1796
|
+
]);
|
|
1797
|
+
function isWeightOperation(operation) {
|
|
1798
|
+
return operation.startsWith("WEIGHT_") || operation === "LOW_RANK_UPDATE";
|
|
1799
|
+
}
|
|
865
1800
|
|
|
866
|
-
// packages/schemas/dist/
|
|
1801
|
+
// packages/schemas/dist/nol-assets.js
|
|
867
1802
|
import { z as z3 } from "zod";
|
|
868
|
-
var
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
1803
|
+
var positive2 = z3.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
1804
|
+
var finite2 = z3.number().finite();
|
|
1805
|
+
var jobId = z3.string().regex(/^[A-Za-z0-9_][A-Za-z0-9_.-]{0,99}$/);
|
|
1806
|
+
var parents = z3.array(z3.object({ model: NolArtifactRefSchema, modelDigest: NolSha256Schema }).strict()).max(128);
|
|
1807
|
+
var NolCheckpointExportLimitsSchema = z3.object({
|
|
1808
|
+
maxInputBytes: positive2,
|
|
1809
|
+
maxArtifactBytes: positive2,
|
|
1810
|
+
maxOutputBytes: positive2,
|
|
1811
|
+
maxWorkingBytes: positive2,
|
|
1812
|
+
maxArithmeticUnits: positive2,
|
|
1813
|
+
maxOperations: positive2,
|
|
1814
|
+
maxDurationMs: positive2.max(864e5),
|
|
1815
|
+
maxProtocolBytes: positive2.max(16 * 1024 ** 2)
|
|
1816
|
+
}).strict();
|
|
1817
|
+
var NolGgufExportLimitsSchema = NolCheckpointExportLimitsSchema.extend({
|
|
1818
|
+
maxMetadataBytes: positive2,
|
|
1819
|
+
maxTensors: positive2,
|
|
1820
|
+
maxKeyValues: positive2,
|
|
1821
|
+
maxArrayElements: positive2
|
|
1822
|
+
}).strict();
|
|
1823
|
+
var NolLoraExportLimitsSchema = NolCheckpointExportLimitsSchema.extend({ maxRank: positive2, maxModules: positive2 }).strict();
|
|
1824
|
+
var exportCommon = {
|
|
1825
|
+
schema: z3.literal("omnius.nol.export-plan.v1"),
|
|
1826
|
+
id: jobId,
|
|
1827
|
+
planDigest: NolSha256Schema,
|
|
1828
|
+
projectId: NolSha256Schema,
|
|
1829
|
+
executionProfileId: NolIdSchema,
|
|
1830
|
+
model: NolArtifactRefSchema,
|
|
1831
|
+
modelDigest: NolSha256Schema,
|
|
1832
|
+
recipe: NolArtifactRefSchema,
|
|
1833
|
+
recipeDigest: NolSha256Schema,
|
|
1834
|
+
parents
|
|
1835
|
+
};
|
|
1836
|
+
var NolExportPlanSchema = z3.discriminatedUnion("exporter", [
|
|
1837
|
+
z3.object({
|
|
1838
|
+
...exportCommon,
|
|
1839
|
+
exporter: z3.literal("checkpoint"),
|
|
1840
|
+
limits: NolCheckpointExportLimitsSchema,
|
|
1841
|
+
orthogonalityTolerance: finite2.gt(0).max(0.01)
|
|
1842
|
+
}).strict(),
|
|
1843
|
+
z3.object({
|
|
1844
|
+
...exportCommon,
|
|
1845
|
+
exporter: z3.literal("gguf"),
|
|
1846
|
+
limits: NolGgufExportLimitsSchema,
|
|
1847
|
+
orthogonalityTolerance: finite2.gt(0).max(0.01),
|
|
1848
|
+
encoding: z3.object({
|
|
1849
|
+
target: z3.enum(["f16", "q8_0"]),
|
|
1850
|
+
maxAbsError: finite2.nonnegative(),
|
|
1851
|
+
maxRelativeL2Error: finite2.nonnegative()
|
|
1852
|
+
}).strict()
|
|
1853
|
+
}).strict(),
|
|
1854
|
+
z3.object({
|
|
1855
|
+
...exportCommon,
|
|
1856
|
+
exporter: z3.literal("lora"),
|
|
1857
|
+
limits: NolLoraExportLimitsSchema,
|
|
1858
|
+
binding: NolRuntimeBindingSchema,
|
|
1859
|
+
moduleBindings: z3.array(z3.object({
|
|
1860
|
+
siteId: NolIdSchema,
|
|
1861
|
+
modulePath: z3.string().min(1).max(512),
|
|
1862
|
+
moduleType: z3.literal("torch.nn.Linear"),
|
|
1863
|
+
layout: z3.literal("out_in")
|
|
1864
|
+
}).strict()).min(1).max(1e4),
|
|
1865
|
+
baseModel: z3.object({
|
|
1866
|
+
nameOrPath: z3.string().min(1).max(400),
|
|
1867
|
+
revision: z3.string().regex(/^[a-f0-9]{40,64}$/),
|
|
1868
|
+
taskType: z3.enum([
|
|
1869
|
+
"CAUSAL_LM",
|
|
1870
|
+
"SEQ_2_SEQ_LM",
|
|
1871
|
+
"FEATURE_EXTRACTION",
|
|
1872
|
+
"SEQ_CLS",
|
|
1873
|
+
"TOKEN_CLS",
|
|
1874
|
+
"QUESTION_ANS"
|
|
1875
|
+
])
|
|
1876
|
+
}).strict()
|
|
1877
|
+
}).strict()
|
|
1878
|
+
]).superRefine((value, ctx) => {
|
|
1879
|
+
if (new Set(value.parents.map((p) => p.modelDigest)).size !== value.parents.length)
|
|
1880
|
+
ctx.addIssue({
|
|
1881
|
+
code: "custom",
|
|
1882
|
+
message: "duplicate export parent model"
|
|
1883
|
+
});
|
|
1884
|
+
});
|
|
1885
|
+
var NolModelSubjectSchema = z3.object({
|
|
1886
|
+
id: NolIdSchema,
|
|
1887
|
+
artifactKind: z3.enum(["checkpoint", "adapter"]),
|
|
1888
|
+
model: NolArtifactRefSchema,
|
|
1889
|
+
modelDigest: NolSha256Schema,
|
|
1890
|
+
runtimeModel: NolArtifactRefSchema,
|
|
1891
|
+
runtimeModelDigest: NolSha256Schema,
|
|
1892
|
+
binding: NolRuntimeBindingSchema,
|
|
1893
|
+
executionProfileId: NolIdSchema,
|
|
1894
|
+
parents,
|
|
1895
|
+
recipe: z3.null(),
|
|
1896
|
+
exportReceipt: NolArtifactRefSchema.optional(),
|
|
1897
|
+
adapter: z3.object({
|
|
1898
|
+
baseModel: NolArtifactRefSchema,
|
|
1899
|
+
baseModelDigest: NolSha256Schema,
|
|
1900
|
+
artifacts: z3.array(NolArtifactRefSchema).min(1).max(1e3),
|
|
1901
|
+
scale: finite2,
|
|
1902
|
+
nativeBaseBinding: NolRuntimeBindingSchema,
|
|
1903
|
+
conformance: NolArtifactRefSchema
|
|
1904
|
+
}).strict().optional()
|
|
1905
|
+
}).strict().superRefine((value, ctx) => {
|
|
1906
|
+
if (value.runtimeModelDigest !== value.binding.modelDigest)
|
|
1907
|
+
ctx.addIssue({
|
|
1908
|
+
code: "custom",
|
|
1909
|
+
message: "subject runtime model/binding mismatch"
|
|
1910
|
+
});
|
|
1911
|
+
if (value.artifactKind === "adapter" !== (value.adapter !== void 0))
|
|
1912
|
+
ctx.addIssue({
|
|
1913
|
+
code: "custom",
|
|
1914
|
+
message: "adapter subject needs exact base/artifact/scale binding"
|
|
1915
|
+
});
|
|
1916
|
+
if (new Set(value.parents.map((p) => p.modelDigest)).size !== value.parents.length)
|
|
1917
|
+
ctx.addIssue({ code: "custom", message: "duplicate subject parent" });
|
|
1918
|
+
});
|
|
1919
|
+
var NolModelControlSubjectSchema = z3.object({
|
|
1920
|
+
kind: z3.enum(["sham", "random"]),
|
|
1921
|
+
seed: z3.number().int().min(0).max(4294967295).optional(),
|
|
1922
|
+
subject: NolModelSubjectSchema,
|
|
1923
|
+
proof: NolArtifactRefSchema
|
|
1924
|
+
}).strict().superRefine((value, ctx) => {
|
|
1925
|
+
if (value.kind === "random" !== (value.seed !== void 0))
|
|
1926
|
+
ctx.addIssue({
|
|
1927
|
+
code: "custom",
|
|
1928
|
+
message: "only random controls require an explicit seed"
|
|
1929
|
+
});
|
|
1930
|
+
});
|
|
1931
|
+
var NolModelValidationPlanSchema = z3.object({
|
|
1932
|
+
schema: z3.literal("omnius.nol.model-validation.v1"),
|
|
1933
|
+
id: jobId,
|
|
1934
|
+
planDigest: NolSha256Schema,
|
|
1935
|
+
projectId: NolSha256Schema,
|
|
1936
|
+
baseline: NolModelSubjectSchema,
|
|
1937
|
+
candidate: NolModelSubjectSchema,
|
|
1938
|
+
controls: z3.array(NolModelControlSubjectSchema).min(2).max(1e3),
|
|
1939
|
+
dataset: NolArtifactRefSchema,
|
|
1940
|
+
datasetDigest: NolSha256Schema,
|
|
1941
|
+
harnessDigest: NolSha256Schema,
|
|
1942
|
+
seeds: z3.array(z3.number().int().min(0).max(4294967295)).min(1).max(1e4),
|
|
1943
|
+
objective: NolObjectiveSchema,
|
|
1944
|
+
budgets: NolBudgetSchema,
|
|
1945
|
+
// Reuse the actual frozen statistical/decoding fields, not an invented v1 experiment.
|
|
1946
|
+
statistics: NolExperimentManifestSchema.shape.statistics,
|
|
1947
|
+
decoding: NolExperimentManifestSchema.shape.decoding
|
|
1948
|
+
}).strict().superRefine((value, ctx) => {
|
|
1949
|
+
const fail2 = (message) => ctx.addIssue({ code: "custom", message });
|
|
1950
|
+
if (new Set(value.seeds).size !== value.seeds.length)
|
|
1951
|
+
fail2("duplicate model-validation seed");
|
|
1952
|
+
if (value.seeds.length > value.budgets.maxSeeds)
|
|
1953
|
+
fail2("seed budget exceeded");
|
|
1954
|
+
if (value.controls.filter((c) => c.kind === "sham").length !== 1 || !value.controls.some((c) => c.kind === "random"))
|
|
1955
|
+
fail2("one sham and at least one random asset control required");
|
|
1956
|
+
const controlIds = value.controls.map((c) => `${c.kind}:${c.seed ?? "sham"}`);
|
|
1957
|
+
if (new Set(controlIds).size !== controlIds.length)
|
|
1958
|
+
fail2("duplicate control identity");
|
|
1959
|
+
if (value.controls.length > value.budgets.maxControls)
|
|
1960
|
+
fail2("control budget exceeded");
|
|
1961
|
+
if (value.decoding.maxTokens > value.budgets.maxTokensPerTrial)
|
|
1962
|
+
fail2("decode exceeds per-trial token budget");
|
|
1963
|
+
const all = [
|
|
1964
|
+
value.baseline,
|
|
1965
|
+
value.candidate,
|
|
1966
|
+
...value.controls.map((c) => c.subject)
|
|
1967
|
+
];
|
|
1968
|
+
if (new Set(all.map((s) => s.id)).size !== all.length)
|
|
1969
|
+
fail2("duplicate frozen subject ID");
|
|
1970
|
+
for (const subject of all) {
|
|
1971
|
+
if (subject.binding.backend !== value.baseline.binding.backend || subject.binding.runtimeBuildDigest !== value.baseline.binding.runtimeBuildDigest || subject.binding.dependencyLockDigest !== value.baseline.binding.dependencyLockDigest)
|
|
1972
|
+
fail2("model arms must use the same actual runtime/backend");
|
|
1973
|
+
if (subject.binding.tokenizerDigest !== value.baseline.binding.tokenizerDigest || subject.binding.chatTemplateDigest !== value.baseline.binding.chatTemplateDigest || subject.binding.contextLimit !== value.baseline.binding.contextLimit)
|
|
1974
|
+
fail2("paired model arms require matched tokenizer/template/context");
|
|
1975
|
+
if (value.decoding.maxTokens > subject.binding.contextLimit)
|
|
1976
|
+
fail2("decode exceeds subject context budget");
|
|
1977
|
+
}
|
|
1978
|
+
});
|
|
1979
|
+
var NolModelValidationReceiptSchema = z3.object({
|
|
1980
|
+
schema: z3.literal("omnius.nol.model-validation-receipt.v1"),
|
|
1981
|
+
id: NolIdSchema,
|
|
1982
|
+
validationDigest: NolSha256Schema,
|
|
1983
|
+
planDigest: NolSha256Schema,
|
|
1984
|
+
subjectDigest: NolSha256Schema,
|
|
1985
|
+
runtimeModel: NolArtifactRefSchema,
|
|
1986
|
+
binding: NolRuntimeBindingSchema,
|
|
1987
|
+
finalTestDatasetDigest: NolSha256Schema,
|
|
1988
|
+
comparison: NolArtifactRefSchema,
|
|
1989
|
+
comparisonDigest: NolSha256Schema,
|
|
1990
|
+
gateResults: z3.array(z3.object({
|
|
1991
|
+
id: NolIdSchema,
|
|
1992
|
+
verdict: z3.enum(["passed", "failed", "inconclusive"]),
|
|
1993
|
+
evidence: z3.array(NolArtifactRefSchema).min(1).max(1e3)
|
|
1994
|
+
}).strict()).min(1).max(1e3),
|
|
1995
|
+
verdict: z3.enum(["passed", "failed", "inconclusive"]),
|
|
1996
|
+
limitations: z3.array(z3.string().min(1).max(4096)).max(1e3),
|
|
1997
|
+
recordedAt: z3.string().datetime()
|
|
1998
|
+
}).strict().superRefine((value, ctx) => {
|
|
1999
|
+
if (new Set(value.gateResults.map((g) => g.id)).size !== value.gateResults.length)
|
|
2000
|
+
ctx.addIssue({
|
|
2001
|
+
code: "custom",
|
|
2002
|
+
message: "duplicate model-validation gate"
|
|
2003
|
+
});
|
|
2004
|
+
if (value.verdict === "passed" && value.gateResults.some((g) => g.verdict !== "passed"))
|
|
2005
|
+
ctx.addIssue({
|
|
2006
|
+
code: "custom",
|
|
2007
|
+
message: "unresolved gate cannot authorize model validation"
|
|
2008
|
+
});
|
|
876
2009
|
});
|
|
2010
|
+
var NolModelEvaluationBundleSchema = z3.object({
|
|
2011
|
+
schema: z3.literal("omnius.nol.model-evaluation.v1"),
|
|
2012
|
+
evaluationSubjectDigest: NolSha256Schema,
|
|
2013
|
+
plan: NolArtifactRefSchema,
|
|
2014
|
+
dataset: NolArtifactRefSchema,
|
|
2015
|
+
comparison: NolArtifactRefSchema,
|
|
2016
|
+
validation: NolArtifactRefSchema,
|
|
2017
|
+
evidence: z3.array(NolArtifactRefSchema).min(1).max(1e4)
|
|
2018
|
+
}).strict();
|
|
877
2019
|
|
|
878
|
-
// packages/schemas/dist/
|
|
2020
|
+
// packages/schemas/dist/messages.js
|
|
879
2021
|
import { z as z4 } from "zod";
|
|
880
|
-
var
|
|
2022
|
+
var AgentMessageSchema = z4.object({
|
|
881
2023
|
id: z4.string().uuid(),
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
config: z4.record(z4.string(), z4.unknown()).optional()
|
|
2024
|
+
sessionId: z4.string().uuid(),
|
|
2025
|
+
role: z4.enum(["user", "assistant", "system", "tool"]),
|
|
2026
|
+
content: z4.string(),
|
|
2027
|
+
timestamp: z4.string().datetime(),
|
|
2028
|
+
metadata: z4.record(z4.string(), z4.unknown()).optional()
|
|
888
2029
|
});
|
|
889
2030
|
|
|
890
|
-
// packages/schemas/dist/
|
|
2031
|
+
// packages/schemas/dist/tools.js
|
|
891
2032
|
import { z as z5 } from "zod";
|
|
892
|
-
var
|
|
2033
|
+
var ToolCallSchema = z5.object({
|
|
2034
|
+
id: z5.string().uuid(),
|
|
2035
|
+
name: z5.string(),
|
|
2036
|
+
arguments: z5.record(z5.string(), z5.unknown()),
|
|
2037
|
+
result: z5.unknown().optional(),
|
|
2038
|
+
status: z5.enum(["pending", "running", "completed", "failed"]),
|
|
2039
|
+
startedAt: z5.string().datetime().optional(),
|
|
2040
|
+
completedAt: z5.string().datetime().optional()
|
|
2041
|
+
});
|
|
2042
|
+
|
|
2043
|
+
// packages/schemas/dist/session.js
|
|
2044
|
+
import { z as z6 } from "zod";
|
|
2045
|
+
var SessionSchema = z6.object({
|
|
2046
|
+
id: z6.string().uuid(),
|
|
2047
|
+
projectRoot: z6.string(),
|
|
2048
|
+
model: z6.string(),
|
|
2049
|
+
createdAt: z6.string().datetime(),
|
|
2050
|
+
updatedAt: z6.string().datetime(),
|
|
2051
|
+
status: z6.enum(["active", "paused", "completed", "error"]),
|
|
2052
|
+
config: z6.record(z6.string(), z6.unknown()).optional()
|
|
2053
|
+
});
|
|
2054
|
+
|
|
2055
|
+
// packages/schemas/dist/task.js
|
|
2056
|
+
import { z as z7 } from "zod";
|
|
2057
|
+
var TaskClassSchema = z7.enum([
|
|
893
2058
|
"bugfix",
|
|
894
2059
|
"feature",
|
|
895
2060
|
"refactor",
|
|
@@ -899,26 +2064,26 @@ var TaskClassSchema = z5.enum([
|
|
|
899
2064
|
"docs",
|
|
900
2065
|
"infra"
|
|
901
2066
|
]);
|
|
902
|
-
var UrgencySchema =
|
|
903
|
-
var NormalizedTaskSchema =
|
|
2067
|
+
var UrgencySchema = z7.enum(["low", "medium", "high", "critical"]);
|
|
2068
|
+
var NormalizedTaskSchema = z7.object({
|
|
904
2069
|
/** Stable unique identifier for this task instance */
|
|
905
|
-
id:
|
|
2070
|
+
id: z7.string(),
|
|
906
2071
|
/** Human-readable goal description */
|
|
907
|
-
goal:
|
|
2072
|
+
goal: z7.string().min(1),
|
|
908
2073
|
/** Constraints the solution must satisfy */
|
|
909
|
-
constraints:
|
|
2074
|
+
constraints: z7.array(z7.string()),
|
|
910
2075
|
/** Criteria that must pass for the task to be considered done */
|
|
911
|
-
successCriteria:
|
|
2076
|
+
successCriteria: z7.array(z7.string()),
|
|
912
2077
|
/** Absolute path to the repo root */
|
|
913
|
-
repoRoot:
|
|
2078
|
+
repoRoot: z7.string(),
|
|
914
2079
|
urgency: UrgencySchema,
|
|
915
2080
|
taskClass: TaskClassSchema,
|
|
916
2081
|
/** Original raw user request before normalization */
|
|
917
|
-
rawRequest:
|
|
2082
|
+
rawRequest: z7.string().optional(),
|
|
918
2083
|
/** Timestamp when the task was created (ISO-8601) */
|
|
919
|
-
createdAt:
|
|
2084
|
+
createdAt: z7.string().datetime()
|
|
920
2085
|
});
|
|
921
|
-
var TaskStatusSchema =
|
|
2086
|
+
var TaskStatusSchema = z7.enum([
|
|
922
2087
|
"pending",
|
|
923
2088
|
"dispatched",
|
|
924
2089
|
"in_progress",
|
|
@@ -931,8 +2096,8 @@ var TaskStatusSchema = z5.enum([
|
|
|
931
2096
|
]);
|
|
932
2097
|
|
|
933
2098
|
// packages/schemas/dist/plan.js
|
|
934
|
-
import { z as
|
|
935
|
-
var SubtaskKindSchema =
|
|
2099
|
+
import { z as z8 } from "zod";
|
|
2100
|
+
var SubtaskKindSchema = z8.enum([
|
|
936
2101
|
"inspect",
|
|
937
2102
|
"patch",
|
|
938
2103
|
"test",
|
|
@@ -940,58 +2105,58 @@ var SubtaskKindSchema = z6.enum([
|
|
|
940
2105
|
"verify",
|
|
941
2106
|
"merge"
|
|
942
2107
|
]);
|
|
943
|
-
var SubtaskSchema =
|
|
2108
|
+
var SubtaskSchema = z8.object({
|
|
944
2109
|
/** Stable identifier used for dependency references */
|
|
945
|
-
id:
|
|
2110
|
+
id: z8.string().min(1),
|
|
946
2111
|
kind: SubtaskKindSchema,
|
|
947
2112
|
/** File paths or symbol names that this subtask targets */
|
|
948
|
-
targets:
|
|
2113
|
+
targets: z8.array(z8.string()),
|
|
949
2114
|
/** IDs of subtasks that must complete before this one starts */
|
|
950
|
-
dependsOn:
|
|
2115
|
+
dependsOn: z8.array(z8.string()).optional(),
|
|
951
2116
|
/** Why this subtask is necessary */
|
|
952
|
-
reason:
|
|
2117
|
+
reason: z8.string().min(1),
|
|
953
2118
|
/** Shell commands or assertions that confirm success */
|
|
954
|
-
validation:
|
|
2119
|
+
validation: z8.array(z8.string())
|
|
955
2120
|
});
|
|
956
|
-
var PlanSchema =
|
|
957
|
-
goal:
|
|
958
|
-
subtasks:
|
|
2121
|
+
var PlanSchema = z8.object({
|
|
2122
|
+
goal: z8.string().min(1),
|
|
2123
|
+
subtasks: z8.array(SubtaskSchema),
|
|
959
2124
|
/** Files/modules at elevated risk of breakage */
|
|
960
|
-
riskAreas:
|
|
2125
|
+
riskAreas: z8.array(z8.string()),
|
|
961
2126
|
/** Aspects of the codebase that are unclear or ambiguous */
|
|
962
|
-
unknowns:
|
|
2127
|
+
unknowns: z8.array(z8.string())
|
|
963
2128
|
});
|
|
964
2129
|
|
|
965
2130
|
// packages/schemas/dist/patch.js
|
|
966
|
-
import { z as
|
|
967
|
-
var EditOperationSchema =
|
|
2131
|
+
import { z as z9 } from "zod";
|
|
2132
|
+
var EditOperationSchema = z9.enum([
|
|
968
2133
|
"diff",
|
|
969
2134
|
"rewrite",
|
|
970
2135
|
"append",
|
|
971
2136
|
"create"
|
|
972
2137
|
]);
|
|
973
|
-
var FileEditSchema =
|
|
2138
|
+
var FileEditSchema = z9.object({
|
|
974
2139
|
/** Repo-relative or absolute path to the file being edited */
|
|
975
|
-
file:
|
|
2140
|
+
file: z9.string().min(1),
|
|
976
2141
|
operation: EditOperationSchema,
|
|
977
2142
|
/** Unified diff, full file content, appended text, or new file content */
|
|
978
|
-
content:
|
|
2143
|
+
content: z9.string()
|
|
979
2144
|
});
|
|
980
|
-
var NeedsMoreContextSchema =
|
|
981
|
-
reason:
|
|
982
|
-
requestedPaths:
|
|
983
|
-
requestedSymbols:
|
|
2145
|
+
var NeedsMoreContextSchema = z9.object({
|
|
2146
|
+
reason: z9.string().min(1),
|
|
2147
|
+
requestedPaths: z9.array(z9.string()).optional(),
|
|
2148
|
+
requestedSymbols: z9.array(z9.string()).optional()
|
|
984
2149
|
});
|
|
985
|
-
var PatchProposalSchema =
|
|
2150
|
+
var PatchProposalSchema = z9.object({
|
|
986
2151
|
/** One-paragraph description of what changed and why */
|
|
987
|
-
summary:
|
|
988
|
-
edits:
|
|
2152
|
+
summary: z9.string().min(1),
|
|
2153
|
+
edits: z9.array(FileEditSchema),
|
|
989
2154
|
/** Test commands or test file paths that should be executed to validate */
|
|
990
|
-
testsToRun:
|
|
2155
|
+
testsToRun: z9.array(z9.string()),
|
|
991
2156
|
/** Assumptions the editor made that the verifier should check */
|
|
992
|
-
assumptions:
|
|
2157
|
+
assumptions: z9.array(z9.string()),
|
|
993
2158
|
/** Known risks introduced by this patch */
|
|
994
|
-
risks:
|
|
2159
|
+
risks: z9.array(z9.string()),
|
|
995
2160
|
/**
|
|
996
2161
|
* When the editor cannot safely produce a patch without more information.
|
|
997
2162
|
* The presence of this field indicates the patch is incomplete.
|
|
@@ -1000,31 +2165,31 @@ var PatchProposalSchema = z7.object({
|
|
|
1000
2165
|
});
|
|
1001
2166
|
|
|
1002
2167
|
// packages/schemas/dist/verification.js
|
|
1003
|
-
import { z as
|
|
1004
|
-
var VerificationStatusSchema =
|
|
1005
|
-
var VerificationNextActionSchema =
|
|
2168
|
+
import { z as z10 } from "zod";
|
|
2169
|
+
var VerificationStatusSchema = z10.enum(["pass", "fail", "partial"]);
|
|
2170
|
+
var VerificationNextActionSchema = z10.enum([
|
|
1006
2171
|
"finish",
|
|
1007
2172
|
"retry",
|
|
1008
2173
|
"rollback",
|
|
1009
2174
|
"inspect_more"
|
|
1010
2175
|
]);
|
|
1011
|
-
var VerificationDecisionSchema =
|
|
2176
|
+
var VerificationDecisionSchema = z10.object({
|
|
1012
2177
|
status: VerificationStatusSchema,
|
|
1013
2178
|
/** Concrete evidence lines from logs, test output, or type-checker output */
|
|
1014
|
-
evidence:
|
|
2179
|
+
evidence: z10.array(z10.string()),
|
|
1015
2180
|
nextAction: VerificationNextActionSchema,
|
|
1016
2181
|
/** Files that should be prioritised in the next retrieval/editing round */
|
|
1017
|
-
focusFiles:
|
|
2182
|
+
focusFiles: z10.array(z10.string()),
|
|
1018
2183
|
/**
|
|
1019
2184
|
* Short fingerprint string identifying the failure category.
|
|
1020
2185
|
* Used to detect repeat failure loops. Only present when status !== "pass".
|
|
1021
2186
|
*/
|
|
1022
|
-
failureFingerprint:
|
|
2187
|
+
failureFingerprint: z10.string().optional()
|
|
1023
2188
|
});
|
|
1024
2189
|
|
|
1025
2190
|
// packages/schemas/dist/repoProfile.js
|
|
1026
|
-
import { z as
|
|
1027
|
-
var LanguageSchema =
|
|
2191
|
+
import { z as z11 } from "zod";
|
|
2192
|
+
var LanguageSchema = z11.enum([
|
|
1028
2193
|
"typescript",
|
|
1029
2194
|
"javascript",
|
|
1030
2195
|
"python",
|
|
@@ -1035,7 +2200,7 @@ var LanguageSchema = z9.enum([
|
|
|
1035
2200
|
"sql",
|
|
1036
2201
|
"other"
|
|
1037
2202
|
]);
|
|
1038
|
-
var PackageManagerSchema =
|
|
2203
|
+
var PackageManagerSchema = z11.enum([
|
|
1039
2204
|
"npm",
|
|
1040
2205
|
"pnpm",
|
|
1041
2206
|
"yarn",
|
|
@@ -1048,7 +2213,7 @@ var PackageManagerSchema = z9.enum([
|
|
|
1048
2213
|
"gradle",
|
|
1049
2214
|
"other"
|
|
1050
2215
|
]);
|
|
1051
|
-
var BuildSystemSchema =
|
|
2216
|
+
var BuildSystemSchema = z11.enum([
|
|
1052
2217
|
"tsc",
|
|
1053
2218
|
"vite",
|
|
1054
2219
|
"webpack",
|
|
@@ -1062,7 +2227,7 @@ var BuildSystemSchema = z9.enum([
|
|
|
1062
2227
|
"maven",
|
|
1063
2228
|
"other"
|
|
1064
2229
|
]);
|
|
1065
|
-
var MigrationSystemSchema =
|
|
2230
|
+
var MigrationSystemSchema = z11.enum([
|
|
1066
2231
|
"prisma",
|
|
1067
2232
|
"drizzle",
|
|
1068
2233
|
"knex",
|
|
@@ -1074,131 +2239,131 @@ var MigrationSystemSchema = z9.enum([
|
|
|
1074
2239
|
"other",
|
|
1075
2240
|
"none"
|
|
1076
2241
|
]);
|
|
1077
|
-
var RepoProfileSchema =
|
|
2242
|
+
var RepoProfileSchema = z11.object({
|
|
1078
2243
|
/** Languages present in the repo, ordered by prevalence */
|
|
1079
|
-
languages:
|
|
2244
|
+
languages: z11.array(LanguageSchema),
|
|
1080
2245
|
/** Frameworks detected (e.g. "nextjs", "fastapi", "express") */
|
|
1081
|
-
frameworks:
|
|
2246
|
+
frameworks: z11.array(z11.string()),
|
|
1082
2247
|
packageManager: PackageManagerSchema.optional(),
|
|
1083
2248
|
buildSystem: BuildSystemSchema.optional(),
|
|
1084
2249
|
/** Shell commands known to run the test suite */
|
|
1085
|
-
testCommands:
|
|
2250
|
+
testCommands: z11.array(z11.string()),
|
|
1086
2251
|
/** Shell commands known to run the linter */
|
|
1087
|
-
lintCommands:
|
|
2252
|
+
lintCommands: z11.array(z11.string()),
|
|
1088
2253
|
migrationSystem: MigrationSystemSchema.optional(),
|
|
1089
2254
|
/** Runtime assumptions such as Node version, Python version, etc. */
|
|
1090
|
-
runtimeAssumptions:
|
|
2255
|
+
runtimeAssumptions: z11.array(z11.string()),
|
|
1091
2256
|
/** Names of environment variables the repo consumes */
|
|
1092
|
-
envVarNames:
|
|
2257
|
+
envVarNames: z11.array(z11.string()),
|
|
1093
2258
|
/** Deployment-related notes (e.g. Docker, Kubernetes, serverless) */
|
|
1094
|
-
deploymentNotes:
|
|
2259
|
+
deploymentNotes: z11.array(z11.string()),
|
|
1095
2260
|
/** Absolute path to the repo root on the agent's filesystem */
|
|
1096
|
-
repoRoot:
|
|
2261
|
+
repoRoot: z11.string(),
|
|
1097
2262
|
/** ISO-8601 timestamp of the last profile update */
|
|
1098
|
-
lastIndexed:
|
|
2263
|
+
lastIndexed: z11.string().datetime()
|
|
1099
2264
|
});
|
|
1100
2265
|
|
|
1101
2266
|
// packages/schemas/dist/retrieval.js
|
|
1102
|
-
import { z as
|
|
1103
|
-
var RetrievalRequestSchema =
|
|
2267
|
+
import { z as z12 } from "zod";
|
|
2268
|
+
var RetrievalRequestSchema = z12.object({
|
|
1104
2269
|
/** Natural language description of what information is needed */
|
|
1105
|
-
query:
|
|
2270
|
+
query: z12.string().min(1),
|
|
1106
2271
|
/** File path hints that the retrieval system should prioritise */
|
|
1107
|
-
pathsHint:
|
|
2272
|
+
pathsHint: z12.array(z12.string()),
|
|
1108
2273
|
/** Symbol names (functions, classes, types) to look up */
|
|
1109
|
-
symbolHint:
|
|
2274
|
+
symbolHint: z12.array(z12.string()),
|
|
1110
2275
|
/** Error message fragments to search for in logs and source */
|
|
1111
|
-
errorHint:
|
|
2276
|
+
errorHint: z12.array(z12.string()),
|
|
1112
2277
|
/** Maximum number of files to include in the retrieval packet */
|
|
1113
|
-
maxFiles:
|
|
2278
|
+
maxFiles: z12.number().int().positive(),
|
|
1114
2279
|
/** Maximum number of code snippets to include */
|
|
1115
|
-
maxSnippets:
|
|
2280
|
+
maxSnippets: z12.number().int().positive(),
|
|
1116
2281
|
/** Whether test files should be included in results */
|
|
1117
|
-
includeTests:
|
|
2282
|
+
includeTests: z12.boolean(),
|
|
1118
2283
|
/** Whether config files (tsconfig, package.json, .env.example …) should be included */
|
|
1119
|
-
includeConfigs:
|
|
2284
|
+
includeConfigs: z12.boolean()
|
|
1120
2285
|
});
|
|
1121
|
-
var SnippetSchema =
|
|
2286
|
+
var SnippetSchema = z12.object({
|
|
1122
2287
|
/** Repo-relative path of the source file */
|
|
1123
|
-
file:
|
|
2288
|
+
file: z12.string(),
|
|
1124
2289
|
/** 1-based start line */
|
|
1125
|
-
startLine:
|
|
2290
|
+
startLine: z12.number().int().positive(),
|
|
1126
2291
|
/** 1-based end line (inclusive) */
|
|
1127
|
-
endLine:
|
|
2292
|
+
endLine: z12.number().int().positive(),
|
|
1128
2293
|
/** The actual source text */
|
|
1129
|
-
content:
|
|
2294
|
+
content: z12.string(),
|
|
1130
2295
|
/** Why this snippet was selected */
|
|
1131
|
-
relevanceNote:
|
|
2296
|
+
relevanceNote: z12.string().optional()
|
|
1132
2297
|
});
|
|
1133
|
-
var RetrievalPacketSchema =
|
|
2298
|
+
var RetrievalPacketSchema = z12.object({
|
|
1134
2299
|
/** Echo of the original request that produced this packet */
|
|
1135
2300
|
request: RetrievalRequestSchema,
|
|
1136
2301
|
/** Full file contents or extracts, keyed by repo-relative path */
|
|
1137
|
-
files:
|
|
1138
|
-
snippets:
|
|
2302
|
+
files: z12.record(z12.string(), z12.string()),
|
|
2303
|
+
snippets: z12.array(SnippetSchema),
|
|
1139
2304
|
/** One-line architecture note for orientation */
|
|
1140
|
-
architectureNote:
|
|
2305
|
+
architectureNote: z12.string().optional(),
|
|
1141
2306
|
/** Note summarising relevant prior attempts at related tasks */
|
|
1142
|
-
priorAttemptNote:
|
|
2307
|
+
priorAttemptNote: z12.string().optional(),
|
|
1143
2308
|
/** ISO-8601 timestamp when the packet was assembled */
|
|
1144
|
-
assembledAt:
|
|
2309
|
+
assembledAt: z12.string().datetime()
|
|
1145
2310
|
});
|
|
1146
2311
|
|
|
1147
2312
|
// packages/schemas/dist/dispatch.js
|
|
1148
|
-
import { z as
|
|
1149
|
-
var DispatchModeSchema =
|
|
2313
|
+
import { z as z13 } from "zod";
|
|
2314
|
+
var DispatchModeSchema = z13.enum([
|
|
1150
2315
|
"single_pass",
|
|
1151
2316
|
"multi_agent",
|
|
1152
2317
|
"hybrid"
|
|
1153
2318
|
]);
|
|
1154
|
-
var TaskComplexitySchema =
|
|
1155
|
-
var AgentRoleSchema =
|
|
2319
|
+
var TaskComplexitySchema = z13.enum(["low", "medium", "high"]);
|
|
2320
|
+
var AgentRoleSchema = z13.enum([
|
|
1156
2321
|
"planner",
|
|
1157
2322
|
"scout",
|
|
1158
2323
|
"editor",
|
|
1159
2324
|
"verifier",
|
|
1160
2325
|
"researcher"
|
|
1161
2326
|
]);
|
|
1162
|
-
var BudgetsSchema =
|
|
2327
|
+
var BudgetsSchema = z13.object({
|
|
1163
2328
|
/** Maximum prompt tokens across all model calls for this task */
|
|
1164
|
-
promptTokens:
|
|
2329
|
+
promptTokens: z13.number().int().positive(),
|
|
1165
2330
|
/** Maximum number of retry cycles allowed per subtask */
|
|
1166
|
-
retries:
|
|
2331
|
+
retries: z13.number().int().nonnegative(),
|
|
1167
2332
|
/** Maximum wall-clock seconds before the task is considered timed out */
|
|
1168
|
-
wallClockSec:
|
|
2333
|
+
wallClockSec: z13.number().positive()
|
|
1169
2334
|
});
|
|
1170
|
-
var DispatchDecisionSchema =
|
|
2335
|
+
var DispatchDecisionSchema = z13.object({
|
|
1171
2336
|
mode: DispatchModeSchema,
|
|
1172
2337
|
taskComplexity: TaskComplexitySchema,
|
|
1173
|
-
splitRecommended:
|
|
2338
|
+
splitRecommended: z13.boolean(),
|
|
1174
2339
|
/** Agent roles that should be spun up for the first wave of execution */
|
|
1175
|
-
initialAgents:
|
|
2340
|
+
initialAgents: z13.array(AgentRoleSchema),
|
|
1176
2341
|
budgets: BudgetsSchema
|
|
1177
2342
|
});
|
|
1178
2343
|
|
|
1179
2344
|
// packages/schemas/dist/memory.js
|
|
1180
|
-
import { z as
|
|
1181
|
-
var RiskLevelSchema =
|
|
1182
|
-
var FileSummarySchema =
|
|
2345
|
+
import { z as z14 } from "zod";
|
|
2346
|
+
var RiskLevelSchema = z14.enum(["low", "medium", "high", "critical"]);
|
|
2347
|
+
var FileSummarySchema = z14.object({
|
|
1183
2348
|
/** Repo-relative path of the file */
|
|
1184
|
-
path:
|
|
2349
|
+
path: z14.string().min(1),
|
|
1185
2350
|
/** One-sentence description of the file's role */
|
|
1186
|
-
purpose:
|
|
2351
|
+
purpose: z14.string(),
|
|
1187
2352
|
/** Primary exported symbols (functions, classes, constants) */
|
|
1188
|
-
mainExports:
|
|
2353
|
+
mainExports: z14.array(z14.string()),
|
|
1189
2354
|
/** Key import paths this file depends on */
|
|
1190
|
-
keyImports:
|
|
2355
|
+
keyImports: z14.array(z14.string()),
|
|
1191
2356
|
/** Logical ownership area (e.g. "auth", "api", "db", "frontend") */
|
|
1192
|
-
ownershipDomain:
|
|
2357
|
+
ownershipDomain: z14.string(),
|
|
1193
2358
|
riskLevel: RiskLevelSchema,
|
|
1194
2359
|
/** Paths of test files that cover this file */
|
|
1195
|
-
relatedTests:
|
|
2360
|
+
relatedTests: z14.array(z14.string()),
|
|
1196
2361
|
/** SHA-256 or similar hash of the file content at last index time */
|
|
1197
|
-
summaryHash:
|
|
2362
|
+
summaryHash: z14.string(),
|
|
1198
2363
|
/** ISO-8601 timestamp of the last indexing pass */
|
|
1199
|
-
lastIndexed:
|
|
2364
|
+
lastIndexed: z14.string().datetime()
|
|
1200
2365
|
});
|
|
1201
|
-
var FailureCategorySchema =
|
|
2366
|
+
var FailureCategorySchema = z14.enum([
|
|
1202
2367
|
"ts_type_drift",
|
|
1203
2368
|
"import_path_mismatch",
|
|
1204
2369
|
"route_not_registered",
|
|
@@ -1211,87 +2376,87 @@ var FailureCategorySchema = z12.enum([
|
|
|
1211
2376
|
"test_error",
|
|
1212
2377
|
"other"
|
|
1213
2378
|
]);
|
|
1214
|
-
var FailureFingerprintSchema =
|
|
2379
|
+
var FailureFingerprintSchema = z14.object({
|
|
1215
2380
|
/** Short stable identifier (e.g. "ts_type_drift:UserSchema") */
|
|
1216
|
-
fingerprint:
|
|
2381
|
+
fingerprint: z14.string().min(1),
|
|
1217
2382
|
category: FailureCategorySchema,
|
|
1218
2383
|
/** Human-readable summary of what went wrong */
|
|
1219
|
-
description:
|
|
2384
|
+
description: z14.string(),
|
|
1220
2385
|
/** Files involved in or triggering the failure */
|
|
1221
|
-
affectedFiles:
|
|
2386
|
+
affectedFiles: z14.array(z14.string()),
|
|
1222
2387
|
/** How many times this fingerprint has been seen */
|
|
1223
|
-
occurrenceCount:
|
|
2388
|
+
occurrenceCount: z14.number().int().nonnegative(),
|
|
1224
2389
|
/** ISO-8601 timestamp of first occurrence */
|
|
1225
|
-
firstSeen:
|
|
2390
|
+
firstSeen: z14.string().datetime(),
|
|
1226
2391
|
/** ISO-8601 timestamp of most recent occurrence */
|
|
1227
|
-
lastSeen:
|
|
2392
|
+
lastSeen: z14.string().datetime()
|
|
1228
2393
|
});
|
|
1229
|
-
var TaskMemorySchema =
|
|
1230
|
-
taskId:
|
|
1231
|
-
goal:
|
|
2394
|
+
var TaskMemorySchema = z14.object({
|
|
2395
|
+
taskId: z14.string().min(1),
|
|
2396
|
+
goal: z14.string(),
|
|
1232
2397
|
/** Normalised constraints carried into the task */
|
|
1233
|
-
normalizedConstraints:
|
|
2398
|
+
normalizedConstraints: z14.array(z14.string()),
|
|
1234
2399
|
/** Files that were read or modified during the task */
|
|
1235
|
-
filesTouched:
|
|
2400
|
+
filesTouched: z14.array(z14.string()),
|
|
1236
2401
|
/** Summary of patches applied (not the full diff) */
|
|
1237
|
-
patchesApplied:
|
|
2402
|
+
patchesApplied: z14.array(z14.string()),
|
|
1238
2403
|
/** Final validation outcome ("pass" | "fail" | "partial") */
|
|
1239
|
-
validationOutcome:
|
|
2404
|
+
validationOutcome: z14.enum(["pass", "fail", "partial"]),
|
|
1240
2405
|
/** Human-readable reasons for any failures */
|
|
1241
|
-
failureReasons:
|
|
2406
|
+
failureReasons: z14.array(z14.string()),
|
|
1242
2407
|
/** Follow-up tasks or open questions left behind */
|
|
1243
|
-
followUpTodos:
|
|
2408
|
+
followUpTodos: z14.array(z14.string()),
|
|
1244
2409
|
/**
|
|
1245
2410
|
* Subjective quality score 0–100 assigned by the verifier
|
|
1246
2411
|
* (100 = perfect, 0 = complete failure)
|
|
1247
2412
|
*/
|
|
1248
|
-
qualityScore:
|
|
2413
|
+
qualityScore: z14.number().int().min(0).max(100),
|
|
1249
2414
|
/** ISO-8601 timestamp when the task completed */
|
|
1250
|
-
completedAt:
|
|
2415
|
+
completedAt: z14.string().datetime()
|
|
1251
2416
|
});
|
|
1252
2417
|
|
|
1253
2418
|
// packages/schemas/dist/backend.js
|
|
1254
|
-
import { z as
|
|
1255
|
-
var MessageRoleSchema =
|
|
2419
|
+
import { z as z15 } from "zod";
|
|
2420
|
+
var MessageRoleSchema = z15.enum([
|
|
1256
2421
|
"system",
|
|
1257
2422
|
"user",
|
|
1258
2423
|
"assistant",
|
|
1259
2424
|
"tool"
|
|
1260
2425
|
]);
|
|
1261
|
-
var ChatMessageSchema =
|
|
2426
|
+
var ChatMessageSchema = z15.object({
|
|
1262
2427
|
role: MessageRoleSchema,
|
|
1263
|
-
content:
|
|
2428
|
+
content: z15.string(),
|
|
1264
2429
|
/** Tool call ID, required when role === "tool" */
|
|
1265
|
-
toolCallId:
|
|
2430
|
+
toolCallId: z15.string().optional(),
|
|
1266
2431
|
/** Tool name, required when role === "tool" */
|
|
1267
|
-
name:
|
|
2432
|
+
name: z15.string().optional()
|
|
1268
2433
|
});
|
|
1269
|
-
var CompletionRequestSchema =
|
|
1270
|
-
messages:
|
|
2434
|
+
var CompletionRequestSchema = z15.object({
|
|
2435
|
+
messages: z15.array(ChatMessageSchema),
|
|
1271
2436
|
/** Override the model used by the backend for this request */
|
|
1272
|
-
model:
|
|
1273
|
-
maxTokens:
|
|
1274
|
-
temperature:
|
|
2437
|
+
model: z15.string().optional(),
|
|
2438
|
+
maxTokens: z15.number().int().positive().optional(),
|
|
2439
|
+
temperature: z15.number().min(0).max(2).optional(),
|
|
1275
2440
|
/** Request class for queue routing */
|
|
1276
|
-
queueClass:
|
|
2441
|
+
queueClass: z15.string().optional(),
|
|
1277
2442
|
/** Prefix hash for cache-aware routing */
|
|
1278
|
-
prefixHash:
|
|
1279
|
-
stopSequences:
|
|
2443
|
+
prefixHash: z15.string().optional(),
|
|
2444
|
+
stopSequences: z15.array(z15.string()).optional()
|
|
1280
2445
|
});
|
|
1281
|
-
var TokenUsageSchema =
|
|
1282
|
-
promptTokens:
|
|
1283
|
-
completionTokens:
|
|
1284
|
-
totalTokens:
|
|
1285
|
-
cacheCreationInputTokens:
|
|
1286
|
-
cacheReadInputTokens:
|
|
1287
|
-
promptEvalCount:
|
|
2446
|
+
var TokenUsageSchema = z15.object({
|
|
2447
|
+
promptTokens: z15.number().int().nonnegative(),
|
|
2448
|
+
completionTokens: z15.number().int().nonnegative(),
|
|
2449
|
+
totalTokens: z15.number().int().nonnegative(),
|
|
2450
|
+
cacheCreationInputTokens: z15.number().int().nonnegative().optional(),
|
|
2451
|
+
cacheReadInputTokens: z15.number().int().nonnegative().optional(),
|
|
2452
|
+
promptEvalCount: z15.number().int().nonnegative().optional()
|
|
1288
2453
|
});
|
|
1289
|
-
var CompletionResponseSchema =
|
|
1290
|
-
content:
|
|
2454
|
+
var CompletionResponseSchema = z15.object({
|
|
2455
|
+
content: z15.string(),
|
|
1291
2456
|
usage: TokenUsageSchema.optional(),
|
|
1292
2457
|
/** Which model actually served the request */
|
|
1293
|
-
model:
|
|
1294
|
-
finishReason:
|
|
2458
|
+
model: z15.string().optional(),
|
|
2459
|
+
finishReason: z15.enum(["stop", "length", "tool_calls", "content_filter", "error"]).optional()
|
|
1295
2460
|
});
|
|
1296
2461
|
var StructuredCompletionRequestSchema = CompletionRequestSchema.extend({
|
|
1297
2462
|
/**
|
|
@@ -1299,55 +2464,55 @@ var StructuredCompletionRequestSchema = CompletionRequestSchema.extend({
|
|
|
1299
2464
|
* Stored as unknown here because Zod schemas are not themselves
|
|
1300
2465
|
* serialisable — callers pass the live schema object.
|
|
1301
2466
|
*/
|
|
1302
|
-
outputSchema:
|
|
2467
|
+
outputSchema: z15.unknown(),
|
|
1303
2468
|
/** Human-readable label used in prompt injection for the schema */
|
|
1304
|
-
schemaLabel:
|
|
2469
|
+
schemaLabel: z15.string().optional()
|
|
1305
2470
|
});
|
|
1306
|
-
var BackendHealthSchema =
|
|
1307
|
-
status:
|
|
1308
|
-
latencyMs:
|
|
2471
|
+
var BackendHealthSchema = z15.object({
|
|
2472
|
+
status: z15.enum(["ok", "degraded", "down"]),
|
|
2473
|
+
latencyMs: z15.number().nonnegative().optional(),
|
|
1309
2474
|
/** Fraction of GPU memory currently in use (0–1) */
|
|
1310
|
-
gpuMemoryUsed:
|
|
2475
|
+
gpuMemoryUsed: z15.number().min(0).max(1).optional(),
|
|
1311
2476
|
/** Fraction of KV cache currently in use (0–1) */
|
|
1312
|
-
kvCacheUsed:
|
|
2477
|
+
kvCacheUsed: z15.number().min(0).max(1).optional(),
|
|
1313
2478
|
/** Number of requests currently waiting in the queue */
|
|
1314
|
-
queueDepth:
|
|
2479
|
+
queueDepth: z15.number().int().nonnegative().optional(),
|
|
1315
2480
|
/** Human-readable note about any degraded state */
|
|
1316
|
-
note:
|
|
2481
|
+
note: z15.string().optional()
|
|
1317
2482
|
});
|
|
1318
|
-
var BackendMetricsSchema =
|
|
2483
|
+
var BackendMetricsSchema = z15.object({
|
|
1319
2484
|
/** Total requests handled since startup */
|
|
1320
|
-
totalRequests:
|
|
2485
|
+
totalRequests: z15.number().int().nonnegative(),
|
|
1321
2486
|
/** Requests that completed successfully */
|
|
1322
|
-
successfulRequests:
|
|
2487
|
+
successfulRequests: z15.number().int().nonnegative(),
|
|
1323
2488
|
/** Requests that failed */
|
|
1324
|
-
failedRequests:
|
|
2489
|
+
failedRequests: z15.number().int().nonnegative(),
|
|
1325
2490
|
/** Average time-to-first-token across recent requests (ms) */
|
|
1326
|
-
avgTtftMs:
|
|
2491
|
+
avgTtftMs: z15.number().nonnegative().optional(),
|
|
1327
2492
|
/** Average end-to-end latency across recent requests (ms) */
|
|
1328
|
-
avgLatencyMs:
|
|
2493
|
+
avgLatencyMs: z15.number().nonnegative().optional(),
|
|
1329
2494
|
/** Approximate prefix cache hit rate (0–1) */
|
|
1330
|
-
prefixCacheHitRate:
|
|
2495
|
+
prefixCacheHitRate: z15.number().min(0).max(1).optional(),
|
|
1331
2496
|
/** Number of sleep/wake cycles since startup */
|
|
1332
|
-
sleepWakeCycles:
|
|
2497
|
+
sleepWakeCycles: z15.number().int().nonnegative().optional(),
|
|
1333
2498
|
/** Number of OOM / preemption / offload events */
|
|
1334
|
-
oomEvents:
|
|
2499
|
+
oomEvents: z15.number().int().nonnegative().optional(),
|
|
1335
2500
|
/** ISO-8601 timestamp of when the backend service started */
|
|
1336
|
-
uptimeSince:
|
|
2501
|
+
uptimeSince: z15.string().datetime().optional()
|
|
1337
2502
|
});
|
|
1338
2503
|
|
|
1339
2504
|
// packages/schemas/dist/config.js
|
|
1340
|
-
import { z as
|
|
1341
|
-
var AgentConfigSchema =
|
|
2505
|
+
import { z as z16 } from "zod";
|
|
2506
|
+
var AgentConfigSchema = z16.object({
|
|
1342
2507
|
// -----------------------------------------------------------------------
|
|
1343
2508
|
// Model / backend
|
|
1344
2509
|
// -----------------------------------------------------------------------
|
|
1345
2510
|
/** HuggingFace model ID, e.g. "Qwen/Qwen3.5-122B-A10B" */
|
|
1346
|
-
MODEL_ID:
|
|
2511
|
+
MODEL_ID: z16.string().min(1),
|
|
1347
2512
|
/** Base URL of the primary vLLM OpenAI-compatible endpoint */
|
|
1348
|
-
VLLM_BASE_URL:
|
|
2513
|
+
VLLM_BASE_URL: z16.string().url(),
|
|
1349
2514
|
/** API key sent to the vLLM service (often the literal string "EMPTY") */
|
|
1350
|
-
VLLM_API_KEY:
|
|
2515
|
+
VLLM_API_KEY: z16.string().default("EMPTY"),
|
|
1351
2516
|
// -----------------------------------------------------------------------
|
|
1352
2517
|
// Context / memory tuning
|
|
1353
2518
|
// -----------------------------------------------------------------------
|
|
@@ -1355,47 +2520,47 @@ var AgentConfigSchema = z14.object({
|
|
|
1355
2520
|
* Maximum context length for the model.
|
|
1356
2521
|
* Should be discovered by startup probing rather than hard-coded.
|
|
1357
2522
|
*/
|
|
1358
|
-
AGENT_MAX_MODEL_LEN:
|
|
2523
|
+
AGENT_MAX_MODEL_LEN: z16.string().transform((v) => parseInt(v, 10)).pipe(z16.number().int().positive()).default(65536),
|
|
1359
2524
|
/** Enable vLLM automatic prefix caching (1 = enabled) */
|
|
1360
|
-
AGENT_ENABLE_PREFIX_CACHING:
|
|
2525
|
+
AGENT_ENABLE_PREFIX_CACHING: z16.string().transform((v) => v === "1" || v.toLowerCase() === "true").pipe(z16.boolean()).default(true),
|
|
1361
2526
|
/** Enable vLLM sleep mode when idle (1 = enabled) */
|
|
1362
|
-
AGENT_ENABLE_SLEEP_MODE:
|
|
2527
|
+
AGENT_ENABLE_SLEEP_MODE: z16.string().transform((v) => v === "1" || v.toLowerCase() === "true").pipe(z16.boolean()).default(true),
|
|
1363
2528
|
// -----------------------------------------------------------------------
|
|
1364
2529
|
// Agent behaviour
|
|
1365
2530
|
// -----------------------------------------------------------------------
|
|
1366
2531
|
/** Maximum retry cycles per subtask */
|
|
1367
|
-
AGENT_MAX_RETRIES:
|
|
2532
|
+
AGENT_MAX_RETRIES: z16.string().transform((v) => parseInt(v, 10)).pipe(z16.number().int().nonnegative()).default(3),
|
|
1368
2533
|
/** Maximum number of parallel subagents that may run simultaneously */
|
|
1369
|
-
AGENT_MAX_PARALLEL_SUBAGENTS:
|
|
2534
|
+
AGENT_MAX_PARALLEL_SUBAGENTS: z16.string().transform((v) => parseInt(v, 10)).pipe(z16.number().int().positive()).default(4),
|
|
1370
2535
|
// -----------------------------------------------------------------------
|
|
1371
2536
|
// Retrieval limits
|
|
1372
2537
|
// -----------------------------------------------------------------------
|
|
1373
2538
|
/** Maximum files included in a single retrieval packet */
|
|
1374
|
-
AGENT_RETRIEVAL_MAX_FILES:
|
|
2539
|
+
AGENT_RETRIEVAL_MAX_FILES: z16.string().transform((v) => parseInt(v, 10)).pipe(z16.number().int().positive()).default(8),
|
|
1375
2540
|
/** Maximum snippets included in a single retrieval packet */
|
|
1376
|
-
AGENT_RETRIEVAL_MAX_SNIPPETS:
|
|
2541
|
+
AGENT_RETRIEVAL_MAX_SNIPPETS: z16.string().transform((v) => parseInt(v, 10)).pipe(z16.number().int().positive()).default(16),
|
|
1377
2542
|
// -----------------------------------------------------------------------
|
|
1378
2543
|
// File paths
|
|
1379
2544
|
// -----------------------------------------------------------------------
|
|
1380
2545
|
/** Directory where agent working trees and artefacts are written */
|
|
1381
|
-
AGENT_WORK_ROOT:
|
|
2546
|
+
AGENT_WORK_ROOT: z16.string().min(1),
|
|
1382
2547
|
/** Directory where the indexer stores its indexes and embeddings */
|
|
1383
|
-
AGENT_INDEX_ROOT:
|
|
2548
|
+
AGENT_INDEX_ROOT: z16.string().min(1),
|
|
1384
2549
|
// -----------------------------------------------------------------------
|
|
1385
2550
|
// Optional models
|
|
1386
2551
|
// -----------------------------------------------------------------------
|
|
1387
2552
|
/** Model ID or endpoint for the embedding model (optional) */
|
|
1388
|
-
AGENT_EMBEDDING_MODEL:
|
|
2553
|
+
AGENT_EMBEDDING_MODEL: z16.string().optional(),
|
|
1389
2554
|
/**
|
|
1390
2555
|
* Optional smaller local model for triage/summarisation tasks.
|
|
1391
2556
|
* When set, used in Profile C (hybrid mode).
|
|
1392
2557
|
*/
|
|
1393
|
-
AGENT_SMALL_MODEL:
|
|
2558
|
+
AGENT_SMALL_MODEL: z16.string().optional()
|
|
1394
2559
|
});
|
|
1395
2560
|
|
|
1396
2561
|
// packages/schemas/dist/queue.js
|
|
1397
|
-
import { z as
|
|
1398
|
-
var QueueClassSchema =
|
|
2562
|
+
import { z as z17 } from "zod";
|
|
2563
|
+
var QueueClassSchema = z17.enum([
|
|
1399
2564
|
/** CLI and direct user-facing requests; lowest latency target */
|
|
1400
2565
|
"interactive-high",
|
|
1401
2566
|
/** Planner role requests; moderate priority */
|
|
@@ -1411,14 +2576,14 @@ var QueueClassSchema = z15.enum([
|
|
|
1411
2576
|
]);
|
|
1412
2577
|
|
|
1413
2578
|
// packages/schemas/dist/operational-world.js
|
|
1414
|
-
import { z as
|
|
2579
|
+
import { z as z18 } from "zod";
|
|
1415
2580
|
var OPERATIONAL_WORLD_SCHEMA_VERSION = "omnius.operational-world.v1";
|
|
1416
|
-
var OperationalWorldSchemaVersionSchema =
|
|
1417
|
-
var OperationalWorldIdSchema =
|
|
1418
|
-
var OperationalWorldRevisionSchema =
|
|
1419
|
-
var ConfidenceSchema =
|
|
1420
|
-
var OperationalFactScopeSchema =
|
|
1421
|
-
kind:
|
|
2581
|
+
var OperationalWorldSchemaVersionSchema = z18.literal(OPERATIONAL_WORLD_SCHEMA_VERSION);
|
|
2582
|
+
var OperationalWorldIdSchema = z18.string().trim().min(1).max(256);
|
|
2583
|
+
var OperationalWorldRevisionSchema = z18.string().trim().min(1).max(256);
|
|
2584
|
+
var ConfidenceSchema = z18.number().finite().min(0).max(1);
|
|
2585
|
+
var OperationalFactScopeSchema = z18.object({
|
|
2586
|
+
kind: z18.enum([
|
|
1422
2587
|
"global",
|
|
1423
2588
|
"run",
|
|
1424
2589
|
"task",
|
|
@@ -1429,9 +2594,9 @@ var OperationalFactScopeSchema = z16.object({
|
|
|
1429
2594
|
"legacy_unscoped"
|
|
1430
2595
|
]),
|
|
1431
2596
|
scopeId: OperationalWorldIdSchema,
|
|
1432
|
-
taskEpoch:
|
|
2597
|
+
taskEpoch: z18.number().int().nonnegative().optional()
|
|
1433
2598
|
}).strict();
|
|
1434
|
-
var OperationalMetadataDerivedFieldSchema =
|
|
2599
|
+
var OperationalMetadataDerivedFieldSchema = z18.enum([
|
|
1435
2600
|
"source_evidence",
|
|
1436
2601
|
"confidence",
|
|
1437
2602
|
"revision",
|
|
@@ -1439,73 +2604,73 @@ var OperationalMetadataDerivedFieldSchema = z16.enum([
|
|
|
1439
2604
|
"scope",
|
|
1440
2605
|
"metadata_provenance"
|
|
1441
2606
|
]);
|
|
1442
|
-
var OperationalMetadataProvenanceSchema =
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
kind:
|
|
1446
|
-
marker:
|
|
2607
|
+
var OperationalMetadataProvenanceSchema = z18.discriminatedUnion("kind", [
|
|
2608
|
+
z18.object({ kind: z18.literal("native") }).strict(),
|
|
2609
|
+
z18.object({
|
|
2610
|
+
kind: z18.literal("legacy_derived"),
|
|
2611
|
+
marker: z18.literal("metadata-only-no-semantic-assertion"),
|
|
1447
2612
|
sourceRecordId: OperationalWorldIdSchema,
|
|
1448
|
-
derivedFields:
|
|
2613
|
+
derivedFields: z18.array(OperationalMetadataDerivedFieldSchema).min(1).max(6)
|
|
1449
2614
|
}).strict()
|
|
1450
2615
|
]);
|
|
1451
|
-
var JsonValueSchema =
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
2616
|
+
var JsonValueSchema = z18.lazy(() => z18.union([
|
|
2617
|
+
z18.string(),
|
|
2618
|
+
z18.number().finite(),
|
|
2619
|
+
z18.boolean(),
|
|
2620
|
+
z18.null(),
|
|
2621
|
+
z18.array(JsonValueSchema),
|
|
2622
|
+
z18.record(z18.string(), JsonValueSchema)
|
|
1458
2623
|
]));
|
|
1459
|
-
var LineRangeLocatorSchema =
|
|
1460
|
-
type:
|
|
1461
|
-
startLine:
|
|
1462
|
-
endLine:
|
|
2624
|
+
var LineRangeLocatorSchema = z18.object({
|
|
2625
|
+
type: z18.literal("line_range"),
|
|
2626
|
+
startLine: z18.number().int().positive(),
|
|
2627
|
+
endLine: z18.number().int().positive()
|
|
1463
2628
|
}).strict();
|
|
1464
|
-
var CharacterRangeLocatorSchema =
|
|
1465
|
-
type:
|
|
1466
|
-
startOffset:
|
|
2629
|
+
var CharacterRangeLocatorSchema = z18.object({
|
|
2630
|
+
type: z18.literal("character_range"),
|
|
2631
|
+
startOffset: z18.number().int().nonnegative(),
|
|
1467
2632
|
/** Exclusive end offset. */
|
|
1468
|
-
endOffset:
|
|
2633
|
+
endOffset: z18.number().int().positive()
|
|
1469
2634
|
}).strict();
|
|
1470
|
-
var PageRangeLocatorSchema =
|
|
1471
|
-
type:
|
|
1472
|
-
startPage:
|
|
1473
|
-
endPage:
|
|
2635
|
+
var PageRangeLocatorSchema = z18.object({
|
|
2636
|
+
type: z18.literal("page_range"),
|
|
2637
|
+
startPage: z18.number().int().positive(),
|
|
2638
|
+
endPage: z18.number().int().positive()
|
|
1474
2639
|
}).strict();
|
|
1475
|
-
var SheetRangeLocatorSchema =
|
|
1476
|
-
type:
|
|
1477
|
-
sheetName:
|
|
1478
|
-
startRow:
|
|
1479
|
-
endRow:
|
|
1480
|
-
startColumn:
|
|
1481
|
-
endColumn:
|
|
2640
|
+
var SheetRangeLocatorSchema = z18.object({
|
|
2641
|
+
type: z18.literal("sheet_range"),
|
|
2642
|
+
sheetName: z18.string().trim().min(1).max(256),
|
|
2643
|
+
startRow: z18.number().int().positive().optional(),
|
|
2644
|
+
endRow: z18.number().int().positive().optional(),
|
|
2645
|
+
startColumn: z18.number().int().positive().optional(),
|
|
2646
|
+
endColumn: z18.number().int().positive().optional()
|
|
1482
2647
|
}).strict();
|
|
1483
|
-
var TableRangeLocatorSchema =
|
|
1484
|
-
type:
|
|
1485
|
-
table:
|
|
1486
|
-
startRow:
|
|
1487
|
-
endRow:
|
|
1488
|
-
columns:
|
|
2648
|
+
var TableRangeLocatorSchema = z18.object({
|
|
2649
|
+
type: z18.literal("table_range"),
|
|
2650
|
+
table: z18.string().trim().min(1).max(256),
|
|
2651
|
+
startRow: z18.number().int().nonnegative(),
|
|
2652
|
+
endRow: z18.number().int().nonnegative(),
|
|
2653
|
+
columns: z18.array(z18.string().trim().min(1).max(256)).max(128).optional()
|
|
1489
2654
|
}).strict();
|
|
1490
|
-
var JsonPathLocatorSchema =
|
|
1491
|
-
type:
|
|
1492
|
-
path:
|
|
2655
|
+
var JsonPathLocatorSchema = z18.object({
|
|
2656
|
+
type: z18.literal("json_path"),
|
|
2657
|
+
path: z18.string().trim().min(1).max(2048)
|
|
1493
2658
|
}).strict();
|
|
1494
|
-
var HeadingLocatorSchema =
|
|
1495
|
-
type:
|
|
1496
|
-
heading:
|
|
1497
|
-
occurrence:
|
|
2659
|
+
var HeadingLocatorSchema = z18.object({
|
|
2660
|
+
type: z18.literal("heading"),
|
|
2661
|
+
heading: z18.string().trim().min(1).max(1024),
|
|
2662
|
+
occurrence: z18.number().int().positive().optional()
|
|
1498
2663
|
}).strict();
|
|
1499
|
-
var FieldLocatorSchema =
|
|
1500
|
-
type:
|
|
1501
|
-
path:
|
|
1502
|
-
recordKey:
|
|
2664
|
+
var FieldLocatorSchema = z18.object({
|
|
2665
|
+
type: z18.literal("field"),
|
|
2666
|
+
path: z18.array(z18.string().trim().min(1).max(256)).min(1).max(64),
|
|
2667
|
+
recordKey: z18.string().trim().min(1).max(512).optional()
|
|
1503
2668
|
}).strict();
|
|
1504
|
-
var UriFragmentLocatorSchema =
|
|
1505
|
-
type:
|
|
1506
|
-
fragment:
|
|
2669
|
+
var UriFragmentLocatorSchema = z18.object({
|
|
2670
|
+
type: z18.literal("uri_fragment"),
|
|
2671
|
+
fragment: z18.string().trim().min(1).max(2048)
|
|
1507
2672
|
}).strict();
|
|
1508
|
-
var EvidenceLocatorSchema =
|
|
2673
|
+
var EvidenceLocatorSchema = z18.discriminatedUnion("type", [
|
|
1509
2674
|
LineRangeLocatorSchema,
|
|
1510
2675
|
CharacterRangeLocatorSchema,
|
|
1511
2676
|
PageRangeLocatorSchema,
|
|
@@ -1573,63 +2738,63 @@ var EvidenceLocatorSchema = z16.discriminatedUnion("type", [
|
|
|
1573
2738
|
});
|
|
1574
2739
|
}
|
|
1575
2740
|
});
|
|
1576
|
-
var SourceAuthoritySchema =
|
|
2741
|
+
var SourceAuthoritySchema = z18.enum([
|
|
1577
2742
|
"authoritative",
|
|
1578
2743
|
"primary",
|
|
1579
2744
|
"secondary",
|
|
1580
2745
|
"derived",
|
|
1581
2746
|
"unknown"
|
|
1582
2747
|
]);
|
|
1583
|
-
var SourceFreshnessSchema =
|
|
1584
|
-
var SourceReadPolicySchema =
|
|
2748
|
+
var SourceFreshnessSchema = z18.enum(["fresh", "stale", "unknown"]);
|
|
2749
|
+
var SourceReadPolicySchema = z18.enum([
|
|
1585
2750
|
"immutable",
|
|
1586
2751
|
"snapshot",
|
|
1587
2752
|
"refresh_before_use",
|
|
1588
2753
|
"live"
|
|
1589
2754
|
]);
|
|
1590
|
-
var SourceBindingSchema =
|
|
2755
|
+
var SourceBindingSchema = z18.object({
|
|
1591
2756
|
schemaVersion: OperationalWorldSchemaVersionSchema,
|
|
1592
2757
|
bindingId: OperationalWorldIdSchema,
|
|
1593
2758
|
sourceId: OperationalWorldIdSchema,
|
|
1594
2759
|
/** URI, repo-relative path, or external source identifier. */
|
|
1595
|
-
sourceUri:
|
|
2760
|
+
sourceUri: z18.string().trim().min(1).max(4096),
|
|
1596
2761
|
sourceRevision: OperationalWorldRevisionSchema,
|
|
1597
|
-
sourceHash:
|
|
2762
|
+
sourceHash: z18.string().trim().min(1).max(512).optional(),
|
|
1598
2763
|
locator: EvidenceLocatorSchema,
|
|
1599
2764
|
authority: SourceAuthoritySchema,
|
|
1600
2765
|
freshness: SourceFreshnessSchema,
|
|
1601
2766
|
readPolicy: SourceReadPolicySchema,
|
|
1602
|
-
observedAt:
|
|
2767
|
+
observedAt: z18.string().datetime(),
|
|
1603
2768
|
confidence: ConfidenceSchema,
|
|
1604
|
-
notes:
|
|
2769
|
+
notes: z18.string().trim().max(2e3).optional()
|
|
1605
2770
|
}).strict();
|
|
1606
|
-
var EvidenceRoleSchema =
|
|
2771
|
+
var EvidenceRoleSchema = z18.enum([
|
|
1607
2772
|
"supports",
|
|
1608
2773
|
"refutes",
|
|
1609
2774
|
"context",
|
|
1610
2775
|
"verification",
|
|
1611
2776
|
"blocker"
|
|
1612
2777
|
]);
|
|
1613
|
-
var EvidenceRefSchema =
|
|
2778
|
+
var EvidenceRefSchema = z18.object({
|
|
1614
2779
|
schemaVersion: OperationalWorldSchemaVersionSchema,
|
|
1615
2780
|
evidenceId: OperationalWorldIdSchema,
|
|
1616
2781
|
bindingId: OperationalWorldIdSchema,
|
|
1617
2782
|
role: EvidenceRoleSchema,
|
|
1618
|
-
excerpt:
|
|
1619
|
-
excerptHash:
|
|
1620
|
-
observedAt:
|
|
2783
|
+
excerpt: z18.string().max(4e3).optional(),
|
|
2784
|
+
excerptHash: z18.string().trim().min(1).max(512).optional(),
|
|
2785
|
+
observedAt: z18.string().datetime(),
|
|
1621
2786
|
confidence: ConfidenceSchema,
|
|
1622
|
-
tags:
|
|
2787
|
+
tags: z18.array(z18.string().trim().min(1).max(128)).max(64)
|
|
1623
2788
|
}).strict();
|
|
1624
|
-
var ClaimKindSchema =
|
|
2789
|
+
var ClaimKindSchema = z18.enum([
|
|
1625
2790
|
"fact",
|
|
1626
2791
|
"inference",
|
|
1627
2792
|
"requirement",
|
|
1628
2793
|
"constraint",
|
|
1629
2794
|
"outcome"
|
|
1630
2795
|
]);
|
|
1631
|
-
var ClaimPolaritySchema =
|
|
1632
|
-
var ClaimStatusSchema =
|
|
2796
|
+
var ClaimPolaritySchema = z18.enum(["positive", "negative"]);
|
|
2797
|
+
var ClaimStatusSchema = z18.enum([
|
|
1633
2798
|
"proposed",
|
|
1634
2799
|
"supported",
|
|
1635
2800
|
"refuted",
|
|
@@ -1637,28 +2802,28 @@ var ClaimStatusSchema = z16.enum([
|
|
|
1637
2802
|
"unverified",
|
|
1638
2803
|
"blocked"
|
|
1639
2804
|
]);
|
|
1640
|
-
var WorkGraphNodeAuthoritySchema =
|
|
2805
|
+
var WorkGraphNodeAuthoritySchema = z18.enum([
|
|
1641
2806
|
"explicit",
|
|
1642
2807
|
"inferred",
|
|
1643
2808
|
"adopted"
|
|
1644
2809
|
]);
|
|
1645
|
-
var ClaimSchema =
|
|
2810
|
+
var ClaimSchema = z18.object({
|
|
1646
2811
|
schemaVersion: OperationalWorldSchemaVersionSchema,
|
|
1647
2812
|
claimId: OperationalWorldIdSchema,
|
|
1648
|
-
statement:
|
|
2813
|
+
statement: z18.string().trim().min(1).max(4e3),
|
|
1649
2814
|
kind: ClaimKindSchema,
|
|
1650
2815
|
polarity: ClaimPolaritySchema,
|
|
1651
2816
|
status: ClaimStatusSchema,
|
|
1652
2817
|
confidence: ConfidenceSchema,
|
|
1653
|
-
evidenceRefIds:
|
|
1654
|
-
dependsOnClaimIds:
|
|
1655
|
-
tags:
|
|
2818
|
+
evidenceRefIds: z18.array(OperationalWorldIdSchema).max(256),
|
|
2819
|
+
dependsOnClaimIds: z18.array(OperationalWorldIdSchema).max(256),
|
|
2820
|
+
tags: z18.array(z18.string().trim().min(1).max(128)).max(64),
|
|
1656
2821
|
/** Structured proposition fields used to group competing claims. */
|
|
1657
2822
|
subjectNodeId: OperationalWorldIdSchema.optional(),
|
|
1658
|
-
predicate:
|
|
2823
|
+
predicate: z18.string().trim().min(1).max(512).optional(),
|
|
1659
2824
|
objectValue: JsonValueSchema.optional(),
|
|
1660
|
-
validFrom:
|
|
1661
|
-
validTo:
|
|
2825
|
+
validFrom: z18.string().datetime().optional(),
|
|
2826
|
+
validTo: z18.string().datetime().optional(),
|
|
1662
2827
|
authority: WorkGraphNodeAuthoritySchema.optional()
|
|
1663
2828
|
}).strict().superRefine((claim, ctx) => {
|
|
1664
2829
|
if (claim.validFrom !== void 0 && claim.validTo !== void 0 && Date.parse(claim.validTo) < Date.parse(claim.validFrom)) {
|
|
@@ -1669,32 +2834,32 @@ var ClaimSchema = z16.object({
|
|
|
1669
2834
|
});
|
|
1670
2835
|
}
|
|
1671
2836
|
});
|
|
1672
|
-
var ConflictKindSchema =
|
|
2837
|
+
var ConflictKindSchema = z18.enum([
|
|
1673
2838
|
"contradiction",
|
|
1674
2839
|
"source_disagreement",
|
|
1675
2840
|
"temporal",
|
|
1676
2841
|
"schema",
|
|
1677
2842
|
"authority"
|
|
1678
2843
|
]);
|
|
1679
|
-
var ConflictStatusSchema =
|
|
2844
|
+
var ConflictStatusSchema = z18.enum([
|
|
1680
2845
|
"open",
|
|
1681
2846
|
"resolved",
|
|
1682
2847
|
"accepted_uncertainty"
|
|
1683
2848
|
]);
|
|
1684
|
-
var ConflictResolutionSchema =
|
|
1685
|
-
decision:
|
|
1686
|
-
rationale:
|
|
1687
|
-
resolvedBy:
|
|
1688
|
-
resolvedAt:
|
|
1689
|
-
evidenceRefIds:
|
|
2849
|
+
var ConflictResolutionSchema = z18.object({
|
|
2850
|
+
decision: z18.string().trim().min(1).max(2e3),
|
|
2851
|
+
rationale: z18.string().trim().min(1).max(4e3),
|
|
2852
|
+
resolvedBy: z18.string().trim().min(1).max(256),
|
|
2853
|
+
resolvedAt: z18.string().datetime(),
|
|
2854
|
+
evidenceRefIds: z18.array(OperationalWorldIdSchema).max(256)
|
|
1690
2855
|
}).strict();
|
|
1691
|
-
var ConflictSchema =
|
|
2856
|
+
var ConflictSchema = z18.object({
|
|
1692
2857
|
schemaVersion: OperationalWorldSchemaVersionSchema,
|
|
1693
2858
|
conflictId: OperationalWorldIdSchema,
|
|
1694
2859
|
kind: ConflictKindSchema,
|
|
1695
|
-
summary:
|
|
1696
|
-
claimIds:
|
|
1697
|
-
evidenceRefIds:
|
|
2860
|
+
summary: z18.string().trim().min(1).max(4e3),
|
|
2861
|
+
claimIds: z18.array(OperationalWorldIdSchema).min(2).max(64),
|
|
2862
|
+
evidenceRefIds: z18.array(OperationalWorldIdSchema).max(256),
|
|
1698
2863
|
status: ConflictStatusSchema,
|
|
1699
2864
|
resolution: ConflictResolutionSchema.optional()
|
|
1700
2865
|
}).strict().superRefine((conflict, ctx) => {
|
|
@@ -1713,7 +2878,7 @@ var ConflictSchema = z16.object({
|
|
|
1713
2878
|
});
|
|
1714
2879
|
}
|
|
1715
2880
|
});
|
|
1716
|
-
var WorkGraphNodeKindSchema =
|
|
2881
|
+
var WorkGraphNodeKindSchema = z18.enum([
|
|
1717
2882
|
"objective",
|
|
1718
2883
|
"requirement",
|
|
1719
2884
|
"document",
|
|
@@ -1741,7 +2906,7 @@ var WorkGraphNodeKindSchema = z16.enum([
|
|
|
1741
2906
|
"conversation",
|
|
1742
2907
|
"relationship"
|
|
1743
2908
|
]);
|
|
1744
|
-
var WorkGraphNodeStatusSchema =
|
|
2909
|
+
var WorkGraphNodeStatusSchema = z18.enum([
|
|
1745
2910
|
"proposed",
|
|
1746
2911
|
"active",
|
|
1747
2912
|
"blocked",
|
|
@@ -1749,42 +2914,42 @@ var WorkGraphNodeStatusSchema = z16.enum([
|
|
|
1749
2914
|
"invalid",
|
|
1750
2915
|
"superseded"
|
|
1751
2916
|
]);
|
|
1752
|
-
var WorkGraphTargetRefSchema =
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
type:
|
|
2917
|
+
var WorkGraphTargetRefSchema = z18.discriminatedUnion("type", [
|
|
2918
|
+
z18.object({ type: z18.literal("node"), nodeId: OperationalWorldIdSchema }).strict(),
|
|
2919
|
+
z18.object({ type: z18.literal("claim"), claimId: OperationalWorldIdSchema }).strict(),
|
|
2920
|
+
z18.object({
|
|
2921
|
+
type: z18.literal("conflict"),
|
|
1757
2922
|
conflictId: OperationalWorldIdSchema
|
|
1758
2923
|
}).strict(),
|
|
1759
|
-
|
|
1760
|
-
type:
|
|
2924
|
+
z18.object({
|
|
2925
|
+
type: z18.literal("evidence"),
|
|
1761
2926
|
evidenceId: OperationalWorldIdSchema
|
|
1762
2927
|
}).strict(),
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
type:
|
|
1766
|
-
uri:
|
|
2928
|
+
z18.object({ type: z18.literal("source"), bindingId: OperationalWorldIdSchema }).strict(),
|
|
2929
|
+
z18.object({
|
|
2930
|
+
type: z18.literal("artifact"),
|
|
2931
|
+
uri: z18.string().trim().min(1).max(4096),
|
|
1767
2932
|
revision: OperationalWorldRevisionSchema.optional()
|
|
1768
2933
|
}).strict()
|
|
1769
2934
|
]);
|
|
1770
|
-
var WorkActionPreconditionSchema =
|
|
2935
|
+
var WorkActionPreconditionSchema = z18.object({
|
|
1771
2936
|
preconditionId: OperationalWorldIdSchema,
|
|
1772
|
-
description:
|
|
1773
|
-
status:
|
|
1774
|
-
evidenceRefIds:
|
|
2937
|
+
description: z18.string().trim().min(1).max(2e3),
|
|
2938
|
+
status: z18.enum(["unknown", "satisfied", "unsatisfied", "waived"]),
|
|
2939
|
+
evidenceRefIds: z18.array(OperationalWorldIdSchema).max(256)
|
|
1775
2940
|
}).strict();
|
|
1776
|
-
var WorkActionMutationSchema =
|
|
2941
|
+
var WorkActionMutationSchema = z18.object({
|
|
1777
2942
|
mutationId: OperationalWorldIdSchema,
|
|
1778
|
-
kind:
|
|
2943
|
+
kind: z18.enum(["create", "update", "delete", "execute", "deliver"]),
|
|
1779
2944
|
target: WorkGraphTargetRefSchema,
|
|
1780
|
-
description:
|
|
1781
|
-
reversible:
|
|
2945
|
+
description: z18.string().trim().min(1).max(2e3),
|
|
2946
|
+
reversible: z18.boolean()
|
|
1782
2947
|
}).strict();
|
|
1783
|
-
var WorkActionApprovalSchema =
|
|
1784
|
-
required:
|
|
1785
|
-
status:
|
|
1786
|
-
approvedBy:
|
|
1787
|
-
approvedAt:
|
|
2948
|
+
var WorkActionApprovalSchema = z18.object({
|
|
2949
|
+
required: z18.boolean(),
|
|
2950
|
+
status: z18.enum(["not_required", "pending", "approved", "rejected"]),
|
|
2951
|
+
approvedBy: z18.string().trim().min(1).max(256).optional(),
|
|
2952
|
+
approvedAt: z18.string().datetime().optional()
|
|
1788
2953
|
}).strict().superRefine((approval, ctx) => {
|
|
1789
2954
|
if (!approval.required && approval.status !== "not_required") {
|
|
1790
2955
|
ctx.addIssue({
|
|
@@ -1808,52 +2973,52 @@ var WorkActionApprovalSchema = z16.object({
|
|
|
1808
2973
|
});
|
|
1809
2974
|
}
|
|
1810
2975
|
});
|
|
1811
|
-
var WorkActionContractSchema =
|
|
1812
|
-
preconditions:
|
|
1813
|
-
mutations:
|
|
1814
|
-
sideEffects:
|
|
2976
|
+
var WorkActionContractSchema = z18.object({
|
|
2977
|
+
preconditions: z18.array(WorkActionPreconditionSchema).max(256),
|
|
2978
|
+
mutations: z18.array(WorkActionMutationSchema).max(256),
|
|
2979
|
+
sideEffects: z18.array(z18.string().trim().min(1).max(2e3)).max(256),
|
|
1815
2980
|
approval: WorkActionApprovalSchema,
|
|
1816
|
-
authority:
|
|
2981
|
+
authority: z18.enum([
|
|
1817
2982
|
"operator_explicit",
|
|
1818
2983
|
"delegated_scope",
|
|
1819
2984
|
"policy",
|
|
1820
2985
|
"none"
|
|
1821
2986
|
]),
|
|
1822
|
-
risk:
|
|
2987
|
+
risk: z18.enum(["none", "low", "medium", "high", "critical"])
|
|
1823
2988
|
}).strict();
|
|
1824
|
-
var WorkGraphNodeReferenceSchema =
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
type:
|
|
2989
|
+
var WorkGraphNodeReferenceSchema = z18.discriminatedUnion("type", [
|
|
2990
|
+
z18.object({ type: z18.literal("claim"), claimId: OperationalWorldIdSchema }).strict(),
|
|
2991
|
+
z18.object({
|
|
2992
|
+
type: z18.literal("conflict"),
|
|
1828
2993
|
conflictId: OperationalWorldIdSchema
|
|
1829
2994
|
}).strict(),
|
|
1830
|
-
|
|
1831
|
-
type:
|
|
2995
|
+
z18.object({
|
|
2996
|
+
type: z18.literal("evidence"),
|
|
1832
2997
|
evidenceId: OperationalWorldIdSchema
|
|
1833
2998
|
}).strict(),
|
|
1834
|
-
|
|
2999
|
+
z18.object({ type: z18.literal("source"), bindingId: OperationalWorldIdSchema }).strict()
|
|
1835
3000
|
]);
|
|
1836
|
-
var WorkGraphNodeSchema =
|
|
3001
|
+
var WorkGraphNodeSchema = z18.object({
|
|
1837
3002
|
schemaVersion: OperationalWorldSchemaVersionSchema,
|
|
1838
3003
|
nodeId: OperationalWorldIdSchema,
|
|
1839
3004
|
kind: WorkGraphNodeKindSchema,
|
|
1840
|
-
label:
|
|
1841
|
-
description:
|
|
3005
|
+
label: z18.string().trim().min(1).max(1e3),
|
|
3006
|
+
description: z18.string().trim().max(4e3).optional(),
|
|
1842
3007
|
status: WorkGraphNodeStatusSchema,
|
|
1843
3008
|
authority: WorkGraphNodeAuthoritySchema,
|
|
1844
3009
|
parentNodeId: OperationalWorldIdSchema.optional(),
|
|
1845
|
-
bindingIds:
|
|
1846
|
-
evidenceRefIds:
|
|
3010
|
+
bindingIds: z18.array(OperationalWorldIdSchema).min(1).max(256),
|
|
3011
|
+
evidenceRefIds: z18.array(OperationalWorldIdSchema).min(1).max(256),
|
|
1847
3012
|
confidence: ConfidenceSchema,
|
|
1848
3013
|
revision: OperationalWorldRevisionSchema,
|
|
1849
|
-
validFrom:
|
|
1850
|
-
validTo:
|
|
3014
|
+
validFrom: z18.string().datetime(),
|
|
3015
|
+
validTo: z18.string().datetime().optional(),
|
|
1851
3016
|
scope: OperationalFactScopeSchema,
|
|
1852
|
-
taskEpoch:
|
|
3017
|
+
taskEpoch: z18.number().int().nonnegative().optional(),
|
|
1853
3018
|
metadataProvenance: OperationalMetadataProvenanceSchema,
|
|
1854
3019
|
reference: WorkGraphNodeReferenceSchema.optional(),
|
|
1855
3020
|
actionContract: WorkActionContractSchema.optional(),
|
|
1856
|
-
attributes:
|
|
3021
|
+
attributes: z18.record(z18.string(), JsonValueSchema)
|
|
1857
3022
|
}).strict().superRefine((node, ctx) => {
|
|
1858
3023
|
const expectedReference = node.kind === "claim" ? "claim" : node.kind === "conflict" ? "conflict" : node.kind === "evidence" ? "evidence" : null;
|
|
1859
3024
|
if (expectedReference && node.reference?.type !== expectedReference) {
|
|
@@ -1892,7 +3057,7 @@ var WorkGraphNodeSchema = z16.object({
|
|
|
1892
3057
|
});
|
|
1893
3058
|
}
|
|
1894
3059
|
});
|
|
1895
|
-
var WorkGraphEdgeKindSchema =
|
|
3060
|
+
var WorkGraphEdgeKindSchema = z18.enum([
|
|
1896
3061
|
"contains",
|
|
1897
3062
|
"part_of",
|
|
1898
3063
|
"decomposes_to",
|
|
@@ -1926,22 +3091,22 @@ var WorkGraphEdgeKindSchema = z16.enum([
|
|
|
1926
3091
|
"owned_by",
|
|
1927
3092
|
"relates_to"
|
|
1928
3093
|
]);
|
|
1929
|
-
var WorkGraphEdgeSchema =
|
|
3094
|
+
var WorkGraphEdgeSchema = z18.object({
|
|
1930
3095
|
schemaVersion: OperationalWorldSchemaVersionSchema,
|
|
1931
3096
|
edgeId: OperationalWorldIdSchema,
|
|
1932
3097
|
sourceNodeId: OperationalWorldIdSchema,
|
|
1933
3098
|
targetNodeId: OperationalWorldIdSchema,
|
|
1934
3099
|
kind: WorkGraphEdgeKindSchema,
|
|
1935
|
-
directed:
|
|
1936
|
-
evidenceRefIds:
|
|
3100
|
+
directed: z18.boolean(),
|
|
3101
|
+
evidenceRefIds: z18.array(OperationalWorldIdSchema).min(1).max(256),
|
|
1937
3102
|
confidence: ConfidenceSchema,
|
|
1938
3103
|
revision: OperationalWorldRevisionSchema,
|
|
1939
|
-
validFrom:
|
|
1940
|
-
validTo:
|
|
3104
|
+
validFrom: z18.string().datetime(),
|
|
3105
|
+
validTo: z18.string().datetime().optional(),
|
|
1941
3106
|
scope: OperationalFactScopeSchema,
|
|
1942
|
-
taskEpoch:
|
|
3107
|
+
taskEpoch: z18.number().int().nonnegative().optional(),
|
|
1943
3108
|
metadataProvenance: OperationalMetadataProvenanceSchema,
|
|
1944
|
-
attributes:
|
|
3109
|
+
attributes: z18.record(z18.string(), JsonValueSchema)
|
|
1945
3110
|
}).strict().superRefine((edge, ctx) => {
|
|
1946
3111
|
if (edge.sourceNodeId === edge.targetNodeId) {
|
|
1947
3112
|
ctx.addIssue({
|
|
@@ -2166,68 +3331,68 @@ function validateGraphCollections(value, ctx) {
|
|
|
2166
3331
|
});
|
|
2167
3332
|
});
|
|
2168
3333
|
}
|
|
2169
|
-
var WorkGraphSchema =
|
|
3334
|
+
var WorkGraphSchema = z18.object({
|
|
2170
3335
|
schemaVersion: OperationalWorldSchemaVersionSchema,
|
|
2171
3336
|
graphId: OperationalWorldIdSchema,
|
|
2172
3337
|
revision: OperationalWorldRevisionSchema,
|
|
2173
3338
|
previousRevision: OperationalWorldRevisionSchema.optional(),
|
|
2174
|
-
title:
|
|
2175
|
-
nodes:
|
|
2176
|
-
edges:
|
|
2177
|
-
sourceBindings:
|
|
2178
|
-
evidenceRefs:
|
|
2179
|
-
claims:
|
|
2180
|
-
conflicts:
|
|
2181
|
-
createdAt:
|
|
2182
|
-
updatedAt:
|
|
3339
|
+
title: z18.string().trim().min(1).max(1e3),
|
|
3340
|
+
nodes: z18.array(WorkGraphNodeSchema).max(1e5),
|
|
3341
|
+
edges: z18.array(WorkGraphEdgeSchema).max(25e4),
|
|
3342
|
+
sourceBindings: z18.array(SourceBindingSchema).max(1e5),
|
|
3343
|
+
evidenceRefs: z18.array(EvidenceRefSchema).max(25e4),
|
|
3344
|
+
claims: z18.array(ClaimSchema).max(1e5),
|
|
3345
|
+
conflicts: z18.array(ConflictSchema).max(1e5),
|
|
3346
|
+
createdAt: z18.string().datetime(),
|
|
3347
|
+
updatedAt: z18.string().datetime()
|
|
2183
3348
|
}).strict().superRefine(validateGraphCollections);
|
|
2184
|
-
var WorldPatchOperationSchema =
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
op:
|
|
3349
|
+
var WorldPatchOperationSchema = z18.discriminatedUnion("op", [
|
|
3350
|
+
z18.object({ op: z18.literal("upsert_node"), node: WorkGraphNodeSchema }).strict(),
|
|
3351
|
+
z18.object({
|
|
3352
|
+
op: z18.literal("remove_node"),
|
|
2188
3353
|
nodeId: OperationalWorldIdSchema,
|
|
2189
|
-
cascade:
|
|
3354
|
+
cascade: z18.boolean()
|
|
2190
3355
|
}).strict(),
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
op:
|
|
3356
|
+
z18.object({ op: z18.literal("upsert_edge"), edge: WorkGraphEdgeSchema }).strict(),
|
|
3357
|
+
z18.object({ op: z18.literal("remove_edge"), edgeId: OperationalWorldIdSchema }).strict(),
|
|
3358
|
+
z18.object({
|
|
3359
|
+
op: z18.literal("upsert_source_binding"),
|
|
2195
3360
|
sourceBinding: SourceBindingSchema
|
|
2196
3361
|
}).strict(),
|
|
2197
|
-
|
|
2198
|
-
op:
|
|
3362
|
+
z18.object({
|
|
3363
|
+
op: z18.literal("remove_source_binding"),
|
|
2199
3364
|
bindingId: OperationalWorldIdSchema
|
|
2200
3365
|
}).strict(),
|
|
2201
|
-
|
|
2202
|
-
op:
|
|
3366
|
+
z18.object({
|
|
3367
|
+
op: z18.literal("upsert_evidence_ref"),
|
|
2203
3368
|
evidenceRef: EvidenceRefSchema
|
|
2204
3369
|
}).strict(),
|
|
2205
|
-
|
|
2206
|
-
op:
|
|
3370
|
+
z18.object({
|
|
3371
|
+
op: z18.literal("remove_evidence_ref"),
|
|
2207
3372
|
evidenceId: OperationalWorldIdSchema
|
|
2208
3373
|
}).strict(),
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
op:
|
|
3374
|
+
z18.object({ op: z18.literal("upsert_claim"), claim: ClaimSchema }).strict(),
|
|
3375
|
+
z18.object({
|
|
3376
|
+
op: z18.literal("remove_claim"),
|
|
2212
3377
|
claimId: OperationalWorldIdSchema
|
|
2213
3378
|
}).strict(),
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
op:
|
|
3379
|
+
z18.object({ op: z18.literal("upsert_conflict"), conflict: ConflictSchema }).strict(),
|
|
3380
|
+
z18.object({
|
|
3381
|
+
op: z18.literal("remove_conflict"),
|
|
2217
3382
|
conflictId: OperationalWorldIdSchema
|
|
2218
3383
|
}).strict()
|
|
2219
3384
|
]);
|
|
2220
|
-
var WorldPatchSchema =
|
|
3385
|
+
var WorldPatchSchema = z18.object({
|
|
2221
3386
|
schemaVersion: OperationalWorldSchemaVersionSchema,
|
|
2222
3387
|
patchId: OperationalWorldIdSchema,
|
|
2223
3388
|
graphId: OperationalWorldIdSchema,
|
|
2224
3389
|
/** Optimistic-concurrency precondition. */
|
|
2225
3390
|
baseRevision: OperationalWorldRevisionSchema,
|
|
2226
3391
|
targetRevision: OperationalWorldRevisionSchema,
|
|
2227
|
-
operations:
|
|
2228
|
-
rationale:
|
|
2229
|
-
createdBy:
|
|
2230
|
-
createdAt:
|
|
3392
|
+
operations: z18.array(WorldPatchOperationSchema).min(1).max(1e4),
|
|
3393
|
+
rationale: z18.string().trim().min(1).max(4e3),
|
|
3394
|
+
createdBy: z18.string().trim().min(1).max(256),
|
|
3395
|
+
createdAt: z18.string().datetime()
|
|
2231
3396
|
}).strict().superRefine((patch, ctx) => {
|
|
2232
3397
|
if (patch.baseRevision === patch.targetRevision) {
|
|
2233
3398
|
ctx.addIssue({
|
|
@@ -2237,31 +3402,31 @@ var WorldPatchSchema = z16.object({
|
|
|
2237
3402
|
});
|
|
2238
3403
|
}
|
|
2239
3404
|
});
|
|
2240
|
-
var ValidationIssueSeveritySchema =
|
|
3405
|
+
var ValidationIssueSeveritySchema = z18.enum([
|
|
2241
3406
|
"info",
|
|
2242
3407
|
"warning",
|
|
2243
3408
|
"error"
|
|
2244
3409
|
]);
|
|
2245
|
-
var OperationalValidationIssueSchema =
|
|
2246
|
-
code:
|
|
3410
|
+
var OperationalValidationIssueSchema = z18.object({
|
|
3411
|
+
code: z18.string().trim().min(1).max(128),
|
|
2247
3412
|
severity: ValidationIssueSeveritySchema,
|
|
2248
|
-
message:
|
|
2249
|
-
path:
|
|
3413
|
+
message: z18.string().trim().min(1).max(4e3),
|
|
3414
|
+
path: z18.array(z18.union([z18.string(), z18.number().int().nonnegative()])).max(64),
|
|
2250
3415
|
nodeId: OperationalWorldIdSchema.optional(),
|
|
2251
|
-
evidenceRefIds:
|
|
3416
|
+
evidenceRefIds: z18.array(OperationalWorldIdSchema).max(256)
|
|
2252
3417
|
}).strict();
|
|
2253
|
-
var OperationalValidationStatusSchema =
|
|
3418
|
+
var OperationalValidationStatusSchema = z18.enum([
|
|
2254
3419
|
"pass",
|
|
2255
3420
|
"fail",
|
|
2256
3421
|
"partial"
|
|
2257
3422
|
]);
|
|
2258
|
-
var OperationalValidationResultSchema =
|
|
3423
|
+
var OperationalValidationResultSchema = z18.object({
|
|
2259
3424
|
schemaVersion: OperationalWorldSchemaVersionSchema,
|
|
2260
|
-
valid:
|
|
3425
|
+
valid: z18.boolean(),
|
|
2261
3426
|
status: OperationalValidationStatusSchema,
|
|
2262
3427
|
checkedRevision: OperationalWorldRevisionSchema,
|
|
2263
|
-
issues:
|
|
2264
|
-
checkedAt:
|
|
3428
|
+
issues: z18.array(OperationalValidationIssueSchema).max(1e4),
|
|
3429
|
+
checkedAt: z18.string().datetime()
|
|
2265
3430
|
}).strict().superRefine((result, ctx) => {
|
|
2266
3431
|
const hasErrors = result.issues.some((issue) => issue.severity === "error");
|
|
2267
3432
|
if (result.valid !== (result.status === "pass")) {
|
|
@@ -2286,27 +3451,27 @@ var OperationalValidationResultSchema = z16.object({
|
|
|
2286
3451
|
});
|
|
2287
3452
|
}
|
|
2288
3453
|
});
|
|
2289
|
-
var ValidationArtifactHashSchema =
|
|
2290
|
-
uri:
|
|
2291
|
-
algorithm:
|
|
2292
|
-
digest:
|
|
3454
|
+
var ValidationArtifactHashSchema = z18.object({
|
|
3455
|
+
uri: z18.string().trim().min(1).max(4096),
|
|
3456
|
+
algorithm: z18.enum(["sha256", "sha512", "blake3"]),
|
|
3457
|
+
digest: z18.string().trim().min(1).max(512)
|
|
2293
3458
|
}).strict();
|
|
2294
|
-
var OperationalValidationReceiptSchema =
|
|
3459
|
+
var OperationalValidationReceiptSchema = z18.object({
|
|
2295
3460
|
schemaVersion: OperationalWorldSchemaVersionSchema,
|
|
2296
3461
|
receiptId: OperationalWorldIdSchema,
|
|
2297
3462
|
graphId: OperationalWorldIdSchema,
|
|
2298
3463
|
patchId: OperationalWorldIdSchema.optional(),
|
|
2299
3464
|
baseRevision: OperationalWorldRevisionSchema,
|
|
2300
3465
|
resultRevision: OperationalWorldRevisionSchema,
|
|
2301
|
-
validator:
|
|
2302
|
-
name:
|
|
2303
|
-
version:
|
|
3466
|
+
validator: z18.object({
|
|
3467
|
+
name: z18.string().trim().min(1).max(256),
|
|
3468
|
+
version: z18.string().trim().min(1).max(128)
|
|
2304
3469
|
}).strict(),
|
|
2305
|
-
startedAt:
|
|
2306
|
-
finishedAt:
|
|
3470
|
+
startedAt: z18.string().datetime(),
|
|
3471
|
+
finishedAt: z18.string().datetime(),
|
|
2307
3472
|
result: OperationalValidationResultSchema,
|
|
2308
|
-
evidenceRefIds:
|
|
2309
|
-
artifactHashes:
|
|
3473
|
+
evidenceRefIds: z18.array(OperationalWorldIdSchema).max(1e4),
|
|
3474
|
+
artifactHashes: z18.array(ValidationArtifactHashSchema).max(1e4)
|
|
2310
3475
|
}).strict().superRefine((receipt, ctx) => {
|
|
2311
3476
|
if (receipt.result.checkedRevision !== receipt.resultRevision) {
|
|
2312
3477
|
ctx.addIssue({
|
|
@@ -2323,29 +3488,29 @@ var OperationalValidationReceiptSchema = z16.object({
|
|
|
2323
3488
|
});
|
|
2324
3489
|
}
|
|
2325
3490
|
});
|
|
2326
|
-
var ReasoningSliceSelectionSchema =
|
|
2327
|
-
strategy:
|
|
2328
|
-
graphHops:
|
|
2329
|
-
maxCharacters:
|
|
2330
|
-
truncated:
|
|
2331
|
-
omissions:
|
|
2332
|
-
evidenceRoles:
|
|
3491
|
+
var ReasoningSliceSelectionSchema = z18.object({
|
|
3492
|
+
strategy: z18.enum(["exact", "lexical", "semantic", "graph", "hybrid"]),
|
|
3493
|
+
graphHops: z18.number().int().nonnegative().max(32),
|
|
3494
|
+
maxCharacters: z18.number().int().positive(),
|
|
3495
|
+
truncated: z18.boolean(),
|
|
3496
|
+
omissions: z18.array(z18.string().trim().min(1).max(1e3)).max(256),
|
|
3497
|
+
evidenceRoles: z18.array(EvidenceRoleSchema).max(5)
|
|
2333
3498
|
}).strict();
|
|
2334
|
-
var ReasoningSliceSchema =
|
|
3499
|
+
var ReasoningSliceSchema = z18.object({
|
|
2335
3500
|
schemaVersion: OperationalWorldSchemaVersionSchema,
|
|
2336
3501
|
sliceId: OperationalWorldIdSchema,
|
|
2337
3502
|
graphId: OperationalWorldIdSchema,
|
|
2338
3503
|
revision: OperationalWorldRevisionSchema,
|
|
2339
|
-
objective:
|
|
2340
|
-
focusNodeIds:
|
|
2341
|
-
nodes:
|
|
2342
|
-
edges:
|
|
2343
|
-
sourceBindings:
|
|
2344
|
-
evidenceRefs:
|
|
2345
|
-
claims:
|
|
2346
|
-
conflicts:
|
|
3504
|
+
objective: z18.string().trim().min(1).max(4e3),
|
|
3505
|
+
focusNodeIds: z18.array(OperationalWorldIdSchema).min(1).max(256),
|
|
3506
|
+
nodes: z18.array(WorkGraphNodeSchema).max(1e4),
|
|
3507
|
+
edges: z18.array(WorkGraphEdgeSchema).max(25e3),
|
|
3508
|
+
sourceBindings: z18.array(SourceBindingSchema).max(1e4),
|
|
3509
|
+
evidenceRefs: z18.array(EvidenceRefSchema).max(25e3),
|
|
3510
|
+
claims: z18.array(ClaimSchema).max(1e4),
|
|
3511
|
+
conflicts: z18.array(ConflictSchema).max(1e4),
|
|
2347
3512
|
selection: ReasoningSliceSelectionSchema,
|
|
2348
|
-
generatedAt:
|
|
3513
|
+
generatedAt: z18.string().datetime()
|
|
2349
3514
|
}).strict().superRefine((slice, ctx) => {
|
|
2350
3515
|
validateGraphCollections(slice, ctx);
|
|
2351
3516
|
const nodeIds = new Set(slice.nodes.map((node) => node.nodeId));
|
|
@@ -2662,12 +3827,12 @@ var DEFAULT_CONFIG2 = {
|
|
|
2662
3827
|
function extractQueryEntities(query) {
|
|
2663
3828
|
const entities = [];
|
|
2664
3829
|
const seen = /* @__PURE__ */ new Set();
|
|
2665
|
-
const add = (
|
|
2666
|
-
const normalized =
|
|
3830
|
+
const add = (text3) => {
|
|
3831
|
+
const normalized = text3.trim().toLowerCase();
|
|
2667
3832
|
if (normalized.length < 2 || seen.has(normalized))
|
|
2668
3833
|
return;
|
|
2669
3834
|
seen.add(normalized);
|
|
2670
|
-
entities.push(
|
|
3835
|
+
entities.push(text3.trim());
|
|
2671
3836
|
};
|
|
2672
3837
|
const filePattern = /(?:[\w./-]+\/[\w./-]+|[\w-]+\.\w{1,5})\b/g;
|
|
2673
3838
|
for (const match of query.matchAll(filePattern)) {
|
|
@@ -3360,13 +4525,13 @@ var EpisodeStore = class {
|
|
|
3360
4525
|
}
|
|
3361
4526
|
return true;
|
|
3362
4527
|
}
|
|
3363
|
-
recordRetrieved(episodes,
|
|
4528
|
+
recordRetrieved(episodes, timestamp2) {
|
|
3364
4529
|
if (episodes.length === 0)
|
|
3365
4530
|
return;
|
|
3366
4531
|
const updateStmt = this.db.prepare("UPDATE episodes SET strength = strength + 1, last_retrieved = ? WHERE id = ?");
|
|
3367
4532
|
const updateAll = this.db.transaction(() => {
|
|
3368
4533
|
for (const episode of episodes)
|
|
3369
|
-
updateStmt.run(
|
|
4534
|
+
updateStmt.run(timestamp2, episode.id);
|
|
3370
4535
|
});
|
|
3371
4536
|
updateAll();
|
|
3372
4537
|
}
|
|
@@ -3914,8 +5079,8 @@ var CRLEncoder = class {
|
|
|
3914
5079
|
/**
|
|
3915
5080
|
* Encode natural language text to CRL
|
|
3916
5081
|
*/
|
|
3917
|
-
encode(
|
|
3918
|
-
let result = this.compress(
|
|
5082
|
+
encode(text3) {
|
|
5083
|
+
let result = this.compress(text3);
|
|
3919
5084
|
const concepts = this.extractConcepts(result);
|
|
3920
5085
|
const relations = this.extractRelations(result, concepts);
|
|
3921
5086
|
if (relations.length > 0) {
|
|
@@ -3926,11 +5091,11 @@ var CRLEncoder = class {
|
|
|
3926
5091
|
/**
|
|
3927
5092
|
* Extract key concepts from text
|
|
3928
5093
|
*/
|
|
3929
|
-
extractConcepts(
|
|
5094
|
+
extractConcepts(text3) {
|
|
3930
5095
|
const concepts = [];
|
|
3931
5096
|
const conceptPattern = /\[([^\]]+)\]/g;
|
|
3932
5097
|
let match;
|
|
3933
|
-
while ((match = conceptPattern.exec(
|
|
5098
|
+
while ((match = conceptPattern.exec(text3)) !== null) {
|
|
3934
5099
|
concepts.push({
|
|
3935
5100
|
type: "concept",
|
|
3936
5101
|
name: match[1],
|
|
@@ -3939,7 +5104,7 @@ var CRLEncoder = class {
|
|
|
3939
5104
|
});
|
|
3940
5105
|
}
|
|
3941
5106
|
const implicitPattern = /\b([A-Z][a-z]+(?:_[A-Z][a-z]+)*)\b/g;
|
|
3942
|
-
while ((match = implicitPattern.exec(
|
|
5107
|
+
while ((match = implicitPattern.exec(text3)) !== null) {
|
|
3943
5108
|
if (!concepts.find((c) => c.name === match[1])) {
|
|
3944
5109
|
concepts.push({
|
|
3945
5110
|
type: "concept",
|
|
@@ -3954,11 +5119,11 @@ var CRLEncoder = class {
|
|
|
3954
5119
|
/**
|
|
3955
5120
|
* Extract relations between concepts
|
|
3956
5121
|
*/
|
|
3957
|
-
extractRelations(
|
|
5122
|
+
extractRelations(text3, concepts) {
|
|
3958
5123
|
const relations = [];
|
|
3959
5124
|
const relationPattern = /\[([^\]]+)\]\s*(→|↔|∴|∵|⇒|⇐)(?::(\w+))?\s*(?:→)?\s*\[([^\]]+)\]/g;
|
|
3960
5125
|
let match;
|
|
3961
|
-
while ((match = relationPattern.exec(
|
|
5126
|
+
while ((match = relationPattern.exec(text3)) !== null) {
|
|
3962
5127
|
const from = concepts.find((c) => c.name === match[1]);
|
|
3963
5128
|
const to = concepts.find((c) => c.name === match[4]);
|
|
3964
5129
|
if (from && to) {
|
|
@@ -4002,7 +5167,7 @@ var CRLEncoder = class {
|
|
|
4002
5167
|
/**
|
|
4003
5168
|
* Compress text using CRL patterns
|
|
4004
5169
|
*/
|
|
4005
|
-
compress(
|
|
5170
|
+
compress(text3) {
|
|
4006
5171
|
const replacements = [
|
|
4007
5172
|
[/therefore/gi, "∴"],
|
|
4008
5173
|
[/because/gi, "∵"],
|
|
@@ -4019,7 +5184,7 @@ var CRLEncoder = class {
|
|
|
4019
5184
|
[/fixes/gi, "→:fixes"],
|
|
4020
5185
|
[/relates to/gi, "∩"]
|
|
4021
5186
|
];
|
|
4022
|
-
let result =
|
|
5187
|
+
let result = text3;
|
|
4023
5188
|
for (const [pattern, replacement] of replacements) {
|
|
4024
5189
|
result = result.replace(pattern, replacement);
|
|
4025
5190
|
}
|
|
@@ -4172,7 +5337,7 @@ var CRLDecoder = class {
|
|
|
4172
5337
|
/**
|
|
4173
5338
|
* Expand CRL symbols to natural language
|
|
4174
5339
|
*/
|
|
4175
|
-
expand(
|
|
5340
|
+
expand(text3) {
|
|
4176
5341
|
const expansions = {
|
|
4177
5342
|
"∴": "therefore",
|
|
4178
5343
|
"∵": "because",
|
|
@@ -4198,7 +5363,7 @@ var CRLDecoder = class {
|
|
|
4198
5363
|
"∃": "there exists",
|
|
4199
5364
|
"∄": "there does not exist"
|
|
4200
5365
|
};
|
|
4201
|
-
let result =
|
|
5366
|
+
let result = text3;
|
|
4202
5367
|
for (const [symbol, expansion] of Object.entries(expansions)) {
|
|
4203
5368
|
result = result.replace(new RegExp(`(^|[.!?]\\s*)${symbol}`, "g"), (match, prefix) => {
|
|
4204
5369
|
const capitalized = expansion.charAt(0).toUpperCase() + expansion.slice(1);
|
|
@@ -4252,8 +5417,8 @@ var CRL = {
|
|
|
4252
5417
|
/**
|
|
4253
5418
|
* Quick encode: natural language → CRL
|
|
4254
5419
|
*/
|
|
4255
|
-
encode(
|
|
4256
|
-
return this.encoder.encode(
|
|
5420
|
+
encode(text3) {
|
|
5421
|
+
return this.encoder.encode(text3);
|
|
4257
5422
|
},
|
|
4258
5423
|
/**
|
|
4259
5424
|
* Quick decode: CRL → natural language
|
|
@@ -4264,14 +5429,14 @@ var CRL = {
|
|
|
4264
5429
|
/**
|
|
4265
5430
|
* Quick compress: replace common patterns with symbols
|
|
4266
5431
|
*/
|
|
4267
|
-
compress(
|
|
4268
|
-
return this.encoder.compress(
|
|
5432
|
+
compress(text3) {
|
|
5433
|
+
return this.encoder.compress(text3);
|
|
4269
5434
|
},
|
|
4270
5435
|
/**
|
|
4271
5436
|
* Quick expand: replace symbols with natural language
|
|
4272
5437
|
*/
|
|
4273
|
-
expand(
|
|
4274
|
-
return this.decoder.expand(
|
|
5438
|
+
expand(text3) {
|
|
5439
|
+
return this.decoder.expand(text3);
|
|
4275
5440
|
},
|
|
4276
5441
|
/**
|
|
4277
5442
|
* Resolve templates with context
|
|
@@ -5068,9 +6233,9 @@ function loadEpisodeCandidates(db, limit) {
|
|
|
5068
6233
|
}
|
|
5069
6234
|
}
|
|
5070
6235
|
function deleteEpisodes(db, ids, dryRun) {
|
|
5071
|
-
const
|
|
5072
|
-
if (dryRun ||
|
|
5073
|
-
return
|
|
6236
|
+
const unique2 = [...new Set(ids)].filter(Boolean);
|
|
6237
|
+
if (dryRun || unique2.length === 0)
|
|
6238
|
+
return unique2.length;
|
|
5074
6239
|
let deleted = 0;
|
|
5075
6240
|
const stmt = db.prepare(`DELETE FROM episodes WHERE id = ?`);
|
|
5076
6241
|
const tx = db.transaction((rows) => {
|
|
@@ -5079,7 +6244,7 @@ function deleteEpisodes(db, ids, dryRun) {
|
|
|
5079
6244
|
deleted += Number(result.changes ?? 0);
|
|
5080
6245
|
}
|
|
5081
6246
|
});
|
|
5082
|
-
tx(
|
|
6247
|
+
tx(unique2);
|
|
5083
6248
|
return deleted;
|
|
5084
6249
|
}
|
|
5085
6250
|
function maintainGraph(dbPath, options, shouldStop) {
|
|
@@ -5183,7 +6348,7 @@ function vectorDuplicateNodePairs(rows, threshold) {
|
|
|
5183
6348
|
}
|
|
5184
6349
|
function mergeGraphNodes(db, pairs, dryRun) {
|
|
5185
6350
|
const seen = /* @__PURE__ */ new Set();
|
|
5186
|
-
const
|
|
6351
|
+
const unique2 = pairs.filter((pair) => {
|
|
5187
6352
|
if (!pair.keepId || !pair.dropId || pair.keepId === pair.dropId)
|
|
5188
6353
|
return false;
|
|
5189
6354
|
if (seen.has(pair.dropId))
|
|
@@ -5191,8 +6356,8 @@ function mergeGraphNodes(db, pairs, dryRun) {
|
|
|
5191
6356
|
seen.add(pair.dropId);
|
|
5192
6357
|
return true;
|
|
5193
6358
|
});
|
|
5194
|
-
if (dryRun ||
|
|
5195
|
-
return
|
|
6359
|
+
if (dryRun || unique2.length === 0)
|
|
6360
|
+
return unique2.length;
|
|
5196
6361
|
let merged = 0;
|
|
5197
6362
|
const tx = db.transaction((rows) => {
|
|
5198
6363
|
const src = db.prepare(`UPDATE kg_edges SET src_id = ? WHERE src_id = ?`);
|
|
@@ -5210,7 +6375,7 @@ function mergeGraphNodes(db, pairs, dryRun) {
|
|
|
5210
6375
|
merged += Number(deleted.changes ?? 0);
|
|
5211
6376
|
}
|
|
5212
6377
|
});
|
|
5213
|
-
tx(
|
|
6378
|
+
tx(unique2);
|
|
5214
6379
|
return merged;
|
|
5215
6380
|
}
|
|
5216
6381
|
function dedupeGraphEdges(db, limit, dryRun) {
|
|
@@ -5486,9 +6651,9 @@ function graphNodeScore(row) {
|
|
|
5486
6651
|
const recency = Math.exp(-age / (30 * DAY));
|
|
5487
6652
|
return Math.log1p(Math.max(0, row.mentionCount)) * 0.7 + recency * 0.3;
|
|
5488
6653
|
}
|
|
5489
|
-
function vectorFor(rawEmbedding,
|
|
6654
|
+
function vectorFor(rawEmbedding, text3) {
|
|
5490
6655
|
const decoded = decodeEmbedding(rawEmbedding);
|
|
5491
|
-
return decoded ?? hashEmbedding(
|
|
6656
|
+
return decoded ?? hashEmbedding(text3);
|
|
5492
6657
|
}
|
|
5493
6658
|
function decodeEmbedding(raw) {
|
|
5494
6659
|
if (!raw)
|
|
@@ -5509,10 +6674,10 @@ function decodeEmbedding(raw) {
|
|
|
5509
6674
|
}
|
|
5510
6675
|
return null;
|
|
5511
6676
|
}
|
|
5512
|
-
function hashEmbedding(
|
|
6677
|
+
function hashEmbedding(text3, dimensions = 256) {
|
|
5513
6678
|
const dim = Math.max(16, dimensions);
|
|
5514
6679
|
const vector = new Array(dim).fill(0);
|
|
5515
|
-
const tokens =
|
|
6680
|
+
const tokens = text3.toLowerCase().split(/[^\p{L}\p{N}_./-]+/u).map((token) => token.trim()).filter(Boolean);
|
|
5516
6681
|
const features = [...tokens];
|
|
5517
6682
|
for (let i = 0; i < tokens.length - 1; i++) {
|
|
5518
6683
|
features.push(`${tokens[i]} ${tokens[i + 1]}`);
|
|
@@ -5581,8 +6746,8 @@ function vacuum(db) {
|
|
|
5581
6746
|
import { join as join3 } from "node:path";
|
|
5582
6747
|
|
|
5583
6748
|
// packages/cli/src/tui/commands/kg-prune-inference.ts
|
|
5584
|
-
function truncate(
|
|
5585
|
-
const clean =
|
|
6749
|
+
function truncate(text3, max) {
|
|
6750
|
+
const clean = text3.replace(/\s+/g, " ").trim();
|
|
5586
6751
|
return clean.length > max ? clean.slice(0, max - 1) + "…" : clean;
|
|
5587
6752
|
}
|
|
5588
6753
|
async function classifySignalNodes(candidates, cfg) {
|