@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,46 @@
|
|
|
1
|
+
import { CAP_RECORD_TYPE } from './core.mjs';
|
|
2
|
+
import { capRecordId } from './research-records.mjs';
|
|
3
|
+
|
|
4
|
+
export function researchReferenceResolver(research, objectGraph, sourceWorkId) {
|
|
5
|
+
const map = new Map([
|
|
6
|
+
...[...objectGraph.objectIds].map(([id, ref]) => [`object:${id}`, ref]),
|
|
7
|
+
...[...objectGraph.sourceIds].map(([id, ref]) => [`source:${id}`, ref]),
|
|
8
|
+
...(research.claims ?? []).map(n => [`claim:${n.id}`, capRecordId('claim', `${research.work.id}:${n.id}`)]),
|
|
9
|
+
...(research.hypotheses ?? []).map(n => [`hypothesis:${n.id}`, capRecordId('hypothesis', `${research.work.id}:${n.id}`)]),
|
|
10
|
+
]);
|
|
11
|
+
return id => {
|
|
12
|
+
const resolved = map.get(id);
|
|
13
|
+
if (!resolved) throw Error(`Unknown research map reference: ${id}`);
|
|
14
|
+
return { ref: resolved };
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function researchMapRecords({ research, objectGraph, sourceWorkId, actorId }) {
|
|
19
|
+
const resolve = researchReferenceResolver(research, objectGraph, sourceWorkId);
|
|
20
|
+
return (research.researchRelations ?? []).map(relation => ({
|
|
21
|
+
$schema: 'https://citeark.com/schemas/cap/v2/relation.schema.json',
|
|
22
|
+
id: capRecordId('source-relation', `${research.work.id}:${relation.id}`),
|
|
23
|
+
type: CAP_RECORD_TYPE.relation, role: 'provenance', predicate: relation.predicate,
|
|
24
|
+
subject: resolve(relation.from), object: resolve(relation.to),
|
|
25
|
+
attributedTo: { ref: actorId }, basis: relation.basis,
|
|
26
|
+
sources: relation.sourceLocators.map(s => resolve(`source:${s.sourceId}`)),
|
|
27
|
+
qualifiers: { sourceLocators: structuredClone(relation.sourceLocators), ...(relation.note ? { note: relation.note } : {}) },
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Keep editorial organization separate from scientific edges. The assembler binds node
|
|
32
|
+
// identities; consumers resolve their exact versions inside this immutable snapshot.
|
|
33
|
+
export function bindResearchReading(research, objectGraph, sourceWorkId) {
|
|
34
|
+
if (!research.reading) return undefined;
|
|
35
|
+
const resolve = researchReferenceResolver(research, objectGraph, sourceWorkId), view = research.reading;
|
|
36
|
+
return { schemaVersion: '1.0', overview: view.overview,
|
|
37
|
+
mainline: view.mainline.map(resolve),
|
|
38
|
+
branches: view.branches.map(b => ({ parent: resolve(b.parent), children: b.children.map(resolve) })),
|
|
39
|
+
labels: (view.labels ?? []).map(({target,...label}) => ({ ...label, ...resolve(target) })),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function bindResearchIntent(experiment, research, objectGraph, sourceWorkId) {
|
|
43
|
+
if (!experiment.researchIntent) return undefined;
|
|
44
|
+
const resolve = researchReferenceResolver(research, objectGraph, sourceWorkId), value = experiment.researchIntent;
|
|
45
|
+
return { ...value, from: resolve(value.from), to: resolve(value.to), context: (value.context ?? []).map(resolve) };
|
|
46
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { CONTEXT_ROLES } from '../../research/research-map.mjs';
|
|
2
|
+
import { CAP_RECORD_TYPE } from './core.mjs';
|
|
3
|
+
import { canonicalJsonBytes, sha256Bytes } from './canonical-json.mjs';
|
|
4
|
+
import { CAP_SCHEMA, capRecordId, capSourceRights, capDecimal } from './research-records.mjs';
|
|
5
|
+
import { reportedObservationCollections } from '../../research/source-observations.mjs';
|
|
6
|
+
|
|
7
|
+
const ref = id => ({ ref: id });
|
|
8
|
+
const objectId = (research, localId) => capRecordId('research-object', `${research.work.id}:${localId}`);
|
|
9
|
+
const sourceId = (research, source, workId) => source.kind === 'paper' ? workId
|
|
10
|
+
: source.kind === 'repository' && source.version ? capRecordId('code', `${source.uri}@${source.version}`)
|
|
11
|
+
: capRecordId('source', `${research.work.id}:${source.id}`);
|
|
12
|
+
const role = kind => ({ repository: 'code', supplement: 'material' })[kind] ?? kind;
|
|
13
|
+
|
|
14
|
+
/** Materialize only named objects and explicitly recorded inputs. Never extract identities from prose. */
|
|
15
|
+
export function researchObjectRecords({ research, sourceWorkId, actorId }) {
|
|
16
|
+
const records = [], inputIdsByExperiment = new Map(), stepIdsByExperiment = new Map();
|
|
17
|
+
const collections = reportedObservationCollections(research);
|
|
18
|
+
const sourceIds = new Map((research.sources ?? []).map(source => [source.id, sourceId(research, source, sourceWorkId)]));
|
|
19
|
+
const objectIds = new Map((research.researchObjects ?? []).map(object => [object.id, object.sourceId ? sourceIds.get(object.sourceId) : objectId(research, object.id)]));
|
|
20
|
+
for (const source of research.sources ?? []) {
|
|
21
|
+
if (source.kind === 'paper') continue;
|
|
22
|
+
records.push({ $schema: CAP_SCHEMA.sourceWork, id: sourceIds.get(source.id), type: CAP_RECORD_TYPE.entity,
|
|
23
|
+
role: role(source.kind), title: source.title ?? source.uri,
|
|
24
|
+
basis: 'declared', identity: { uri: source.uri, ...(source.version ? { version: source.version } : {}), ...(source.digest ? { digest: source.digest } : {}) },
|
|
25
|
+
rights: capSourceRights(source.kind, research.license),
|
|
26
|
+
origin: { basis: 'declared', actor: ref(actorId) }, citeark: { sourceId: source.id },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
for (const object of research.researchObjects ?? []) {
|
|
30
|
+
const sourceIndex = records.findIndex(record => record.id === objectIds.get(object.id));
|
|
31
|
+
const sourceRecord = sourceIndex >= 0 ? records.splice(sourceIndex, 1)[0] : {};
|
|
32
|
+
const primitive = CONTEXT_ROLES[object.role]?.[0] ?? 'entity';
|
|
33
|
+
records.push({ ...sourceRecord, $schema: `https://citeark.com/schemas/cap/v2/${primitive}.schema.json`, id: objectIds.get(object.id), type: CAP_RECORD_TYPE[primitive],
|
|
34
|
+
...(primitive === 'activity' ? { status: 'unknown', reportingBasis: 'declared' } : {}),
|
|
35
|
+
...(primitive === 'assertion' ? { statement: { value: object.description ?? object.title, language: 'und' } } : {}),
|
|
36
|
+
...(primitive === 'agent' ? { name: object.title, kind: object.role === 'person' ? 'human' : object.role } : {}),
|
|
37
|
+
role: object.role, title: object.title, basis: object.basis ?? 'declared',
|
|
38
|
+
...(object.role === 'observation' ? { kind: object.prospective ? 'observation-specification'
|
|
39
|
+
: object.observationKind && object.observationKind !== 'scalar' ? 'source-observation-collection' : 'source-observation',
|
|
40
|
+
...(object.observationKind ? { observationKind: object.observationKind } : {}) } : {}),
|
|
41
|
+
...(collections.has(object.id) ? { kind: 'source-observation-collection',
|
|
42
|
+
measurements: collections.get(object.id).map(({ claim, measurement }) => ({
|
|
43
|
+
measurementId: measurement.id, metric: measurement.metric,
|
|
44
|
+
value: { decimal: capDecimal(measurement.value) }, unit: measurement.unit,
|
|
45
|
+
...(measurement.dimensions ? { scope: structuredClone(measurement.dimensions) } : {}),
|
|
46
|
+
conditions: structuredClone(measurement.conditions ?? claim.conditions ?? {}),
|
|
47
|
+
sourceLocator: structuredClone(measurement.sourceLocator ?? claim.sourceLocator),
|
|
48
|
+
contextObjects: (measurement.objectIds ?? claim.objectIds ?? []).map(id => ref(objectIds.get(id))),
|
|
49
|
+
...(measurement.aggregation ? { aggregation: measurement.aggregation } : {}),
|
|
50
|
+
...(measurement.evidenceBasis ? { evidenceBasis: measurement.evidenceBasis } : {}),
|
|
51
|
+
...(measurement.extractionUncertainty !== undefined ? { uncertainty: { absolute: capDecimal(measurement.extractionUncertainty) } } : {}),
|
|
52
|
+
})),
|
|
53
|
+
contextObjects: [...new Set(collections.get(object.id).flatMap(({ claim, measurement }) => measurement.objectIds ?? claim.objectIds ?? []))]
|
|
54
|
+
.map(id => ref(objectIds.get(id))),
|
|
55
|
+
} : {}),
|
|
56
|
+
...(object.description ? { description: object.description } : {}),
|
|
57
|
+
...((sourceRecord.identity || object.identity) ? { identity: { ...sourceRecord.identity, ...structuredClone(object.identity ?? {}) } } : {}),
|
|
58
|
+
...(object.conditions !== undefined ? { conditions: structuredClone(object.conditions) } : {}),
|
|
59
|
+
prospective: object.prospective === true,
|
|
60
|
+
...(object.prospective ? { availability: 'not-yet-generated' } : {}),
|
|
61
|
+
sourceContext: (object.sourceLocators ?? []).map(locator => ({ source: ref(sourceIds.get(locator.sourceId)), selector: { label: locator.locator } })),
|
|
62
|
+
derivedFrom: (object.derivedFromIds ?? []).map(id => ref(objectIds.get(id))),
|
|
63
|
+
origin: { basis: object.basis ?? 'declared', actor: ref(actorId) },
|
|
64
|
+
citeark: { ...sourceRecord.citeark, objectId: object.id, sourceLocators: object.sourceLocators ?? [], limitations: object.limitations ?? [] },
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// Older compiler inputs already carry source-grounded asset declarations. Keep each exact recipe
|
|
68
|
+
// once; availability labels and matching names never establish observed bytes or shared identity.
|
|
69
|
+
const materialIds = new Set(records.map(record => record.id));
|
|
70
|
+
for (const experiment of research.experiments ?? []) {
|
|
71
|
+
const inputs = new Set((experiment.inputIds ?? []).map(id => objectIds.get(id)));
|
|
72
|
+
const repository = experiment.repository;
|
|
73
|
+
if (repository?.url && repository?.commit) {
|
|
74
|
+
const codeId = capRecordId('code', `${repository.url}@${repository.commit}`);
|
|
75
|
+
if (!materialIds.has(codeId)) {
|
|
76
|
+
records.push({ $schema: CAP_SCHEMA.sourceWork, id: codeId, type: CAP_RECORD_TYPE.entity, role: 'code',
|
|
77
|
+
title: repository.url, identity: { uri: repository.url, revision: repository.commit }, basis: 'declared',
|
|
78
|
+
origin: { basis: 'declared', actor: ref(actorId) } });
|
|
79
|
+
materialIds.add(codeId);
|
|
80
|
+
}
|
|
81
|
+
inputs.add(codeId);
|
|
82
|
+
}
|
|
83
|
+
for (const asset of experiment.protocol?.preflight?.assets ?? []) {
|
|
84
|
+
const identity = { kind: asset.kind, identity: asset.identity, acquisition: asset.acquisition ?? null,
|
|
85
|
+
sourceUrls: [...(asset.sourceUrls ?? [])].sort(), registryDatasetId: asset.registryDatasetId ?? null,
|
|
86
|
+
scientificRole: asset.scientificRole ?? null };
|
|
87
|
+
const assetId = capRecordId('material', sha256Bytes(canonicalJsonBytes(identity)));
|
|
88
|
+
if (!materialIds.has(assetId)) {
|
|
89
|
+
records.push({ $schema: CAP_SCHEMA.sourceWork, id: assetId, type: CAP_RECORD_TYPE.entity, role: role(asset.kind ?? 'material'),
|
|
90
|
+
title: asset.identity ?? asset.id, identity, basis: 'declared', availability: asset.availability ?? 'unknown',
|
|
91
|
+
origin: { basis: 'declared', actor: ref(actorId) }, citeark: { assetId: asset.id, verification: asset.verification ?? null } });
|
|
92
|
+
materialIds.add(assetId);
|
|
93
|
+
}
|
|
94
|
+
inputs.add(assetId);
|
|
95
|
+
}
|
|
96
|
+
inputIdsByExperiment.set(experiment.id, [...inputs]);
|
|
97
|
+
}
|
|
98
|
+
const steps = new Map();
|
|
99
|
+
for (const experiment of research.experiments ?? []) {
|
|
100
|
+
const ids = [];
|
|
101
|
+
const internalOutputs = new Set((experiment.steps ?? []).flatMap(step => step.outputIds ?? []));
|
|
102
|
+
const packageInputs = new Set(inputIdsByExperiment.get(experiment.id));
|
|
103
|
+
for (const step of experiment.steps ?? []) {
|
|
104
|
+
const id = capRecordId('research-step', `${research.work.id}:${step.id}`);
|
|
105
|
+
ids.push(id);
|
|
106
|
+
for (const input of step.inputIds ?? []) if (!internalOutputs.has(input)) packageInputs.add(objectIds.get(input));
|
|
107
|
+
if (!steps.has(step.id)) steps.set(step.id, { id, step, claimIds: new Set(), experimentIds: new Set() });
|
|
108
|
+
const entry = steps.get(step.id);
|
|
109
|
+
entry.experimentIds.add(experiment.id);
|
|
110
|
+
for (const claimId of step.claimIds ?? []) if (research.claims.some(claim => claim.id === claimId)) entry.claimIds.add(claimId);
|
|
111
|
+
}
|
|
112
|
+
stepIdsByExperiment.set(experiment.id, ids);
|
|
113
|
+
inputIdsByExperiment.set(experiment.id, [...packageInputs]);
|
|
114
|
+
}
|
|
115
|
+
for (const entry of steps.values()) {
|
|
116
|
+
const step = entry.step;
|
|
117
|
+
records.push({ $schema: CAP_SCHEMA.experiment, id: entry.id, type: CAP_RECORD_TYPE.entity, role: 'procedure-step',
|
|
118
|
+
title: step.title, kind: step.kind, prospective: true,
|
|
119
|
+
inputs: (step.inputIds ?? []).map(id => ({ record: ref(objectIds.get(id)), role: 'scientific-input', basis: 'declared' })),
|
|
120
|
+
expectedOutputs: (step.outputIds ?? []).map(id => ref(objectIds.get(id))),
|
|
121
|
+
dependencies: (step.dependsOn ?? []).map(id => ref(capRecordId('research-step', `${research.work.id}:${id}`))),
|
|
122
|
+
tests: [...entry.claimIds].map(id => ref(capRecordId('claim', `${research.work.id}:${id}`))),
|
|
123
|
+
origin: { basis: 'inferred', actor: ref(actorId) },
|
|
124
|
+
evaluationPlan: { title: step.title, state: 'planned', ...(step.description ? { instructions: step.description } : {}) },
|
|
125
|
+
citeark: { stepId: step.id, experimentIds: [...entry.experimentIds], workloadIds: step.workloadIds ?? [] },
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return { records, objectIds, sourceIds, inputIdsByExperiment, stepIdsByExperiment };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Source measurements remain declared observations, including during compilation. */
|
|
132
|
+
export function reportedObservationRecords({ research, sourceWorkId, objectIds = new Map() }) {
|
|
133
|
+
const records = [], idsByClaim = new Map();
|
|
134
|
+
for (const claim of research.claims ?? []) {
|
|
135
|
+
const ids = [];
|
|
136
|
+
for (const measurement of claim.reportedMeasurements ?? []) {
|
|
137
|
+
if (measurement.observationId !== undefined) {
|
|
138
|
+
const object = (research.researchObjects ?? []).find(object => object.id === measurement.observationId);
|
|
139
|
+
const id = objectIds.get(measurement.observationId);
|
|
140
|
+
if (!id || object?.role !== 'observation' || object.prospective || object.basis === 'inferred') throw Error('Invalid source observation collection');
|
|
141
|
+
if (!ids.includes(id)) ids.push(id);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const id = capRecordId('evidence', `${research.work.id}:${claim.id}:reported:${measurement.id}`);
|
|
145
|
+
ids.push(id);
|
|
146
|
+
records.push({ $schema: CAP_SCHEMA.evidence, id, type: CAP_RECORD_TYPE.entity, role: 'observation',
|
|
147
|
+
title: `${measurement.metric}: ${measurement.value} ${measurement.unit}`, kind: 'measurement', basis: 'declared',
|
|
148
|
+
derivedFrom: [{ ref: sourceWorkId }],
|
|
149
|
+
measurement: { measurementId: measurement.id, metric: measurement.metric,
|
|
150
|
+
value: { decimal: capDecimal(measurement.value) }, unit: measurement.unit,
|
|
151
|
+
...(measurement.dimensions ? { scope: measurement.dimensions } : {}) },
|
|
152
|
+
contextObjects: (measurement.objectIds ?? claim.objectIds ?? []).map(id => ref(objectIds.get(id))),
|
|
153
|
+
limitations: ['Declared by the fixed source work; not independently observed.',
|
|
154
|
+
...(measurement.evidenceBasis === 'digitized_figure' ? [`Digitized with absolute extraction uncertainty ${measurement.extractionUncertainty} ${measurement.unit}.`] : [])],
|
|
155
|
+
citeark: { claimId: claim.id, sourceLocator: measurement.sourceLocator, conditions: measurement.conditions ?? claim.conditions ?? null,
|
|
156
|
+
aggregation: measurement.aggregation ?? null, evidenceBasis: measurement.evidenceBasis ?? 'reported_numeric',
|
|
157
|
+
extractionUncertainty: measurement.extractionUncertainty ?? null },
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
idsByClaim.set(claim.id, ids);
|
|
161
|
+
}
|
|
162
|
+
return { records, idsByClaim };
|
|
163
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { CAP_RECORD_TYPE } from "./core.mjs";
|
|
2
|
+
import { sha256Bytes } from "./canonical-json.mjs";
|
|
3
|
+
|
|
4
|
+
export const CAP_SCHEMA = Object.freeze({
|
|
5
|
+
actor: "https://citeark.com/schemas/cap/v2/agent.schema.json",
|
|
6
|
+
sourceWork: "https://citeark.com/schemas/cap/v2/entity.schema.json",
|
|
7
|
+
claim: "https://citeark.com/schemas/cap/v2/assertion.schema.json",
|
|
8
|
+
experiment: "https://citeark.com/schemas/cap/v2/entity.schema.json",
|
|
9
|
+
execution: "https://citeark.com/schemas/cap/v2/activity.schema.json",
|
|
10
|
+
evidence: "https://citeark.com/schemas/cap/v2/entity.schema.json",
|
|
11
|
+
assessment: "https://citeark.com/schemas/cap/v2/assertion.schema.json",
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export function capRecordId(kind, value) {
|
|
15
|
+
return `urn:citeark:${kind}:${sha256Bytes(Buffer.from(String(value), "utf8")).slice(7)}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function capActorRecord(id, name, kind, version) {
|
|
19
|
+
return {
|
|
20
|
+
$schema: CAP_SCHEMA.actor,
|
|
21
|
+
id,
|
|
22
|
+
type: CAP_RECORD_TYPE.agent, role: "agent",
|
|
23
|
+
kind,
|
|
24
|
+
name,
|
|
25
|
+
...(version ? { version: String(version) } : {}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function capSourceWorkRecord({
|
|
30
|
+
research,
|
|
31
|
+
id,
|
|
32
|
+
processingBinding,
|
|
33
|
+
}) {
|
|
34
|
+
return {
|
|
35
|
+
$schema: CAP_SCHEMA.sourceWork,
|
|
36
|
+
id,
|
|
37
|
+
type: CAP_RECORD_TYPE.entity, role: "source-work",
|
|
38
|
+
title: research.work.title,
|
|
39
|
+
abstract: research.work.abstract,
|
|
40
|
+
sources: research.sources.map((source) => capSourceDescriptor({
|
|
41
|
+
source,
|
|
42
|
+
research,
|
|
43
|
+
processingBinding,
|
|
44
|
+
})),
|
|
45
|
+
citeark: {
|
|
46
|
+
workId: research.work.id,
|
|
47
|
+
...(research.compilationStage ? { compilationStage: research.compilationStage } : {}),
|
|
48
|
+
...(research.sourceInventory ? { sourceInventory: structuredClone(research.sourceInventory) } : {}),
|
|
49
|
+
...(research.reproductionScope ? { reproductionScope: research.reproductionScope } : {}),
|
|
50
|
+
...(research.work.significance ? { significance: research.work.significance } : {}),
|
|
51
|
+
authorNames: research.work.authors ?? [],
|
|
52
|
+
subjects: research.work.subjects ?? [],
|
|
53
|
+
license: research.license ?? {},
|
|
54
|
+
provenance: research.provenance ?? {},
|
|
55
|
+
coverage: research.coverage ?? { items: [] },
|
|
56
|
+
lineage: research.lineage ?? [],
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function capClaimRecord({
|
|
62
|
+
claim,
|
|
63
|
+
id,
|
|
64
|
+
sourceWorkId,
|
|
65
|
+
actorId,
|
|
66
|
+
reportedEvidenceIds = [],
|
|
67
|
+
objectReferences = [],
|
|
68
|
+
}) {
|
|
69
|
+
const ref = (value) => ({ ref: value });
|
|
70
|
+
return {
|
|
71
|
+
$schema: CAP_SCHEMA.claim,
|
|
72
|
+
id,
|
|
73
|
+
type: CAP_RECORD_TYPE.assertion, role: "claim",
|
|
74
|
+
statement: { value: claim.statement, language: "en" },
|
|
75
|
+
kind: capClaimKind(claim.type),
|
|
76
|
+
...(objectReferences.length ? { objects: objectReferences } : {}),
|
|
77
|
+
scope: {
|
|
78
|
+
reportedMeasurements: (claim.reportedMeasurements ?? []).map((item) => ({
|
|
79
|
+
id: item.id,
|
|
80
|
+
metric: item.metric,
|
|
81
|
+
value: capDecimal(item.value),
|
|
82
|
+
unit: item.unit,
|
|
83
|
+
evidenceBasis: item.evidenceBasis ?? "reported_numeric",
|
|
84
|
+
...(item.extractionUncertainty !== undefined
|
|
85
|
+
? { extractionUncertainty: capDecimal(item.extractionUncertainty) }
|
|
86
|
+
: {}),
|
|
87
|
+
})),
|
|
88
|
+
reproduction: claim.reproduction ?? {},
|
|
89
|
+
},
|
|
90
|
+
source: {
|
|
91
|
+
work: ref(sourceWorkId),
|
|
92
|
+
selector: {
|
|
93
|
+
type: "TextQuoteSelector",
|
|
94
|
+
exact: claim.statement,
|
|
95
|
+
label: `${claim.sourceLocator.sourceId}:${claim.sourceLocator.locator}`,
|
|
96
|
+
},
|
|
97
|
+
selectedTextDigest: sha256Bytes(Buffer.from(claim.statement, "utf8")),
|
|
98
|
+
},
|
|
99
|
+
origin: {
|
|
100
|
+
basis: "inferred",
|
|
101
|
+
actor: ref(actorId),
|
|
102
|
+
},
|
|
103
|
+
...(reportedEvidenceIds.length
|
|
104
|
+
? { reportedEvidence: reportedEvidenceIds.map(ref) }
|
|
105
|
+
: {}),
|
|
106
|
+
citeark: {
|
|
107
|
+
localId: claim.id,
|
|
108
|
+
versionId: claim.versionId,
|
|
109
|
+
type: claim.type,
|
|
110
|
+
sourceLocator: claim.sourceLocator,
|
|
111
|
+
...Object.fromEntries(["description", "sourceLocators", "conditions", "relations", "ambiguities", "verificationHint"]
|
|
112
|
+
.filter((key) => claim[key] !== undefined).map((key) => [key, structuredClone(claim[key])])),
|
|
113
|
+
reportedMeasurements: claim.reportedMeasurements ?? [],
|
|
114
|
+
reproduction: claim.reproduction ?? {},
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function capSourceDescriptor({ source, research, processingBinding }) {
|
|
120
|
+
const paperDigest = source.kind === "paper" && capDigest(processingBinding?.sourceDigest)
|
|
121
|
+
? processingBinding.sourceDigest
|
|
122
|
+
: capDigest(source.digest) ? source.digest : null;
|
|
123
|
+
return {
|
|
124
|
+
kind: capSourceKind(source.kind),
|
|
125
|
+
uri: source.uri,
|
|
126
|
+
...(source.version ? { version: String(source.version) } : {}),
|
|
127
|
+
integrity: paperDigest ? "verified" : "unverified",
|
|
128
|
+
...(paperDigest ? { digest: paperDigest } : {}),
|
|
129
|
+
rights: capSourceRights(source.kind, research.license),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function capSourceRights(kind, license = {}) {
|
|
134
|
+
const key = kind === "repository"
|
|
135
|
+
? "code"
|
|
136
|
+
: kind === "paper"
|
|
137
|
+
? "paper"
|
|
138
|
+
: kind === "dataset"
|
|
139
|
+
? "dataset"
|
|
140
|
+
: kind === "checkpoint" ? "checkpoint" : null;
|
|
141
|
+
return {
|
|
142
|
+
statement: key && license?.[key]
|
|
143
|
+
? String(license[key])
|
|
144
|
+
: "Source-specific rights; CAP records identity and provenance but grants no redistribution permission.",
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function capClaimKind(value) {
|
|
149
|
+
return ({
|
|
150
|
+
finding: "descriptive",
|
|
151
|
+
method: "methodological",
|
|
152
|
+
measurement: "descriptive",
|
|
153
|
+
limitation: "limitation",
|
|
154
|
+
})[value] ?? "descriptive";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** A source's proposed mechanism is an Assertion, without a reproduction disposition or verdict. */
|
|
158
|
+
export function capHypothesisRecords({ research, sourceWorkId, actorId, objectIds }) {
|
|
159
|
+
return (research.hypotheses ?? []).map(hypothesis => ({
|
|
160
|
+
$schema: CAP_SCHEMA.claim, id: capRecordId('hypothesis', `${research.work.id}:${hypothesis.id}`),
|
|
161
|
+
type: CAP_RECORD_TYPE.assertion, role: 'hypothesis',
|
|
162
|
+
statement: { value: hypothesis.statement, language: 'en' },
|
|
163
|
+
source: { work: { ref: sourceWorkId }, selector: { label: `${hypothesis.sourceLocator.sourceId}:${hypothesis.sourceLocator.locator}` } },
|
|
164
|
+
origin: { basis: 'inferred', actor: { ref: actorId } },
|
|
165
|
+
objects: (hypothesis.objectIds ?? []).map(id => ({ ref: objectIds.get(id) })),
|
|
166
|
+
...(hypothesis.conditions !== undefined ? { scope: structuredClone(hypothesis.conditions) } : {}),
|
|
167
|
+
citeark: { localId: hypothesis.id, sourceLocator: hypothesis.sourceLocator,
|
|
168
|
+
limitations: hypothesis.limitations ?? [], status: 'proposed' },
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function capSourceKind(value) {
|
|
173
|
+
if (value === "checkpoint") return "model";
|
|
174
|
+
return new Set(["paper", "repository", "dataset", "model", "supplement", "other"]).has(value)
|
|
175
|
+
? value
|
|
176
|
+
: "other";
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function capDecimal(value) {
|
|
180
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
181
|
+
if (typeof value === "string" && /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/.test(value)) return value;
|
|
182
|
+
throw new Error(`CAP scientific number cannot be represented as a decimal string: ${String(value)}`);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function capDigest(value) {
|
|
186
|
+
return typeof value === "string" && /^sha256:[0-9a-f]{64}$/.test(value);
|
|
187
|
+
}
|