Home / Projects / Orchestrata Ultimate / Decisions / ADR index / ADR-0074

ADR-0074: The prod promote re-embeds only changed semantic chunks and probes the embedding provider before the tree moves

field value
Status Accepted — Accepted (ruling, Mohamed, 2026-10-07: "adr 0074 agreed")
Date 2026-10-07
Register factory (docs/adr, 4-digit ids)
Source docs/adr/0074-prod-promote-embeds-only-changed-chunks-and-probes-the-embedding-provider-at-infra.md — permalink at 98f80b0df (unchanged on master since that commit)
Wiki register entry ADR-0074 (wiki status: Accepted)

← ADR-0073 · ADR-0075 →

The record

Status: Accepted (ruling, Mohamed, 2026-10-07: "adr 0074 agreed") · Date: 2026-10-07

Context

promote_env.py promote --to prod ends with a graphs stage (src/orchestrata_ultimate/promotion/stages_graphs.py:25-82) that runs bootstrap_graphs.py --all from the deployed tree: the operational-KG chain (schema, AST full sync, architecture sync, spec enrichment) and then the Memgraph step ingest_orchestrata_ultimate.py, which chunks the source tree and embeds every chunk through OpenRouter (mistralai/codestral-embed-2505, dim 1536, label CodestralChunk). The stage is part of the promote's success gate: a FAIL rolls the tree back and restarts the units on the previous commit (promotion/runner.py).

Measured on 2026-10-07 (plans/ast-daemon-deployment-plan.md § 3b, rows ab189ccc7 and c8c4ddd23; logs p6a_ship3.log, p6a_ship4.log):

The forcing fact is the last one combined with the first: a metered external API that the promote calls ~570 times per ship, on text that did not change, decides at the very end whether a deploy that has already passed verify stays or rolls back.

Decision (proposed)

  1. The semantic ingest becomes incremental by content hash. Every chunk node carries content_sha256 (hex of the chunk text). ingest_directory reads the existing (id, content_sha256) pairs for the project before embedding, embeds only chunks whose id is new or whose hash differs, and deletes chunk nodes under the project whose id no longer exists in the tree. A promote whose ship changed no chunked file performs zero embedding calls. The first run after Accepted re-embeds everything once to record the hashes.
  2. The infra stage probes the embedding provider before the tree moves. With the same key the deployed tree will use, it reads the provider's credit/limit endpoint (for OpenRouter GET /api/v1/credits) or, where no such endpoint exists, embeds one short string; a 401/402/403, or a balance that cannot cover the estimated run (changed_chunks × per-call cost, zero when nothing changed), is [FAIL] infra embedding provider: <status> and the promote is refused before any unit is restarted. No rollback is needed because nothing moved.
  3. graphs keeps --all. "Promoted to prod" continues to mean both graphs are derived from the deployed commit; the stage simply stops paying to re-derive text it already holds.

Alternatives rejected

Consequences

On Accepted: packet P6c of plans/ast-daemon-deployment-plan.md builds items 1–2 against semantic_graph/ingestion.py, semantic_graph/adapters/memgraph.py (read existing hashes, delete stale ids), promotion/stages_resolve.probe_endpoints + promotion/env_profile.probe_infra (provider probe) and promotion/stages_graphs.py (unchanged --all), with real-Memgraph tests on the test fleet (10.53.2.10) proving: an unchanged tree embeds nothing; a one-line edit re-embeds exactly the chunks covering that line; a removed file's chunks are gone; a 402 from a local HTTP stand-in is refused at infra with no unit restarted. A no-change promote's graphs stage drops by ~5.5 min; a credit lapse surfaces in seconds at infra with the instruction to top up, instead of after a restart-and-rollback cycle. The Definition of Done (ADR-0069) applies: @traces, RTM, docs (docs/ship-and-deploy.md), wiki, ≥90% coverage, one ship. Until Accepted, prod stays at ab189ccc7 and the next promote needs credits on the account; nothing in /opt/orchestrata needs the two commits master is ahead by (both are ship-side).

Provenance

Orchestrator finding F-P6a-2, 2026-10-07, from the c8c4ddd23 ship (p6a_ship4.log: [FAIL] graphs 449.8s bootstrap failed: … VectorSearchError: OpenRouter embeddings HTTP error 402; [OK ] rollback returned to ab189ccc722f and restarted 4 unit(s)), the ab189ccc7 ship (p6a_ship3.log: 570 embedding POSTs 06:22:11–06:27:40, [OK ] graphs 835.6s), and the OpenRouter /api/v1/credits reading taken with the prod key right after the failure (total_credits 1148, total_usage 1148.22191807). Code: src/orchestrata_ultimate/semantic_graph/ingestion.py:134-199, 271-313; src/orchestrata_ultimate/promotion/stages_graphs.py:25-82; scripts/bootstrap_graphs.py --help; scripts/ingest_orchestrata_ultimate.py --help. Awaiting Mohamed's ruling; only he rules.

Relations of ADR-0074

Rulings cited

None.

Specs cited

None (or no spec page exists for the ones named).