@daihum/scholar-contract
v0.1.4
Published
DAIHUM Scholar neutral OPERATION CONTRACT: a machine-readable operation manifest (scholar.operation-manifest.v1) + per-op JSON Schemas, authored in zod, emitted as a deterministic JSON bundle (scholar.operation-bundle.v1) that Carrel's generic generator a
Maintainers
Readme
@daihum/scholar-contract
The neutral Scholar operation contract — a machine-readable manifest of Scholar operations +
per-op JSON Schemas, authored in zod and emitted as a deterministic JSON bundle. Carrel's generic
generator ingests the bundle and auto-derives its CLI/descriptors/authority — no hand-written
downstream TypeSpec ("doc folding", zero manual maintenance). zod is the ergonomic authoring face;
the emitted JSON Schema is the vendor-neutral truth (same pattern as @daihum/work-metadata).
Exports (cleanly split — the data path pulls no impl deps)
@daihum/scholar-contract/operation-bundle.v1.json— the canonical data asset Carrel ingests at codegen. Pure JSON (scholar.operation-bundle.v1): envelope + manifest + first-party I/O schemas (keyed by$id, linked$refs) +externalSchemas(work.v1). Deterministic, content-hashed.@daihum/scholar-contract/operation-bundle— the same bundle as a typed loader (operationBundle).@daihum/scholar-contract— types, zod schemas, the manifest,assembleBundle().@daihum/scholar-contract/handlers—createScholarOperationHandlersV1(deps): a THIN, dependency-injected handler registry keyed byopId. Each handler delegates to an injected port or fails closed with a typed reason. The real execution lives in the host (the extension's download executor; a node/provider resolve engine) — this is a SEAM, not an authority path.
First slice
scholar/record.resolve@v0 (read control) · scholar/item.download@v0 · scholar/batch.download@v0
(the two download ops are browser-required; node/daemon fails closed; batch is a durable job).
Build
pnpm --filter @daihum/scholar-contract build → tsdown then scripts/gen-bundle.mjs writes the
deterministic operation-bundle.v1.json. A test guards: the on-disk bundle == source, the zod schemas
== the runtime types (drift), and work.v1's $id == @daihum/work-metadata's.
Versioning
op-id @vN is the consumer contract (breaking I/O → @v(N+1), coexisting); scholar.operation-manifest.v1
is the envelope; additive-within-@vN. Per-schema + bundle sha256 content hashes for compatibility/readback.
