World model contracts and pinned inputs
Generic business model contracts and reproducible evidence bundles with explicit historical cutoffs.
@oblive/types/world-model-contracts defines bounded business entities, observed/estimated/assumed/
unknown parameters, calculator expressions and model revisions. These contracts are independent of
providers and business domains. A schema-valid forecast is not evidence that its arithmetic or
assumptions are correct.
@oblive/types/world-model-inputs defines explicit source pins and input bundles. The internal backend
createWorldModelInputService(context).construct(request) accepts an authorized organization scope,
an explicit cutoff and retained source selections. It returns a bundle and SHA-256 or safe typed
failure paths. This service does not grant controller access and has no public route or agent command.
Selecting evidence
- Context: publication ID, revision, manifest hash and selected document paths/hashes.
- Insights: retained receipt ID/hash, publication revision and exact metric/version/hash, source and resource sets, dimensions, units, currency, timezone and measurement windows.
- Files: terminal source run, safe
outputs/path and retained hash.
The backend verifies source bytes and current access. It never creates a new analytical query, fetches provider data or replaces missing pins with current information. Metric identities come from the retained receipts; no subscription, commerce or operational formulas are built into this layer.
Measurement period and evidence availability are separate. A receipt created in March for January cannot enter a February bundle. Selected historic measurements preserve nulls, coverage and collection times. A failed run’s retained file remains evidence from a failed run, not proof of success.
Choosing sources at a cutoff
The internal createWorldModelHistoricalInputService(context) adds resolve(request) and
constructAsOf(request). Requests use worldModelHistoricalRequestSchema and specify desired
Context document paths, exact metric definitions/populations/windows, or a particular run ID and
output file path. Receipt IDs, publication revisions and retained content hashes are discovered.
Context is optional; a business can construct a measurement-only bundle.
latest_confirmed_v1 chooses the highest eligible Context revision and, for each exact measurement
window, the matching receipt ordered by publication revision descending, confirmation time
descending and receipt ID ascending. Only confirmations and measurement timestamps at or before
the cutoff qualify. Null/provisional points are preserved. File selection does not search task
history, and metric selection does not replace the requested definition with today’s definition.
resolve returns selectionPolicy and resolvedRequest. constructAsOf also returns the bundle
and SHA-256 from the existing constructor. Save resolvedRequest for replay: calling construct
with those pins gives identical bundle bytes. The bundle retains its explicit_pins_v1 format.
Deleted evidence, tampered bytes and revoked permissions fail verification rather than changing
the selected pins. Diagnostics name the original request fields without business values.
Discovery is bounded to 200 candidate artifacts and 64 MiB of candidate content. The selected bundle limits below also apply; spanning multiple receipts can use multiple metric selections. These operations perform no provider calls, new analytical queries, storage listings or writes. Dates mentioned inside Context prose are not availability timestamps.
Reproducibility and limits
Model expressions allow 32 nodes and depth 8, with the root at depth 1. The safe validation
projection reports expression_limit_exceeded with bound (nodes or depth), field path,
limit and first observed violating count. It checks nodes before depth if both are exceeded
together, and stops before recursive parsing. Cycles remain invalid_model failures.
The manifest records explicit_pins_v1, source identities/hashes, availability times and selected
content hashes. It accompanies Context text, measurement points and base64 file content. Canonical
ordering removes request-order differences; output contains no newly generated IDs or timestamps.
Repeated construction produces the same hash when the same evidence is still retained and authorized.
Construction allows 200 artifacts, 25 metric selections and 10,000 points. Each selected document/file
is at most 256 KiB; original Insight receipts are at most 6 MiB; canonical bundles are at most 10 MiB.
Each Context manifest and selected document counts as an artifact. Exceeding a bound fails explicitly.
These POC engineering bounds follow the approved roadmap; they are not measured business complexity.
Missing, ambiguous, corrupt, forbidden or post-cutoff evidence produces a failure without partial output.
Temporary storage/database failures return source_unavailable; unexpected failures return
internal_error. integrity_mismatch means an explicit content or identity mismatch. Safe diagnostics
include the existing trace ID when available, without business values or raw error messages.
Publication provenance and rollout
Apply the Context publication and evidence availability migrations before running the updated backend. Successful Context pointer updates and bootstrap record a backend-owned receipt, including the historical claim count, in the same database transaction. Context, Insight retention, and terminal runs with files also create a pending availability record in their source transaction. A separate transaction verifies the committed source and confirms availability with a database timestamp rounded up to milliseconds. Retries preserve the original confirmation. Failed confirmation does not fail the saved source; the existing scheduler recovers at most 100 pending records per cycle using database locks and bounded retries. Insight confirmation runs outside the analytical query deadline.
Historical construction requires matching confirmation and checks selected measurement windows and
collection times against the cutoff separately. Application generation times and dates in document text
cannot prove availability. There is no fixed safety margin or historical backfill. An uploaded manifest,
a pending confirmation, or older evidence without confirmation returns historical_provenance_unavailable.
Ordinary application reads still work for old evidence. Construction itself remains read-only.
Both kinds of bookkeeping are protected from generic mutations and excluded from generated agent context. Context-only and file-only construction use general organization/profile checks without scanning Insight sources. Access is checked again after reads, together with the retained identities.
This milestone implements CWM-1 contracts and CWM-4 selection/construction for explicitly requested business information at a cutoff. It does not choose which metrics a business should model, calculate forecasts, publish business models, or create model proposals. Existing Oliver ownership is unchanged. Actual CWM-5 live-build and REP-2 replay integration remains a separate milestone; both will consume the shared constructor and retain the returned pins.
Verify a private example
Run the opt-in command from the repository root with the backend database and object-store environment already configured:
bun run world-model:check-inputs /absolute/private/acceptance.jsonThe private JSON has two fields: request, a worldModelHistoricalRequestSchema value, and model,
a WorldModelRevision. Both use the same organization and cutoff. Include at least one observed
variable referencing a measurement requested by the selectors. Keep the file (at most 10 MiB),
business content and credentials outside Git; credentials belong in the private backend environment.
The command verifies authenticated retained bytes and runs the existing observed-value checker. It then resolves and constructs twice independently, compares canonical bytes, pins and hashes, and confirms that each model observation cites a selected measurement with the correct confirmed availability. It does not generate a model or forecasts. Database transactions are read-only; storage writes, deletes and listing are blocked. It starts no server or background jobs.
Output contains safe check statuses, diagnostic codes/paths and a hash on success. Business values,
receipt contents and credentials are omitted. Exit 0 means all checks passed; exit 1 means validation
or verification failed; exit 2 means prerequisites are blocked or the configuration cannot be read.
Missing confirmation or required database schema leaves historical acceptance blocked even when
modelReceipts passes. Never create proof for old evidence to make this check pass.
The smaller bun scripts/check-world-model-fixture.ts /absolute/private/model.json remains available
for offline model/measurement consistency. It does not authenticate an arbitrary file. Disposable
PostgreSQL tests exercise the new command with synthetic subscription, commerce and operational
evidence; report their success separately from the private-instance result.
The earlier private receipt check does not prove the confirmation rule. Report code/test results and current authenticated historical acceptance separately. Separate forecast runs, structured plans, action catalogs, and larger model limits require their own design and evaluation.