@citeark/agent 0.3.20
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/LICENSE +202 -0
- package/README.md +128 -0
- package/data/dataset-source-registry.v1.json +300 -0
- package/dist/arkgraph/boot.js +6 -0
- package/dist/arkgraph/index.html +1 -0
- package/dist/arkgraph/viewer.css +1 -0
- package/dist/arkgraph/viewer.en.css +1 -0
- package/dist/arkgraph/viewer.en.js +49 -0
- package/dist/arkgraph/viewer.en.js.LEGAL.txt +56 -0
- package/dist/arkgraph/viewer.js +49 -0
- package/dist/arkgraph/viewer.js.LEGAL.txt +56 -0
- package/docker/claude-code/Dockerfile +97 -0
- package/docker/claude-code/codex-pro-relay.mjs +466 -0
- package/docker/claude-code/runtime-contract-check.mjs +79 -0
- package/docs/arkgraph-reading.md +79 -0
- package/docs/configuration.md +100 -0
- package/docs/integration.md +92 -0
- package/docs/maturity-plan.md +27 -0
- package/docs/npm-release.md +44 -0
- package/docs/paper-reading.md +40 -0
- package/docs/research-plan-granularity.md +27 -0
- package/docs/terminal.md +49 -0
- package/examples/toy-evaluation/compile-task.json +27 -0
- package/examples/toy-evaluation/paper.md +5 -0
- package/examples/toy-evaluation/repository/README.md +9 -0
- package/examples/toy-evaluation/repository/checkpoint.json +4 -0
- package/examples/toy-evaluation/repository/evaluate.py +17 -0
- package/examples/toy-evaluation/task.json +81 -0
- package/package.json +59 -0
- package/prompts/compile-research.md +58 -0
- package/prompts/execute-contract.md +72 -0
- package/prompts/execute-workspace-simple.md +51 -0
- package/prompts/execute-workspace.md +34 -0
- package/prompts/prepare-reproduction.md +82 -0
- package/prompts/repair-research.md +45 -0
- package/protocol/CAP.md +129 -0
- package/protocol/LICENSE +12 -0
- package/protocol/MAPPINGS.md +72 -0
- package/protocol/README.md +38 -0
- package/protocol/conformance-v2.0-alpha.1.json +36 -0
- package/protocol/examples/arkgraph/checkpoint-evaluation.json +309 -0
- package/protocol/examples/arkgraph/fixtures.mjs +49 -0
- package/protocol/examples/arkgraph/paper-free.json +291 -0
- package/protocol/examples/arkgraph/partial-failure.json +344 -0
- package/protocol/examples/arkgraph/training-evaluation.json +443 -0
- package/protocol/profiles/agent-trace.md +16 -0
- package/protocol/profiles/computational-run.md +16 -0
- package/protocol/profiles/core.md +15 -0
- package/protocol/profiles/public-bundle.md +18 -0
- package/protocol/profiles/reproduction.md +29 -0
- package/protocol/profiles/research-compilation.md +44 -0
- package/protocol/profiles/research-plan.md +39 -0
- package/protocol/profiles/restricted-evidence.md +15 -0
- package/runtime/bootstrap-autodl-runtime.sh +314 -0
- package/runtime/create-runtime-venv.sh +41 -0
- package/runtime/install-local-cpu-runtime.sh +23 -0
- package/runtime/install-scientific-runtime.sh +153 -0
- package/runtime/mineru/parse.py +62 -0
- package/runtime/mineru/requirements.txt +4 -0
- package/runtime/requirements-baseline.txt +38 -0
- package/schemas/cap/v2/activity.schema.json +47 -0
- package/schemas/cap/v2/agent.schema.json +32 -0
- package/schemas/cap/v2/assertion.schema.json +110 -0
- package/schemas/cap/v2/descriptor.schema.json +243 -0
- package/schemas/cap/v2/entity.schema.json +64 -0
- package/schemas/cap/v2/manifest.schema.json +67 -0
- package/schemas/cap/v2/relation.schema.json +82 -0
- package/schemas/compute-catalog.schema.json +63 -0
- package/schemas/compute-decision.schema.json +27 -0
- package/schemas/execution-contract.schema.json +1024 -0
- package/schemas/research-card.schema.json +30 -0
- package/schemas/research-inventory-draft.schema.json +366 -0
- package/schemas/research.schema.json +1044 -0
- package/schemas/result.schema.json +173 -0
- package/schemas/verification-policy.schema.json +47 -0
- package/schemas/verified-conclusion.schema.json +58 -0
- package/schemas/workspace-summary.schema.json +24 -0
- package/scripts/build-arkgraph-view.mjs +12 -0
- package/scripts/check-execution-feasibility.mjs +24 -0
- package/scripts/check-syntax.mjs +15 -0
- package/scripts/deterministic-asset-preparation.py +438 -0
- package/scripts/package-cap.mjs +23 -0
- package/scripts/package-local-agent.mjs +23 -0
- package/scripts/preview-arkgraph.mjs +25 -0
- package/scripts/replay-research-compiler-candidate.mjs +134 -0
- package/scripts/review-compiler-sources.mjs +44 -0
- package/scripts/run-asset-preparation.sh +17 -0
- package/scripts/run-research-plan.mjs +98 -0
- package/scripts/validate-asset-preparation.py +290 -0
- package/scripts/verify-local-runtime.mjs +57 -0
- package/scripts/verify-npm-package.mjs +57 -0
- package/src/adapters/paper2agent.mjs +107 -0
- package/src/assets/cache.mjs +159 -0
- package/src/assets/compute.mjs +98 -0
- package/src/assets/executor.mjs +145 -0
- package/src/assets/lifecycle.mjs +213 -0
- package/src/assets/manifest.mjs +242 -0
- package/src/assets/opportunistic-preparation.mjs +81 -0
- package/src/assets/plan.mjs +411 -0
- package/src/assets/prompts.mjs +29 -0
- package/src/assets/public-asset-probe.mjs +525 -0
- package/src/assets/qualification.mjs +119 -0
- package/src/assets/readiness.mjs +130 -0
- package/src/assets/reproduction-admission.mjs +355 -0
- package/src/assets/requirements.mjs +152 -0
- package/src/assets/source-grounding.mjs +341 -0
- package/src/assets/source-policy.mjs +118 -0
- package/src/autodl/client.mjs +260 -0
- package/src/autodl/ssh.mjs +380 -0
- package/src/autodl/tools.mjs +129 -0
- package/src/cap/redaction.mjs +38 -0
- package/src/cap/v2/archive.mjs +152 -0
- package/src/cap/v2/attestation.mjs +204 -0
- package/src/cap/v2/canonical-json.mjs +114 -0
- package/src/cap/v2/compilation-artifact.mjs +240 -0
- package/src/cap/v2/core.mjs +282 -0
- package/src/cap/v2/measurement-assessment-records.mjs +23 -0
- package/src/cap/v2/pipeline-artifact.mjs +922 -0
- package/src/cap/v2/read.mjs +41 -0
- package/src/cap/v2/reassessment-artifact.mjs +383 -0
- package/src/cap/v2/research-artifact.mjs +231 -0
- package/src/cap/v2/research-map-records.mjs +46 -0
- package/src/cap/v2/research-object-records.mjs +163 -0
- package/src/cap/v2/research-records.mjs +187 -0
- package/src/cap/v2/verify.mjs +642 -0
- package/src/cli.mjs +1146 -0
- package/src/compute/autodl-pro-compiler.mjs +347 -0
- package/src/compute/autodl-pro-executor.mjs +459 -0
- package/src/compute/autodl-pro-job.mjs +843 -0
- package/src/compute/autodl-pro-network.mjs +295 -0
- package/src/compute/autodl-pro-remote.mjs +810 -0
- package/src/compute/autodl-pro-staging.mjs +117 -0
- package/src/compute/campaign.mjs +110 -0
- package/src/compute/catalog.mjs +123 -0
- package/src/compute/checkpoint-protocol.mjs +154 -0
- package/src/compute/codex-account-lock.mjs +111 -0
- package/src/compute/codex-account-session.mjs +107 -0
- package/src/compute/compiler-profile.mjs +38 -0
- package/src/compute/compiler-router.mjs +23 -0
- package/src/compute/coordinator-recovery.mjs +210 -0
- package/src/compute/executor-router.mjs +29 -0
- package/src/compute/gcp-batch-compiler.mjs +685 -0
- package/src/compute/gcp-batch-executor.mjs +1215 -0
- package/src/compute/gcp-batch-failure.mjs +92 -0
- package/src/compute/gcp-batch-job.mjs +527 -0
- package/src/compute/gcp-batch-lifecycle.mjs +81 -0
- package/src/compute/gcp-checkpoint-worker.mjs +1633 -0
- package/src/compute/local-codex-compiler.mjs +52 -0
- package/src/compute/measurement-hardware.mjs +128 -0
- package/src/compute/remote-attempt.mjs +226 -0
- package/src/compute/requirements.mjs +124 -0
- package/src/compute/research-phases.mjs +48 -0
- package/src/compute/scheduler.mjs +452 -0
- package/src/compute/shared-workloads.mjs +26 -0
- package/src/compute/stage-archive.mjs +79 -0
- package/src/contracts/campaign-contract.mjs +52 -0
- package/src/contracts/execution-contract.mjs +819 -0
- package/src/contracts/execution-mode.mjs +19 -0
- package/src/contracts/execution-timeouts.mjs +45 -0
- package/src/contracts/execution-workload.mjs +68 -0
- package/src/contracts/preflight-schema.mjs +25 -0
- package/src/contracts/public-contract.mjs +63 -0
- package/src/contracts/subject-tags.mjs +31 -0
- package/src/dashboard/data.mjs +898 -0
- package/src/dashboard/server.mjs +79 -0
- package/src/dashboard/static/dashboard.css +366 -0
- package/src/dashboard/static/dashboard.js +560 -0
- package/src/dashboard/static/index.html +85 -0
- package/src/deployment/community-policy.mjs +9 -0
- package/src/deployment/environment.mjs +112 -0
- package/src/deployment/guided.mjs +98 -0
- package/src/deployment/handoff.mjs +102 -0
- package/src/deployment/local-contract.mjs +31 -0
- package/src/deployment/local.mjs +100 -0
- package/src/deployment/prepare.mjs +46 -0
- package/src/deployment/recipe.mjs +108 -0
- package/src/deployment/supplement.mjs +51 -0
- package/src/deployment/terminal.mjs +43 -0
- package/src/diagnosis/renderer.mjs +75 -0
- package/src/diagnosis/target-failure.mjs +46 -0
- package/src/evidence/parser-registry.mjs +54 -0
- package/src/evidence/parsers/fasttext-classification.mjs +82 -0
- package/src/evidence/parsers/json-scalar.mjs +96 -0
- package/src/evidence/parsers/simcse-senteval.mjs +104 -0
- package/src/evidence/parsers/starspace-classification.mjs +78 -0
- package/src/evidence/registry.mjs +147 -0
- package/src/execution/runner-audit.mjs +473 -0
- package/src/gcp/auth.mjs +106 -0
- package/src/gcp/batch-client.mjs +120 -0
- package/src/gcp/resource-discovery.mjs +177 -0
- package/src/gcp/rest.mjs +82 -0
- package/src/gcp/secret-manager.mjs +34 -0
- package/src/gcp/signed-url.mjs +133 -0
- package/src/gcp/storage.mjs +220 -0
- package/src/graph/command.mjs +41 -0
- package/src/graph/execution.mjs +97 -0
- package/src/graph/model.mjs +37 -0
- package/src/graph/presentation.mjs +110 -0
- package/src/graph/query.mjs +159 -0
- package/src/graph/research-relations.mjs +69 -0
- package/src/graph/source-page.mjs +12 -0
- package/src/graph/source-preview.mjs +34 -0
- package/src/graph/validate.mjs +76 -0
- package/src/job.mjs +496 -0
- package/src/network/autodl-routing-proxy.mjs +462 -0
- package/src/network/egress-proxy.mjs +158 -0
- package/src/observability/event-contract.mjs +230 -0
- package/src/observability/pipeline-monitor.mjs +166 -0
- package/src/pipeline/orchestrator.mjs +1281 -0
- package/src/pipeline/recovery-error.mjs +11 -0
- package/src/pipeline/replay.mjs +304 -0
- package/src/pipeline/shared-execution.mjs +115 -0
- package/src/pipeline/stage-checkpoint.mjs +86 -0
- package/src/pipeline/stage-recovery.mjs +101 -0
- package/src/pipeline/targets.mjs +110 -0
- package/src/process.mjs +143 -0
- package/src/protocol.mjs +312 -0
- package/src/provider/codex-account.mjs +44 -0
- package/src/provider/codex-completion.mjs +49 -0
- package/src/provider/completion.mjs +292 -0
- package/src/provider/model-client.mjs +44 -0
- package/src/provider/model-route.mjs +29 -0
- package/src/provider/openrouter-readiness.mjs +189 -0
- package/src/provider/reader-bridge.mjs +35 -0
- package/src/provider/relay.mjs +263 -0
- package/src/provider/runtime-auth.mjs +40 -0
- package/src/public/cap.d.mts +90 -0
- package/src/public/cap.mjs +12 -0
- package/src/public/contracts.d.mts +2 -0
- package/src/public/host.mjs +171 -0
- package/src/public/operations.d.mts +11 -0
- package/src/public/presentation.d.mts +4 -0
- package/src/records/views.mjs +26 -0
- package/src/remote/command.mjs +178 -0
- package/src/remote/ssh.mjs +59 -0
- package/src/repository-origin.mjs +81 -0
- package/src/reproduction/evidence-feedback.mjs +96 -0
- package/src/reproduction/incomplete-initialization.mjs +25 -0
- package/src/reproduction/lifecycle.mjs +253 -0
- package/src/reproduction/plan.mjs +132 -0
- package/src/reproduction/prompts.mjs +70 -0
- package/src/reproduction/runner.mjs +188 -0
- package/src/reproduction/summary.mjs +130 -0
- package/src/reproduction/workspace-mode.mjs +7 -0
- package/src/research/automatic-admission.mjs +156 -0
- package/src/research/compiler-coverage.mjs +85 -0
- package/src/research/compiler-failure.mjs +24 -0
- package/src/research/compiler-normalization-guards.mjs +112 -0
- package/src/research/compiler-repair.mjs +3 -0
- package/src/research/compiler.mjs +853 -0
- package/src/research/continuation-selection.mjs +26 -0
- package/src/research/execution-graph-context.mjs +43 -0
- package/src/research/experiment-importance.mjs +15 -0
- package/src/research/inventory-handoff.mjs +104 -0
- package/src/research/inventory-revisions.mjs +32 -0
- package/src/research/mineru-local.mjs +73 -0
- package/src/research/paper-command.mjs +19 -0
- package/src/research/paper-markdown.mjs +180 -0
- package/src/research/paper-source-map.mjs +69 -0
- package/src/research/planning-policy.mjs +88 -0
- package/src/research/reference-materials.mjs +11 -0
- package/src/research/reproduction-scope.mjs +30 -0
- package/src/research/research-map.mjs +94 -0
- package/src/research/research-objects.mjs +88 -0
- package/src/research/source-discovery.mjs +646 -0
- package/src/research/source-observations.mjs +75 -0
- package/src/research/source-review-cli-mcp.mjs +26 -0
- package/src/research/source-review-input.mjs +209 -0
- package/src/research/source-review-local-codex.mjs +36 -0
- package/src/research/source-review-model.mjs +70 -0
- package/src/research/source-review.mjs +173 -0
- package/src/research/structure.mjs +3163 -0
- package/src/research-card/renderer.mjs +277 -0
- package/src/research-card/verified-conclusion.mjs +143 -0
- package/src/results/output-registry.mjs +183 -0
- package/src/runtime/claude-code.mjs +52 -0
- package/src/runtime/codex-capacity-retry.mjs +87 -0
- package/src/runtime/codex.mjs +64 -0
- package/src/runtime/config.mjs +157 -0
- package/src/runtime/final-output.mjs +40 -0
- package/src/runtime/index.mjs +21 -0
- package/src/runtime/local-codex.mjs +74 -0
- package/src/runtime/opencode.mjs +95 -0
- package/src/runtime/prompt.mjs +13 -0
- package/src/sandbox/docker.mjs +363 -0
- package/src/settings/command.mjs +297 -0
- package/src/settings/store.mjs +119 -0
- package/src/telemetry/pricing.mjs +68 -0
- package/src/telemetry/usage.mjs +265 -0
- package/src/terminal/events.mjs +97 -0
- package/src/terminal/input.mjs +40 -0
- package/src/terminal/plain.mjs +40 -0
- package/src/terminal/remote-stream.mjs +22 -0
- package/src/terminal/screen.mjs +214 -0
- package/src/terminal/transcript.mjs +69 -0
- package/src/util.mjs +107 -0
- package/src/verification/ai-assessor.mjs +534 -0
- package/src/verification/claim-evaluator.mjs +242 -0
- package/src/verification/evidence-context.mjs +165 -0
- package/src/verification/evidence-reader.mjs +95 -0
- package/src/verification/integrity.mjs +570 -0
- package/src/verification/tolerance.mjs +32 -0
- package/src/workloads/cpu-research-preparation.mjs +56 -0
- package/src/workloads/definition.mjs +74 -0
- package/src/workloads/phase-aware-reproduction.mjs +46 -0
- package/src/workloads/reproduction.mjs +85 -0
- package/src/workspace/command.mjs +242 -0
- package/src/workspace/control.mjs +49 -0
- package/src/workspace/entry.mjs +28 -0
- package/src/workspace/input.mjs +93 -0
- package/src/workspace/interactive.mjs +94 -0
- package/src/workspace/jobs.mjs +418 -0
- package/src/workspace/session.mjs +97 -0
- package/src/workspace/worker.mjs +137 -0
- package/ui/arkgraph/ambient-motion.mjs +10 -0
- package/ui/arkgraph/app.jsx +153 -0
- package/ui/arkgraph/boot.js +6 -0
- package/ui/arkgraph/camera-motion.mjs +20 -0
- package/ui/arkgraph/context-reveal.mjs +39 -0
- package/ui/arkgraph/details.css +3 -0
- package/ui/arkgraph/entry.jsx +28 -0
- package/ui/arkgraph/experiment-curves.mjs +17 -0
- package/ui/arkgraph/experiment-selection.mjs +15 -0
- package/ui/arkgraph/experiment-style.css +26 -0
- package/ui/arkgraph/experiment-ui.jsx +32 -0
- package/ui/arkgraph/frame.html +1 -0
- package/ui/arkgraph/graph-gestures.mjs +62 -0
- package/ui/arkgraph/label-layout.mjs +57 -0
- package/ui/arkgraph/locales/en.json +229 -0
- package/ui/arkgraph/locales/source-types.json +15 -0
- package/ui/arkgraph/localization-build.mjs +27 -0
- package/ui/arkgraph/material-build.mjs +23 -0
- package/ui/arkgraph/material-colors.mjs +39 -0
- package/ui/arkgraph/material-style.css +15 -0
- package/ui/arkgraph/open-graph.jsx +326 -0
- package/ui/arkgraph/outline.jsx +49 -0
- package/ui/arkgraph/package-lock.json +888 -0
- package/ui/arkgraph/package.json +17 -0
- package/ui/arkgraph/reading-layout.mjs +130 -0
- package/ui/arkgraph/reading-presentation.mjs +73 -0
- package/ui/arkgraph/record-detail.css +51 -0
- package/ui/arkgraph/record-details.jsx +29 -0
- package/ui/arkgraph/research-types.mjs +31 -0
- package/ui/arkgraph/selection-mark.jsx +6 -0
- package/ui/arkgraph/soft-spine.mjs +26 -0
- package/ui/arkgraph/steering-style.css +187 -0
- package/ui/arkgraph/style.css +272 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const EXECUTION_MODES = new Set([
|
|
2
|
+
"agent_planned",
|
|
3
|
+
"fixed_entrypoint",
|
|
4
|
+
]);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Old Research Plan records predate executionMode and promised an immutable
|
|
8
|
+
* entrypoint. Keep that meaning for compatibility. Newly compiled plans state
|
|
9
|
+
* their mode explicitly and default to Agent-owned execution planning.
|
|
10
|
+
*/
|
|
11
|
+
export function resolveExecutionMode(protocol) {
|
|
12
|
+
return EXECUTION_MODES.has(protocol?.executionMode)
|
|
13
|
+
? protocol.executionMode
|
|
14
|
+
: "fixed_entrypoint";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function agentPlansExecution(protocol) {
|
|
18
|
+
return resolveExecutionMode(protocol) === "agent_planned";
|
|
19
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const MINUTES_PER_HOUR = 60;
|
|
2
|
+
|
|
3
|
+
// These are anomaly circuit breakers, not scheduling targets. New Research
|
|
4
|
+
// Plans must still declare an explicit timeout based on the complete workload.
|
|
5
|
+
export const LEGACY_EXECUTION_TIMEOUT_FALLBACK_MINUTES = 12 * MINUTES_PER_HOUR;
|
|
6
|
+
|
|
7
|
+
export const EXECUTION_TIMEOUT_CAPS_MINUTES = Object.freeze({
|
|
8
|
+
proxy: 168 * MINUTES_PER_HOUR,
|
|
9
|
+
approximate: 168 * MINUTES_PER_HOUR,
|
|
10
|
+
faithful: 168 * MINUTES_PER_HOUR,
|
|
11
|
+
exact: 168 * MINUTES_PER_HOUR,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const GCP_BATCH_PROVISIONING_GRACE_PER_ATTEMPT_MINUTES = 2 * MINUTES_PER_HOUR;
|
|
15
|
+
export const GCP_BATCH_CONTROLLER_FINALIZATION_GRACE_MINUTES = 1 * MINUTES_PER_HOUR;
|
|
16
|
+
|
|
17
|
+
export function executionTimeoutCapMinutes(fidelity) {
|
|
18
|
+
return EXECUTION_TIMEOUT_CAPS_MINUTES[fidelity]
|
|
19
|
+
?? EXECUTION_TIMEOUT_CAPS_MINUTES.faithful;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function gcpBatchControllerWaitTimeoutMinutes({
|
|
23
|
+
executionTimeoutMinutes,
|
|
24
|
+
infrastructureRetryCount = 0,
|
|
25
|
+
}) {
|
|
26
|
+
const timeoutMinutes = positiveFiniteNumber(
|
|
27
|
+
executionTimeoutMinutes,
|
|
28
|
+
LEGACY_EXECUTION_TIMEOUT_FALLBACK_MINUTES,
|
|
29
|
+
);
|
|
30
|
+
const retryCount = Number.isInteger(infrastructureRetryCount)
|
|
31
|
+
&& infrastructureRetryCount >= 0
|
|
32
|
+
? infrastructureRetryCount
|
|
33
|
+
: 0;
|
|
34
|
+
const provisioningAttempts = retryCount + 1;
|
|
35
|
+
return Math.ceil(
|
|
36
|
+
timeoutMinutes
|
|
37
|
+
+ provisioningAttempts * GCP_BATCH_PROVISIONING_GRACE_PER_ATTEMPT_MINUTES
|
|
38
|
+
+ GCP_BATCH_CONTROLLER_FINALIZATION_GRACE_MINUTES,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function positiveFiniteNumber(value, fallback) {
|
|
43
|
+
const numeric = Number(value);
|
|
44
|
+
return Number.isFinite(numeric) && numeric > 0 ? numeric : fallback;
|
|
45
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Pure workload arithmetic shared by the compiler, runtime helper and verifier. */
|
|
2
|
+
export function executionWorkloadIssues(workload) {
|
|
3
|
+
if (workload === undefined) return [];
|
|
4
|
+
if (!workload || typeof workload !== "object" || Array.isArray(workload)) return ["protocol.workload must be an object"];
|
|
5
|
+
const issues = [];
|
|
6
|
+
if (typeof workload.unit !== "string" || !workload.unit.trim()) issues.push("protocol.workload.unit is required");
|
|
7
|
+
if (!Array.isArray(workload.groups) || !workload.groups.length) return [...issues, "protocol.workload.groups must contain the full scientific workload"];
|
|
8
|
+
const ids = new Set();
|
|
9
|
+
for (const group of workload.groups) {
|
|
10
|
+
if (typeof group?.id !== "string" || !group.id.trim() || ids.has(group.id)) issues.push("workload group ids must be nonempty and unique");
|
|
11
|
+
ids.add(group?.id);
|
|
12
|
+
if (!Number.isSafeInteger(group?.units) || group.units < 1) issues.push("workload group units must be positive safe integers");
|
|
13
|
+
if (typeof group?.description !== "string" || !group.description.trim()) issues.push("workload groups must describe their scientific scope");
|
|
14
|
+
}
|
|
15
|
+
return issues;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function assessExecutionFeasibility({ workload, probes, completed = [], remainingSeconds, publicationReserveSeconds = 300 }) {
|
|
19
|
+
const issues = executionWorkloadIssues(workload);
|
|
20
|
+
if (!workload) issues.push("A declared workload is required for a measured forecast");
|
|
21
|
+
if (!Number.isFinite(remainingSeconds) || remainingSeconds < 0) issues.push("remainingSeconds must come from the current runner ledger");
|
|
22
|
+
if (!Number.isFinite(publicationReserveSeconds) || publicationReserveSeconds < 300) issues.push("Reserve at least 300 seconds for evidence publication");
|
|
23
|
+
if (issues.length) throw new TypeError(issues.join("; "));
|
|
24
|
+
const expected = new Map(workload.groups.map((group) => [group.id, group.units]));
|
|
25
|
+
if (!Array.isArray(completed) || new Set(completed.map((item) => item?.groupId)).size !== completed.length
|
|
26
|
+
|| completed.some((item) => !expected.has(item?.groupId)
|
|
27
|
+
|| !Number.isSafeInteger(item.units) || item.units < 0 || item.units > expected.get(item.groupId)
|
|
28
|
+
|| typeof item.evidencePath !== "string" || !item.evidencePath.trim())) {
|
|
29
|
+
throw new TypeError("Completed work must have unique declared groups, bounded counts and raw evidence");
|
|
30
|
+
}
|
|
31
|
+
const groups = workload.groups.map((group) => {
|
|
32
|
+
const done = completed.find((item) => item.groupId === group.id)?.units ?? 0;
|
|
33
|
+
if (!Number.isSafeInteger(done) || done < 0 || done > group.units) throw new TypeError(`Invalid completed count for ${group.id}`);
|
|
34
|
+
const samples = (probes ?? []).filter((item) => item.groupId === group.id);
|
|
35
|
+
const valid = samples.filter((item) => Number.isSafeInteger(item.units) && item.units > 0
|
|
36
|
+
&& Number.isFinite(item.durationSeconds) && item.durationSeconds > 0
|
|
37
|
+
&& typeof item.evidencePath === "string" && item.evidencePath.trim());
|
|
38
|
+
// Use the slowest observed rate; do not assume unmeasured parallel speedup.
|
|
39
|
+
const secondsPerUnit = valid.length ? Math.max(...valid.map((item) => item.durationSeconds / item.units)) : null;
|
|
40
|
+
const remainingUnits = group.units - done;
|
|
41
|
+
return { groupId: group.id, totalUnits: group.units, completedUnits: done, remainingUnits, secondsPerUnit,
|
|
42
|
+
forecastSeconds: remainingUnits === 0 ? 0 : secondsPerUnit === null ? null : remainingUnits * secondsPerUnit,
|
|
43
|
+
evidencePaths: [...new Set(valid.map((item) => item.evidencePath))] };
|
|
44
|
+
});
|
|
45
|
+
const complete = groups.every((group) => group.forecastSeconds !== null);
|
|
46
|
+
const forecastSeconds = complete ? groups.reduce((total, group) => total + group.forecastSeconds, 0) : null;
|
|
47
|
+
return {
|
|
48
|
+
schemaVersion: "1.0", kind: "citeark.execution-feasibility",
|
|
49
|
+
status: !complete ? "insufficient_evidence" : forecastSeconds + publicationReserveSeconds <= remainingSeconds ? "fits" : "requires_replanning",
|
|
50
|
+
forecastSeconds, remainingSeconds, publicationReserveSeconds, groups,
|
|
51
|
+
basis: "measured-rates-and-declared-workload; not a guarantee of completion",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function executionWorkloadCompletionIssues(workload, completed) {
|
|
56
|
+
if (!workload) return [];
|
|
57
|
+
const issues = executionWorkloadIssues(workload);
|
|
58
|
+
if (!Array.isArray(completed)) return [...issues, "Successful execution requires workload completion records"];
|
|
59
|
+
const expected = new Map((workload.groups ?? []).map((group) => [group.id, group.units]));
|
|
60
|
+
const ids = completed.map((item) => item?.groupId);
|
|
61
|
+
if (new Set(ids).size !== ids.length || ids.some((id) => !expected.has(id))) issues.push("Completion groups must be unique and declared");
|
|
62
|
+
for (const [id, units] of expected) {
|
|
63
|
+
const record = completed.find((item) => item.groupId === id);
|
|
64
|
+
if (record?.units !== units || !Number.isSafeInteger(record?.units)) issues.push(`Incomplete workload ${id}: expected ${units} units`);
|
|
65
|
+
if (typeof record?.evidencePath !== "string" || !record.evidencePath.trim()) issues.push(`Missing raw completion evidence for ${id}`);
|
|
66
|
+
}
|
|
67
|
+
return issues;
|
|
68
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const PREFLIGHT_SCHEMA_VERSIONS = Object.freeze(["0.1", "0.2", "0.3"]);
|
|
2
|
+
export const CURRENT_PREFLIGHT_SCHEMA_VERSION = "0.3";
|
|
3
|
+
export const PREFLIGHT_SCHEMA_VERSION_SET = new Set(PREFLIGHT_SCHEMA_VERSIONS);
|
|
4
|
+
|
|
5
|
+
export const MAX_PREFLIGHT_MINUTES = 240;
|
|
6
|
+
export const MIN_PUBLIC_ASSET_PREFLIGHT_MINUTES = 30;
|
|
7
|
+
|
|
8
|
+
export const PREFLIGHT_CHECK_KINDS = new Set([
|
|
9
|
+
"runtime",
|
|
10
|
+
"dependencies",
|
|
11
|
+
"dataset_loader",
|
|
12
|
+
"assets",
|
|
13
|
+
"entrypoint",
|
|
14
|
+
"parser",
|
|
15
|
+
"smoke_test",
|
|
16
|
+
"duration",
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
export function supportsPreflightSchemaVersion(value) {
|
|
20
|
+
return PREFLIGHT_SCHEMA_VERSION_SET.has(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function describeSupportedPreflightSchemaVersions() {
|
|
24
|
+
return PREFLIGHT_SCHEMA_VERSIONS.join("、");
|
|
25
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** One prospective projection, shared by compilation and CAP publication. */
|
|
2
|
+
export function researchPublicContract(experiment) {
|
|
3
|
+
const protocol = experiment?.protocol ?? {};
|
|
4
|
+
return {
|
|
5
|
+
implementation: {
|
|
6
|
+
repository: experiment?.repository?.url,
|
|
7
|
+
revision: experiment?.repository?.commit,
|
|
8
|
+
...(protocol.executionMode ? { executionMode: protocol.executionMode } : {}),
|
|
9
|
+
...(protocol.objective ? { objective: protocol.objective } : {}),
|
|
10
|
+
entrypoint: protocol.entrypoint,
|
|
11
|
+
requiredCommandFragments: protocol.requiredCommandFragments ?? [],
|
|
12
|
+
},
|
|
13
|
+
parameters: protocol.parameters ?? [],
|
|
14
|
+
measurements: (Array.isArray(experiment?.measurements) ? experiment.measurements : []).map((item) => {
|
|
15
|
+
const measurement = item ?? {};
|
|
16
|
+
return {
|
|
17
|
+
id: measurement.id ?? measurement.reportedMeasurementId,
|
|
18
|
+
metric: measurement.metric,
|
|
19
|
+
...(measurement.quantityKind ? { quantityKind: measurement.quantityKind } : {}),
|
|
20
|
+
unit: measurement.unit,
|
|
21
|
+
evidenceParser: { id: measurement.parser?.id, version: measurement.parser?.version },
|
|
22
|
+
};
|
|
23
|
+
}),
|
|
24
|
+
...(experiment?.reproductionScope ? { reproductionScope: experiment.reproductionScope, requiredReproductionScope: experiment.requiredReproductionScope } : {}),
|
|
25
|
+
resources: { computeRequirement: experiment?.compute ?? {}, environment: experiment?.environment ?? {} },
|
|
26
|
+
...(protocol.benchmark ? { benchmark: protocol.benchmark } : {}),
|
|
27
|
+
...(protocol.preflight ? { preflight: protocol.preflight } : {}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const PRIVATE_FIELDS = new Set([
|
|
32
|
+
'reportedvalue', 'targetvalue', 'acceptancecriterion', 'acceptancecriteria',
|
|
33
|
+
'verificationtolerance', 'verificationpolicy', 'privatepolicy', 'policyreveal',
|
|
34
|
+
]);
|
|
35
|
+
const fieldName = value => String(value).replace(/[_\s-]/g, '').toLowerCase();
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Enforce private policy structure, not a vocabulary ban on scientific prose.
|
|
39
|
+
* Numerical solver tolerances are public algorithm parameters. Bare tolerance
|
|
40
|
+
* in a measurement or at the contract root is an acceptance-policy field.
|
|
41
|
+
* This does not claim to prove semantic blindness of arbitrary text or code.
|
|
42
|
+
*/
|
|
43
|
+
export function publicContractPolicyIssues(contract) {
|
|
44
|
+
const issues = [];
|
|
45
|
+
function visit(value, parts) {
|
|
46
|
+
if (!value || typeof value !== 'object') return;
|
|
47
|
+
for (const [key, child] of Object.entries(value)) {
|
|
48
|
+
const name = fieldName(key);
|
|
49
|
+
const location = [...parts, key];
|
|
50
|
+
if (PRIVATE_FIELDS.has(name)
|
|
51
|
+
|| (name === 'tolerance' && (parts.length === 0 || parts[0] === 'measurements'))) {
|
|
52
|
+
issues.push(`${location.join('.')} contains a private verification-policy field`);
|
|
53
|
+
}
|
|
54
|
+
// Also recognize records representing parameters by name rather than key.
|
|
55
|
+
if (name === 'name' && typeof child === 'string' && PRIVATE_FIELDS.has(fieldName(child))) {
|
|
56
|
+
issues.push(`${location.join('.')} names a private verification-policy field`);
|
|
57
|
+
}
|
|
58
|
+
visit(child, location);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
visit(contract, []);
|
|
62
|
+
return issues;
|
|
63
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const SUBJECT_TAGS = new Set([
|
|
2
|
+
"cs-ai", "cs-ar", "cs-cc", "cs-ce", "cs-cg", "cs-cl", "cs-cr", "cs-cv", "cs-cy", "cs-db",
|
|
3
|
+
"cs-dc", "cs-dl", "cs-dm", "cs-ds", "cs-et", "cs-fl", "cs-gl", "cs-gr", "cs-gt", "cs-hc",
|
|
4
|
+
"cs-ir", "cs-it", "cs-lg", "cs-lo", "cs-ma", "cs-mm", "cs-ms", "cs-na", "cs-ne", "cs-ni",
|
|
5
|
+
"cs-oh", "cs-os", "cs-pf", "cs-pl", "cs-ro", "cs-sc", "cs-sd", "cs-se", "cs-si", "cs-sy",
|
|
6
|
+
"econ-em", "econ-gn", "econ-th",
|
|
7
|
+
"eess-as", "eess-iv", "eess-sp", "eess-sy",
|
|
8
|
+
"math-ac", "math-ag", "math-ap", "math-at", "math-ca", "math-co", "math-ct", "math-cv",
|
|
9
|
+
"math-dg", "math-ds", "math-fa", "math-gm", "math-gn", "math-gr", "math-gt", "math-ho",
|
|
10
|
+
"math-it", "math-kt", "math-lo", "math-mg", "math-mp", "math-na", "math-nt", "math-oa",
|
|
11
|
+
"math-oc", "math-pr", "math-qa", "math-ra", "math-rt", "math-sg", "math-sp", "math-st",
|
|
12
|
+
"astro-ph-co", "astro-ph-ep", "astro-ph-ga", "astro-ph-he", "astro-ph-im", "astro-ph-sr",
|
|
13
|
+
"cond-mat-dis-nn", "cond-mat-mes-hall", "cond-mat-mtrl-sci", "cond-mat-other",
|
|
14
|
+
"cond-mat-quant-gas", "cond-mat-soft", "cond-mat-stat-mech", "cond-mat-str-el", "cond-mat-supr-con",
|
|
15
|
+
"gr-qc",
|
|
16
|
+
"hep-ex", "hep-lat", "hep-ph", "hep-th",
|
|
17
|
+
"math-ph",
|
|
18
|
+
"nlin-ao", "nlin-cd", "nlin-cg", "nlin-ps", "nlin-si",
|
|
19
|
+
"nucl-ex", "nucl-th",
|
|
20
|
+
"physics-acc-ph", "physics-ao-ph", "physics-app-ph", "physics-atm-clus", "physics-atom-ph",
|
|
21
|
+
"physics-bio-ph", "physics-chem-ph", "physics-class-ph", "physics-comp-ph", "physics-data-an",
|
|
22
|
+
"physics-ed-ph", "physics-flu-dyn", "physics-gen-ph", "physics-geo-ph", "physics-hist-ph",
|
|
23
|
+
"physics-ins-det", "physics-med-ph", "physics-optics", "physics-plasm-ph", "physics-pop-ph",
|
|
24
|
+
"physics-soc-ph", "physics-space-ph",
|
|
25
|
+
"quant-ph",
|
|
26
|
+
"q-bio-bm", "q-bio-cb", "q-bio-gn", "q-bio-mn", "q-bio-nc", "q-bio-ot", "q-bio-pe",
|
|
27
|
+
"q-bio-qm", "q-bio-sc", "q-bio-to",
|
|
28
|
+
"q-fin-cp", "q-fin-ec", "q-fin-gn", "q-fin-mf", "q-fin-pm", "q-fin-pr", "q-fin-rm",
|
|
29
|
+
"q-fin-st", "q-fin-tr",
|
|
30
|
+
"stat-ap", "stat-co", "stat-me", "stat-ml", "stat-ot", "stat-th",
|
|
31
|
+
]);
|