Skip to content

Atlas harvest production-readiness (spec-driven blitz) - #135

Merged
jpr5 merged 9 commits into
mainfrom
blitz/atlas-harvest-prod/integration
Jul 7, 2026
Merged

Atlas harvest production-readiness (spec-driven blitz)#135
jpr5 merged 9 commits into
mainfrom
blitz/atlas-harvest-prod/integration

Conversation

@jpr5

@jpr5 jpr5 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Makes the Atlas harvest pipeline production-ready: it turns raw company-knowledge fragments (memory, GitHub, Notion) into a deduplicated, quality-gated, human-approvable seed corpus for the Pathfinder MCP retrieval layer.

What this does (by theme)

  • A — Seed quality (distillation gate): a distillation gate filters restatement/low-signal fragments and salvages the why/how content, so the corpus carries rationale rather than restated facts. approvable=false is enforced across all fact/behavior types; prose facts are human-gated.
  • B — Semantic dedup (RAG): near-duplicate seeds are collapsed via pgvector cosine similarity (supersedes the old lexical-tsvector probe, which was inert for long bodies), distilling to the delta so a duplicate never outranks or crowds out its original.
  • C — Validation hardening: strict + prose-aware validation; adapters populate structured validation targets (paths/symbols) that are checked against the checkout; sensitivity scanning runs over the raw body; exclusion rules are enforced fail-loud.
  • D — Embeddings/indexing dimension-safety: all embedding providers assert response dimensions at the provider boundary (fail loud, not an opaque pgvector crash).
  • E — Ops/preflight: config preflight validates required env fail-loud; harvest CLI threads a single run store; canonical-key discipline throughout.
  • F — Tests & runbooks: comprehensive red-green suites plus the scripts/atlas-harvest/ sandbox/leaf-fleet runbooks and README preflight guidance.

Every behavioral fix in this branch carries a red-green test.

Code review

11 unbiased reviewers × 7 rounds (Tier 3, verbatim byte-identical prompts). ~27 bucket-(a) fixes, including:

  • a GitHub credential-scan-over-distilled-body leak vector (sensitivity scan now runs over the raw body, not the stripped one);
  • 7 structural fixes (uniform marker-strip on verdict flips, a single shared artifact/upsert pipeline, semantic-dedup degraded-signal observability + CJK coverage, approvable-floor composition, content-drop);
  • 3 round-6 fixes (no-delta marker flip-strip — a self-introduced regression caught and closed; OpenAI embedding-dimension assertion; absolute-path citation capture);
  • 3 round-7 fixes (no-delta floor-marker excluded from rank scoring; GitHub unterminated-fence boilerplate recovery; verbatim-duplicate flooring).

Round 7 drove the core clean — the primary source-gate reviewer and the silent-failure specialist both returned no findings — and converged with zero load-bearing new bucket-(a). History is 8 plain-English commits by concern; one is a repo-wide prettier formatting-baseline (formatting-only, satisfies the CI prettier check).

Follow-ups (non-blocking, tracked in the CR ledger)

  • Rework the no-delta floor from a shared-carrier text marker into a dedicated typed field (net −40 LOC; removes the marker/carrier collision class structurally).
  • validate.ts isPathLike single-segment path-probe fallback; distillation-gate rewritten-branch empty-guard symmetry.
  • Hardening tail: embeddings token-batch cap, rag-dedup NaN-similarity telemetry, validate cross-candidate memoization.

Deferred

Production wire-on (S21) is intentionally deferred — it needs a ratified corpus first. This PR delivers the pipeline and quality gates, not the prod cutover.

Spec: https://app.notion.com/p/3953aa3818528102be21e433fc0e5351

@jpr5
jpr5 marked this pull request as ready for review July 7, 2026 02:56
@jpr5
jpr5 merged commit 826411b into main Jul 7, 2026
6 checks passed
@jpr5
jpr5 deleted the blitz/atlas-harvest-prod/integration branch July 7, 2026 02:57
jpr5 added a commit that referenced this pull request Jul 7, 2026
Prompt-only fix so the Atlas distillation judge's **rewrite** branch
retains concrete verifiable detail instead of abstracting it into
generic WHY prose.

## How this was found

A live prod-read-only dry-run of the just-merged harvest pipeline (#135)
over real memory fragments. One candidate — a precise admin-ops claim
(`POST /admin/:op`, `202/400/401/503`, `timingSafeEqual`, `trust_proxy`
fail-closed) — was rewritten by the judge into *"unified authentication
enhances security and simplifies access control,"* **dropping every
specific.** The 5 already-well-formed candidates were correctly passed
through untouched; only the rewrite path over-abstracted.

## Root cause

`DISTILLATION_SYSTEM_PROMPT` had no preservation constraint — it asked
for "why/how prose" and only guarded against *inventing* reasoning,
never against *dropping* facts. Its WHY-vs-WHAT framing had no category
for a precise HOW claim, so verifiable mechanics got recoded as
low-value WHAT and "elevated" to rationale.

## The fix (3 edits to `DISTILLATION_SYSTEM_PROMPT`, no gate/parsing
changes)

- Rewrite MUST retain every concrete verifiable detail (endpoints,
HTTP/error codes, symbol names, paths, config keys, numbers); sharpen
the WHY/HOW *around* them.
- A claim already stating a concrete mechanism is `distilled` — keep
as-is, don't rewrite up into rationale.
- If a rewrite can't keep every specific, return `distilled` instead —
losing a verifiable specific is worse than slightly-WHAT-flavored prose.

## Proof (real-LLM red-green — the actual failure surface, not fakes)

An opt-in eval (`OPENAI_API_KEY`-gated, `skipIf` so it's out of normal
CI) runs the real judge on the admin-ops fragment:
- **RED (pre-fix):** verdict `rewritten`, `POST /admin/:op` dropped —
3/3.
- **GREEN (post-fix):** verdict `rewritten` retaining `POST /admin/:op`
+ `timingSafeEqual` + `202/400/401/503` + `trust_proxy` — 4/4.

Plus a Layer-1 aimock gate-plumbing contract guard, and this closes the
`judgeDistillation` zero-coverage gap.

## Review

7 reviewers (Tier 2), 3 rounds. The prompt diff was clean (source-gate +
generalist reviewers: no findings). One in-subject test-quality fix —
the eval's `distilled`-fallback branch was made guard-independent
(`toContain(["rewritten","distilled"])`, fails loud on a `restatement`
regression) instead of a vacuous re-check. Converged with zero
in-subject bucket-(a).

**Blast radius:** the pass-through cases can only become *more* likely
to pass through; `restatement` untouched. 3410 tests green; the eval is
`skipIf`-gated.

## Follow-ups (non-blocking, tracked in the CR ledger)

- Code-enforce PRESERVE-SPECIFICS with a gate-side token-retention guard
(belt-and-braces beyond the prompt).
- Strengthen the eval's `distilled` path to assert the gate-layer
pass-through invariant.
- Add a through-the-gate test for `stripGitHubMetadataHeader`.
- Pre-existing `llm.ts` hardening surfaced by review (public→internal
floor, `CandidateFragmentSchema.parse`, embed finite-element check).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant