Arxi Contract Generation and Projection Architecture
Executive Overview
arxi-contract is the canonical deterministic generator/checker for Arxi
projection artifacts. It emits schema/contract/example/glossary/tooltip outputs
under Docs/generated/arxi/ and enforces fail-closed drift checks.
Tooltip generation is now world-class projection metadata with:
- backward-compatible tooltip manifest (
tooltips.json), - rich term catalog (
tooltips.catalog.json), - pointer/token bindings for code blocks and JSON examples
(
tooltips.annotations.json), - glossary markdown (
glossary.md) generated from the same term source.
Artifact Authority
Authoritative generator code:
crates/arxi-contract/src/lib.rscrates/arxi-contract/src/sidecar_api.rscrates/arxi-contract/src/sidecar_api/openapi.rscrates/arxi-contract/src/sidecar_api/artifacts.rscrates/arxi-contract/src/sidecar_api/specs/mod.rs
Authoritative generated root:
Docs/generated/arxi/
Machine manifest authority:
index.json includes contract version plus per-artifact SHA-256 hash metadata.
When sidecar API artifacts are present, compatibility gates are enforced from
generated artifacts via scripts/ci/sidecar_contract_gates.py.
Generator Modes
arxi-contract supports two deterministic modes:
GenerateMode::Generate- Regenerates artifacts and rewrites output root.
- Removes stale unexpected files under output root.
- Fails closed if output-root traversal encounters symlinks or unsupported filesystem entry types.
GenerateMode::Check- Fails closed on missing files, byte drift, or unexpected files.
- Fails closed if expected paths resolve through symlinked roots/components or non-regular files.
CLI integration:
arxi contract generatearxi contract check
Determinism Model
Determinism controls include:
- stable artifact ordering via ordered maps/sets,
- canonical JSON encoding via JCS,
- explicit SHA-256 hashing for manifest entries,
- check-mode byte comparison against committed files.
Constraint-Aware Schema Projection
Schema generation is two-stage:
- infer structural shape from deterministic sample artifacts,
- apply authoritative domain constraints by JSON-pointer overlay.
Constraint overlays include:
- strict UUID text shape policies for all ID fields,
- hostile-string and max-length constraints for identifier/text fields,
- strict event-type regex policy and length ceiling,
- strict
key_idregex policy (^[0-9a-f]{64}$), - fixed-length byte-array constraints for hash/signature fields,
- explicit nullable representations for optional fields,
- full
BundleSelectoralgebra projection (BySegment,BySegments,ByTrace,ByTimeRange,ByEnvelopeIds,ByFilter, recursiveComposite) via schema$defs.
Projection fails closed if expected pointer paths are missing while applying constraints.
Produced Artifact Set
Current v1 emitted files:
index.jsonschemas/envelope.schema.jsonschemas/segment.schema.jsonschemas/bundle.schema.jsoncontracts/adapter.jsoncontracts/provider.jsonglossary.mdtooltips.jsontooltips.catalog.jsontooltips.annotations.jsonexamples/envelope.jsonexamples/segment.jsonexamples/bundle.jsonapis/sidecar.openapi.jsonapis/sidecar.errors.jsonapis/sidecar.enums.jsonapis/sidecar.examples.jsonapis/sidecar.compat.jsonconfig/sidecar.schema.jsonconfig/sidecar.compat.jsonconfig/sidecar.example.tomlconfig/sidecar.md
Conformance and Validation
arxi-contract unit tests validate:
- repeated generation determinism,
- manifest hash/file-byte consistency,
- generated examples validate against generated schemas,
- tooltip catalog includes all adapter/provider contract method names,
- required world-class core term coverage,
- tooltip catalog pointers resolve against generated JSON artifacts,
- tooltip annotation bindings only reference defined term keys,
- schema/runtime invariance for
key_id, hostile text fields, and identifier max-length constraints. - sidecar artifact emission and manifest inclusion.
- sidecar error-registry and compatibility-baseline consistency.
- sidecar OpenAPI/compat idempotency contract consistency.
- sidecar config artifact consistency (schema/compat/example/docs linkage).
arxi-contract dedicated path-safety tests validate:
- generate mode rejects symlinked output roots,
- generate mode rejects symlinked child paths under output root,
- check mode reports byte drift for modified artifacts,
- check mode rejects symlinked expected artifact files.
Orchestration and CI
One-command orchestration entrypoint:
scripts/ci/generate_all.sh
Behavior:
generate: regenerate contract artifacts + run sidecar contract gates + regenerate testing coverage docs.check: run contract drift check + sidecar contract gates + docs drift check (fail closed).- Optional release mode: if
ARXI_SIDECAR_PERF_GATE=1, enforce sidecar SLO metrics viascripts/ci/sidecar_perf_gate.pyagainst generated perf report artifacts.
CI workflows run this in required quality gates.
Projection Handoff Boundary
Website/i18n handoff and glossary ownership policy:
Docs/roadmap/arxi_generated_contract_sync_and_glossary_policy.md
This defines required file presence, hash verification, path stability, and single-source glossary/tooltip ownership.