Repository navigation
reference data models
Sych stores immutable, versioned review documents alongside mutable operational rows and repository-scoped API views. The Rust DTOs are the schema source; the database does not normalize every field of a review result into tables.
flowchart TD
Source["SourceSnapshot and DiffManifest"] --> External["ExternalInputManifest"]
Policy["PolicySnapshot"] --> External
External --> Evidence["EvidenceManifest"]
Facts["Derived facts and Evidence"] --> Evidence
Evidence --> Result["ReviewResult"]
Source --> Result
Policy --> Result
Result --> Tour["TourArtifact"]
Result --> Handoff["Handoff"]
Result --> Lifecycle["Mutable run, finding lineage and publication rows"]
The arrows are identity dependencies, not embedded ownership of every byte. Sources: crates/sych-core/src/snapshot.rs, crates/sych-core/src/freeze.rs, crates/sych-core/src/result.rs, crates/sych-core/src/tour.rs, crates/sych-core/src/handoff.rs.
SourceSnapshot pins repository, optional target ref, target_tip, diff_base, head, comparison mode and source/diff manifest hashes. Its content identity excludes display ref, ID and creation timestamp. MERGE_BASE computes the comparison from target/head; EXPLICIT_DIFF_BASE records an explicit two-dot base.
DiffManifest retains old/new paths, modes, blob OIDs, content kind, hunks, rename/copy similarity, trusted generated classification, untrusted generated claims and explicit omissions. A deleted file can have only old side; an addition only new side. Binary, links, submodules, LFS pointers and unread content remain represented, not silently dropped.
CodeRef binds snapshot_id, side: DIFF_BASE|HEAD|TARGET_TIP, repository path, blob OID, 1-based inclusive start/end lines and line-content SHA-256. SnapshotReader verifies references against pinned objects. Sources: crates/sych-core/src/snapshot.rs, crates/sych-core/src/manifest.rs.
PolicySnapshot binds source (engine_defaults or a trusted ref/commit), normalized rules/config hashes and authorization-policy version. Effective configuration/provenance is distinct from this compact identity document. Source: crates/sych-core/src/policy.rs; see Configuration.
| Type | Relationship and invariants |
|---|---|
Evidence |
UUID ID, source snapshot, kind, producer/version/config hash, source/CI/environment binding, validity, completeness, trust class, artifact digest, code references, limitations and observed time |
ExternalInputManifest |
Snapshot + policy + sorted external evidence IDs/kinds/digests, frozen before analysis; time excluded from content ID |
EvidenceManifest |
Final sorted records for frozen inputs plus evidence derived from the pinned snapshot; records each origin, validity and digest |
RunFacts |
Normalized semantic, syntax, CI, effect ledger, lint and schema-reference data used by analysis |
ContextPackets |
Bounded selected source/evidence and explicit exclusions/gaps shown to model passes |
Evidence kinds are source, semantic, static, test, coverage, contract, infrastructure, human. Validity is VALID|STALE|UNAVAILABLE|MALFORMED|FAILED; completeness is COMPLETE_FOR_QUERY|PARTIAL|UNKNOWN. Trust is separately TRUSTED_POLICY|SOURCE_OBSERVATION|DERIVED_LOCAL|AUTHENTICATED_CI|AUTHOR_CLAIM|HUMAN_ATTESTATION.
Freeze rejects foreign-snapshot evidence, source-derived records presented as external inputs, and external evidence not matching a frozen ID/digest. External status is determined by binding kind, not by a convenient artifact filename. Sources: crates/sych-core/src/evidence.rs, crates/sych-core/src/freeze.rs. Trust interpretation belongs to Security.
ScopeManifest fixes revision, units, required obligation IDs, requested profiles and exclusions before discovery. A ReviewUnit groups related changed paths, with risk hints that are routing hints rather than proof.
Obligation joins rule ID/version, question, requirement/risk, unit IDs, code refs, three-valued applicability and accepted evidence kinds. Final status is a tagged union:
SUPPORTEDVIOLATEDUNKNOWN {reason_code, next_evidence_needed}NOT_APPLICABLE {basis}
Evidence IDs, limitations and scoped waivers accompany the answer; pending work is not a fifth final status. Sources: crates/sych-core/src/result.rs, crates/sych-core/src/obligation.rs.
Candidate is a hypothesis with claim, causal chain, anchors, conditions, refutation, evidence/obligation IDs and verification state. Its VerdictRecords preserve proposed versus accepted verifier status and engine problems. A Finding adds accepted severity/support, consequence, validation expectation, fingerprint, predecessor and lifecycle. Overlapping lower-severity confirmed findings can remain in also; an optional suggested change binds replacement text to exact HEAD lines. Source: crates/sych-core/src/finding.rs.
ReviewResult joins run/result/revision/parent IDs, source/policy/evidence-manifest IDs, fixed scope, execution outcome, coverage, recommendation, findings, obligations, questions, excluded paths and usage/provenance. Rejected/unresolved candidates remain explicit internal review data. A tour or handoff reads that committed revision rather than rewriting it (crates/sych-core/src/result.rs).
| Dimension | Values |
|---|---|
| Execution state |
QUEUED, RUNNING, WAITING_EVIDENCE, RETRY_WAIT, FINALIZING, COMPLETED, CANCELLED, SUPERSEDED, FAILED
|
| Result execution outcome |
PLAN_EXECUTED, LIMIT_REACHED, RETRIES_EXHAUSTED, INPUT_UNAVAILABLE
|
| Coverage |
COMPLETE_FOR_SCOPE, PARTIAL, UNAVAILABLE
|
| Recommendation |
ATTENTION_REQUIRED, NEEDS_EVIDENCE, NO_BLOCKING_FINDINGS_IN_SCOPE
|
| Publication operation |
PENDING, PUBLISHING, CONFIRMED, UNCERTAIN, FAILED, SUPERSEDED
|
| Mutable relevance |
CURRENT, STALE
|
Only completed runs have saved results. Publication/relevance stay outside immutable result content; no enum alone is “the verdict.” Source: crates/sych-core/src/status.rs; rationale: Background.
document_schemas() in crates/sych-core/src/schema.rs registers these 14 JSON Schema files:
Artifact stem in schemas/
|
Rust type |
|---|---|
source-snapshot.schema.json |
SourceSnapshot |
diff-manifest.schema.json |
DiffManifest |
policy-snapshot.schema.json |
PolicySnapshot |
evidence.schema.json |
Evidence |
external-input-manifest.schema.json |
ExternalInputManifest |
evidence-manifest.schema.json |
EvidenceManifest |
review-result.schema.json |
ReviewResult |
semantic-facts.schema.json |
SemanticFacts |
context-packets.schema.json |
ContextPackets |
run-facts.schema.json |
RunFacts |
deployment-model.schema.json |
DeploymentModel |
transition-matrix.schema.json |
TransitionMatrix |
tour-artifact.schema.json |
TourArtifact |
handoff.schema.json |
Handoff |
crates/sych-core/src/api.rs separately generates schemas/openapi.json from HTTP DTOs and manually assembled operation descriptions. Dashboard types derive from that file. Generation does not make OpenAPI the router authority. Run just schemas after DTO changes and check crates/sych-core/tests/contracts.rs.
Versioned documents use schema_version: 1; decode probes the major before other field validation and rejects missing/unknown majors. Do not assume that additive fields make new enum values backward-compatible. Source: crates/sych-core/src/version.rs.
| Value | Format/meaning |
|---|---|
GitObjectId |
sha1:<40 lowercase hex> or sha256:<64 lowercase hex>
|
Sha256Digest |
sha256:<64 lowercase hex> |
SourceSnapshotId, PolicySnapshotId
|
Content-derived snapshot identity wrappers |
| Run/result/evidence/obligation/finding/tour IDs | UUID-backed typed IDs; generation method depends on the producer |
RepoPath |
Validated repository-relative path, not an arbitrary host path |
MicroUsd |
Integer micro-USD, not floating-point dollars |
| Domain timestamps |
jiff::Timestamp serialization; many operational API views instead expose Unix seconds |
Sources: crates/sych-core/src/primitives.rs, crates/sych-core/src/api.rs. Do not confuse a result's UUID finding ID with the numeric finding row used in dashboard feedback/history URLs.
RunStatus is a mutable operational view with state/stage, generation, parent run, usage, failure and optional coverage/UNKNOWN count. RunSnapshots returns full policy and optional source, which can be null after shorter retention. PublicationStatus returns delivery and relevance separately. TourView joins immutable tour with caller-private session/exchanges and a stale marker. See API.
Usage distinguishes known charge, reference estimate, unknown-cost attempts, unknown token usage and per-route billing/enforcement. Reasoning tokens are already included in output tokens; subscription quota is not free money and unknown usage is not zero (crates/sych-core/src/result.rs).
Both backends currently have 25 application tables, excluding _sqlx_migrations. The authoritative import inventory is TABLES in crates/sych-storage/src/import/schema.rs; both migration trees implement it.
| Group | Tables |
|---|---|
| Repository/change state |
repositories, changes, change_events, change_intents
|
| Work lifecycle |
runs, jobs, run_reasons
|
| Content pointers |
artifacts, run_artifacts
|
| Model accounting |
model_attempts, subscription_fees
|
| Admission/retry identity |
inbox_events, idempotency_keys
|
| External delivery |
publication_objects, publication_operations
|
| Finding/risk policy history |
findings, finding_events, feedback, waivers, suggestion_decisions
|
| Reader identity/progress |
sessions, tour_sessions, tour_exchanges
|
| Audit/notifications |
audit_events, digest_deliveries
|
Artifact retention and operational-row retention differ. Source/diff artifacts normally retain seven days, other normalized documents thirty; active work and unresolved publication pin artifacts. Missing bytes are unavailable, not regenerated. See Durable storage for backend transactions, GC, migrations and offline import.
| File | Change here |
|---|---|
crates/sych-core/src/schema.rs |
Register an externally versioned document |
crates/sych-core/src/version.rs |
Major-version decoding policy |
crates/sych-core/src/snapshot.rs |
Immutable source identity and coordinates |
crates/sych-core/src/freeze.rs |
Input/evidence identity invariants |
crates/sych-core/src/result.rs |
Saved result and usage contract |
crates/sych-core/src/api.rs |
Public HTTP DTOs, distinct from storage structs |
crates/sych-storage/src/import/schema.rs |
Exact application-table inventory/import validation |
Change Rust types, generated schemas, old fixtures and consuming API/dashboard types together. A database change also needs backend migrations and import-contract validation.