Yoke DB Reference
Raw item reads join item_refs r ON r.item_id = items.id and select r.public_ref. The read-only view follows prefix updates; project_sequence alone is ambiguous across projects. yoke db read warns when a query reads item ids (items.id or any *item_id column) without joining item_refs, and when a returned project_sequence lacks both public_ref and public_item_prefix.
yoke db read returns column values as stored. It refuses a query whose result includes a declared secret column (organizations.events_signing_key), including through SELECT *, with db_read_secret_column_refused; select the specific columns you need instead.
Source of truth: the configured Postgres authority. Agent-facing reads and
writes route through registered yoke ... commands or the Yoke
function-call surface. Everyday raw diagnostic SELECTs use
yoke db read "SELECT ...". python3 -m yoke_core.cli.db_router query
remains read-only source-dev/operator-debug diagnostics; never call raw database
clients directly and never hardcode a DB path or DSN.
A session holding a live steering seat on the repaired project, acting for an
org administrator, uses yoke operator data-repair --content-file repair.json --reviewed-sha256 SHA --dry-run
for bounded guarded repairs without a lane. Review the simulation before applying;
the repair contract owns durable before/after evidence.
Quickstart for session operators: AGENTS.md § Code Conventions, § Structured Item Writes, and § Governed DB Mutation. Update those sections when this file changes.
The function catalog owns registered ids, CLI adapters, claim verification and permanent boundaries. For a source-checkout Atlas, use yoke dev run -- python3 -m yoke_core.tools.atlas_render_docs render; this source-dev renderer is not a product command. Mutations use registered function ids; CLI adapters construct the same dispatched request.
This reference covers diagnostic columns, agent packets, registered operations, JSON payloads and common pitfalls. The database branch links migration conventions and governed repair; the Topic Index links current data-model homes, QA commands and the remaining event reference.
Common column mistakes to avoid in raw SQL
Quick reference for the columns most often mis-named in agent SQL. The DB-command column lint at yoke_core.domain.lint_db_rules_columns denies these patterns and points here; legacy telemetry/check ids remain stable.
epic_tasks: useepic_id(NOTitem_id),task_num(NOTtask_number/seq),dependencies(NOTdepends_on).epic_progress_notes: content is inbody(NOTnote).events: useevent_name/event_type/source_type/created_at/envelope(NOTtype/timestamp/source/detail/context/worker/payload/outcome).deployment_runs: useid(NOTrun_id),current_stage(NOTdeploy_stage),created_by(NOTcreator). Noitem_idcolumn — join throughdeployment_run_itemsfor item-bound runs.carried_workrecords resolved items and unresolved commit SHAs. A warning that changes what the run can attest isdeployment_runs.getattestation_warnings(reason, cost, recovery) — do not parsecarried_workJSON for that downgrade.deployment_run_items: userun_id+item_id(composite PK, NOidcolumn). Junction table only — has NOdeploy_stage,current_stage, orstatuscolumns. Stage data lives onitems.deploy_stageanddeployment_runs.current_stage. Zero rows are valid for started environment-level deployment runs.qa_runs: useqa_requirement_id(NOTrequirement_idorreq_id).deployment_flows: useid(NOTflow_id), noitem_idcolumn.shepherd_verdicts: usepublic_ref(public item key),transition(NOTgate).ouroboros_entries: content is inbody(NOTentry), usecreated_at(NOTtimestamp).project_capabilities: usetype(NOTcapability/name/capability_type),configfor full JSON (may contain secrets),settingsfor non-sensitive JSON.projects: useid(NOTproject_id/name) andgithub_repo(NOTrepo_url/github_url). Checkout paths are machine-local config, notprojectscolumns. Work-item-level deployment-flow defaulting lives in thedeploy_defaultsProject Structure family, not as a column onprojects.- Domain names:
epic(NOTepics),events registry(NOTregistry),runs(NOTdeploy-events); board rebuild isyoke board rebuild. - Live-claim holder lookup: use
yoke claims work holder-get PREFIX-N; inspect project steering holders withyoke claims steering list --project P --active-only. The typedwork_claimsmodel usestarget_kindplus one canonical JSONscope; session ownership issession_id. See Live claim-holder lookup.
Agent-context packet
Packets are generated by yoke_core.domain.schema_api_context from curated
seeds and schema introspection. Role audiences, topic ownership and budgets
live in its seed modules; rendered adapters use
yoke_core.domain.agents_render_context. Main, Architect, Engineer, Tester,
QA Walker, Simulator and Boss receive the current decision and executable
recipes their role needs. Explicit topic depth remains available for discovery.
Authorization, Pack, claims, project and QA teaching belongs to its owning
topic rather than a copied whole-registry roster.
yoke packets render --role main_agent
yoke packets render --role engineer_agent
yoke packets check
yoke packets budget get
yoke agents render
yoke agents render check
These adapters dispatch packets.render, packets.check,
packets.budget.get, agents.render.run and agents.render.check.
Run the owning command's --help for topic/depth selection and checks.
When schema or recipes change, update their curated owner and regenerate;
checks reject canonical/rendered drift and stale parallel examples.
The only packet insertion point is
<!-- YOKE:DB-PACKET role=R topic=T start --> ... <!-- YOKE:DB-PACKET end -->.
Do not hand-copy a second cheat sheet. QA plan materialization and review
ownership follow the active executor contract; a packet does not delegate
them merely by showing a command. harness_contract separately owns
manifest/bootstrap substrate facts. See the agent guide.
Topic Index
-
merge-queue-landing-attempts.md —
merge_queue_landing_attempts: a pull request opened for an item that already landed, tracked apart from the item's current landing until it merges or closes with its reason. -
Items, dependencies, tasks and landings describe work records and their history.
-
Session path claims describe physical-path coverage; steering reports and delivery describe coordination projections, including dependency deadlocks and waiting chains.
-
Steering dependency sections describe the shared live blocking graph and minimal dependency rules.
-
Workflow statuses describe immutable workflow pins and independent generated-task progression.
-
Deployment runs, stage receipts and run timings and members and QA describe execution and release custody.
-
Release authorities and notices describe verification, verdicts and delivery announcements.
-
Projects and capabilities describe the project registry and Project Structure aggregate; sites, environments and flows describe deployment targets and pipelines.
-
QA records describe requirements, runs and artifacts; session records describe harness identity and work claims, and shared coordination describes leases and session accounting.
-
Event records describe events, severity configuration and the registry; preview and ephemeral environments describe environment tracking.
-
Machine-local evidence describes bounded relay, watcher and diagnostic retrieval.
-
QA CLI describes QA commands; body writes describes structured-content writes and rendering.
-
Function catalogs describe registered operations, claim policies and typed envelopes.
Entry points
yoke <subcommand> [args...]
yoke db read "SELECT ..."
Lifecycle-owned writes (item status, deploy_stage, epic_task status, the
events table) are not available through query — use the sanctioned
mutators below. The Python lint owners enforce the separation.
Bootstrap contract
Normal runtime commands (reads, domain dispatch, structured-field writes) never trigger schema/domain bootstrap as a side effect. The module chain under _AUTO_INIT_MODULES runs only when:
- the operator invokes the explicit schema bootstrap subcommand; or
- the calling process sets
YOKE_DB_INIT_ALLOW=1(test fixtures, first-run provisioning, cross-worktree DB creation).
When a normal command runs against an existing DB whose baseline schema is missing (no items table), the router refuses the command and prints remediation pointing at db_router init. No silent CREATE TABLE as a side effect of a read-looking command.
Additive schema self-propagates on deploy. Separately from the CLI bootstrap path above, the API server entrypoint (yoke_core.api.server_entrypoint.ensure_core_schema) runs the full idempotent schema_init.converge_core_schema — every CREATE TABLE/CREATE INDEX plus additive ADD COLUMN step — on every boot of an already-born universe. So any net-new additive table or column added to the schema-init chain reaches every born universe on its next deploy/restart with no governed migration and no manual catch-up. Foreign keys onto environments.id match the live primary-key type so a universe still on text keys reaches the ordered history that converts them, rather than failing the boot. Data-transforming changes — backfills, drops, rewrites — go in the ordered migration history instead, and are applied by the same boot converge.
Registered operations
Use yoke --help for the live product command roster and the
function catalog for complete payloads and
family homes. Items, epic tasks, sections, verdicts/dependencies, projects,
flows/runs, ephemeral environments, events, QA, releases and Ouroboros each
retain their registered owner. Python service-client modules are internal
implementation, not an agent mutation surface. New item intake uses
/yoke idea; the pinned workflow owns lifecycle targets.
# Narrow reads; choose the actual pinned stage rather than a copied sequence.
yoke items get PREFIX-N status
yoke items dependency list PREFIX-N
yoke project-structure get --project P --family test_roots
yoke qa requirement list --item PREFIX-N
# Complete intended content is file-backed; additive transforms stay native.
yoke items structured-field replace PREFIX-N --field spec --stdin < /tmp/spec.md
yoke items structured-field section-upsert PREFIX-N --section "Goals" --content-file /tmp/goals.md --ordering 100 --source operator
yoke items progress-log append PREFIX-N --headline "Verification" --content-file /tmp/update.md --source operator
# Diagnostic item reads retain current project-qualified identity.
yoke db read "SELECT r.public_ref, i.title FROM items i JOIN item_refs r ON r.item_id=i.id WHERE i.status='implementing'"
Read each command's --help before changing its payload or selecting a
write. The QA CLI owns QA
requirements and artifacts; body writes owns structured transforms; the
deployment run home owns registered run recipes;
members and QA owns custody. Deployment flow/run adapters are
available; discover their current shape rather than treating them as pending.
Exit codes: 0 success, 1 error/not found, 2 usage error.
JSON-payload columns
JSON payload shape is separate from physical SQL type. The candidate's
yoke_core.domain.sql_json.JSONB_COLUMNS enumerates these native-type targets;
inspect live schema before claiming a universe has completed that cutover.
json_get handles empty/nullable TEXT by casting for extraction;
json_set_expr preserves the current TEXT writer contract.
| Table | JSON-payload columns |
|---|---|
events |
envelope, anomaly_flags |
items |
db_mutation_profile, db_compatibility_attestation |
qa_runs |
raw_result |
qa_artifacts |
metadata |
deployment_flows |
stages |
deployment_runs |
carried_work, bound_sources |
migration_audit |
baseline_verify_result, author_verify_result |
path_context_values |
value |
function_call_ledger |
result |
github_workflow_dispatch_intents |
inputs |
pack_catalog |
dependencies_json |
Event envelopes are objects; anomaly flags are arrays at native cutover
(legacy storage may be comma-separated). QA stores tool-result/metadata
envelopes, flow stages are an array, and carried work contains resolved items,
bare commits and named empty reasons. Topic schemas own exact shapes.
Separately, typed work_claims.scope is a canonical JSON object selected by
target_kind; it is not an entry in the legacy TEXT-target enumeration above.
Markdown and plain-text columns are NOT JSON payload and stay TEXT on both dialects. Authoring agents occasionally conflate "long text stored in a DB column" with "JSON payload" — they are different. The following columns are markdown or plain text and must not be annotated with → JSONB on Postgres:
items.spec,items.design_spec,items.technical_plan,items.worktree_plan,items.shepherd_caveats,items.test_results,items.deploy_log— structured markdown per the virtual-body-field model (docs/archive/decisions/virtual-body-field.md).epic_progress_notes.body— markdown.shepherd_verdicts.caveats,ouroboros_entries.body— markdown.release_entries.title,release_entries.version,release_entries.category,release_entries.project— plain-text identifiers.
Postgres target for markdown/plain-text columns: TEXT (or VARCHAR(N) for bounded identifiers).
Common Pitfalls
- Function is
query_item, NOT_query_item - SQL operators: use
<>not!=. - Prefer registered
yoke ...readers over raw SQL in shell scripts for single-item operations. - Structured fields: Pipeline stages write to structured DB fields (
spec,shepherd_caveats,design_spec,technical_plan,worktree_plan, …) through the Yoke function-call surface: agents call function ids such asitems.structured_field.replace,items.structured_field.append_addendum,items.structured_field.section_upsert,items.structured_field.section_append,items.section.upsert, anditems.progress_log.append. The CLI commands (yoke items structured-field replace,yoke items structured-field append-addendum,yoke items structured-field section-upsert,yoke items structured-field section-append, andyoke items section upsert) build the matchingFunctionCallRequestand dispatch through the same registry. The body is a generated view assembled byyoke_core.domain.render_body. Never use ad-hoc sed chains or awk on body content. Full payload shapes, claim-verification rules, and event emissions live in db-reference/functions.md. - Structured-field transforms (agent path): Two operations, one envelope each. Full-field rewrites call
items.structured_field.replacewith the complete intended content. Additive transforms (preserve existing content, append a## heading-led block) callitems.structured_field.append_addendum/section_upsert/section_append. The handler reads through canonical DB routing, applies an idempotent transform, writes via the existing guarded structured-write path (preserving empty/shrinkage/freeze guards), and re-reads to verify. Reading a structured field withitems get, redirecting through a temp file or shell variable for transformation, and piping back intoitems update --stdinis blocked byyoke_core.domain.lint_structured_field_transform_shell. Bypass:# lint:no-structured-transform-check(audited). - For bulk reads in shell scripts, use
yoke db read --jsonor a registered read adapter rather than raw database clients. frozenis INTEGER in DB (0/1) butquery_itemmaps it to "true"/"false"