Skip to main content

V7 repository-map design — draft for core#3680

Status: awaiting founder decisions D10–D14 and measurement authorization. Author: backend-sme. Source inspection: core main 5daba852b, 2026-09-30. PRD amendment: #2995 proposal §17. Scope: design only, Tier C milestone 38. No implementation or milestone 37 work.

2026-11-26 direction checkpoint​

Repository maps remain bounded orientation artifacts. The next substantive step is evidence-backed retrieval and evaluation across exact source revisions, rather than expanding the draft directory hierarchy into a large wiki without measured task value. The offline structural evaluator in repository-intelligence-evaluation.md records the first approved slice: pinned tasks, honest incomplete outcomes, source-bound citations, and separate unknown coverage and cost measures.

This checkpoint does not accept this historical V7 draft, select a production index, alter the map format, or authorize source/model traffic. It supplies a reproducible gate for comparing later retrieval designs before any production or schema decision.

What is known and what is not​

The present code validates one repo-map-v1 hash and admits at most 10,000 tree entries. Provider transport/probes pin GitHub hosts. The generated root map has six kinds and a 24,000-byte complete-document limit. This design builds on V3's provider seam; it does not start V3 or reopen its approvals.

A complete HLD cannot yet be submitted for acceptance: #3680 requires its limits and navigation threshold to come from a real measurement. No disposable large fixture or charged-run authorization was supplied. Every pending D13 cell below is a blocking unknown, not an infinite cap or a default. This file is the concrete proposal to review while that input is obtained. It is not a measured HLD or authority to start implementation.

Proposed composition and authority​

  1. Existing registered-repository scope resolves the exact organization, team, numeric upstream repository, approved host and live credential epoch.
  2. The V3 provider seam resolves the target ref to a commit and obtains only the authorized repository's read credential. The clone transport consumes that result, never an arbitrary caller URL or an agent's ambient git credential.
  3. Fetch the pinned commit to a run-owned ephemeral object store. Restrict git protocols to the approved HTTPS origin and repository; do not execute hooks, filters, helpers, submodules, LFS processes or repository instructions. No inherited global/system git config, interactive prompt, credential in argv, credential in remote URL, unrestricted redirect or secondary-host fetch. Credentials are stage-local and redacted; diagnostics contain classifications and counters, not bodies or secrets. Exact implementation requires security review of subprocess environment, credential delivery and host enforcement.
  4. Enumerate the complete immutable tree. Apply symlink/submodule, generated, vendor, binary and secret exclusions before bounded body reads. Count both manifest entries and excluded/eligible entries; reject truncation. Filtering support is discovered, not assumed. If the server refuses fetching the exact SHA, fetch the already-authorized ref and refuse if its tip differs from the previously resolved commit; never silently generate from the moved ref. An unsupported sparse/object filter may fall back only within the same pre-admitted transfer, disk and time envelope; otherwise refuse, without silently fetching the entire history.
  5. Build a deterministic directory evidence graph without executing source. Module/package documentation and explicit ownership metadata are evidence, not instructions or authority. The hierarchical generator summarizes only supported facts with unknown states for insufficient evidence.
  6. Each generation stage uses the existing direct AgentTokenMinter.Mint path, exact LLM audience/identity, finite reservation and actual usage reconciliation. New v2 counts include every stage, retry and repair. Zero attributed usage after model work blocks publication and alerts. No session, tools, extraction side channel, direct provider inference or hidden unmetered hierarchy stage.
  7. Final commit/revision/epoch/authority checks fence publication of the root and children atomically. Known denial withholds all pages through the same source state; exact-epoch restoration cannot override a human denial. Unknown transport failure is not evidence of revoked access. Unfinished graphs are not published as complete maps.
  8. Purge every source object and buffer on all terminal paths; an orphan sweep and revoke/remove/offboard paths cover crashed processes and abandoned files. Do not share source storage with another team or a coding-agent workspace.

Map and read contract​

Keep root order: purpose, responsibilities, directory_ownership, conventions, related_repositories, do_not_touch. The root directory index holds a bounded set of top-level entries and immutable page references rather than flattening all paths. The root remains at most 24,000 UTF-8 bytes including mandatory headers; no new section silently consumes another section's budget. Current v1 publication allocates each section (24000 - len(header))/6 - 512 UTF-8 bytes (integer division): at most 3,488 even with an empty header, less with real metadata. The directory index must fit that exact allowance. If top-level entries do not fit, render a bounded complete-entry prefix plus an index-page reference and the remaining entry count, reserving those bytes before selecting the prefix. Never rely on truncating a directory index; no clipped entry or dropped tail may replace explicit continuation. Index pages use the same bounded continuation contract recursively. do_not_touch remains last and protected. Child pages carry directory-local equivalents of these fields; the presence of the hierarchy is not an inferred ownership grant.

A directory entry has a normalized repository-relative path, explicit parent, evidence-backed purpose, owns/touch-when, declared owners or unknown, observed entry points, module/package-doc references, child-page references and evidence paths pinned to the generation commit. A child page records generation/run id, commit/ref, policy/recipe version, observed tree/body counts and omissions. Source excerpts are not persisted in these pages. Generated prose may summarize source; it must not turn the result store into retained source-body storage.

Page identifiers are opaque scoped references: every read re-derives org/team, repository, generation and current source-access state. A saved or foreign page reference cannot bypass withholding. Root and children share mandatory honesty, coverage, provenance and freshness headers. Every root, directory and index page read labels the repo-wide complete tree-entry count and sampled-body coverage/omissions separately from its directory-local observed/sampled counts. Each page identifies the root map, generation/run, pinned commit/ref and policy/recipe version; section attribution distinguishes generated runs from actual curators. Freshness is the root's read-time currentness/staleness and observation qualification, including unknown states, not merely a cached child timestamp. These are the TK-8.2/8.3/8.4/8.5/8.7 extensions in PRD §17; TK-8.8 additionally requires the paginated read API and agent-facing MCP consumer to ship together, with scoped child traversal and the same read qualifications. Pagination cannot mean unknown entries silently disappear; expose remaining page count and traversal limits. Exact per-page/index/result caps are D13 outputs. A client cannot request an unbounded recursive expansion. Legacy root-only reads remain valid.

Storage proposal: retain the current root section/curation contract and add versioned directory-page records keyed by org/map_id/generation/path, with composite foreign keys to the root map and RLS, rather than multiplying the six section_kind values per directory. Decide schema names in the approved LLD; none is claimed to exist. Child curation locks/divergences inherit TK-8.4 at the page-section grain. A locked v1 root section is preserved verbatim; if it contradicts newly generated hierarchy, report the divergence instead of rewriting it. When the locked section is directory_ownership, a system-rendered navigation block in the mandatory root header, outside the curated body and neither curatable nor lockable, carries the bounded complete-entry prefix with index/child-page references, named continuation and remaining entry count. Charge navigation only to the root header allocation, within the same 24,000-byte document limit; never take it from a section's allocation or reduce a locked section's budget. In particular, appending navigation to len(header) and recomputing the v1 six-way formula above is not the v2 allocation rule. The measured v2 header allocation must cover required metadata and the bounded navigation together while preserving the existing section allocations; its numeric bound remains pending D13. If those bytes do not fit, refuse v2 publication with a named navigation-header-budget divergence requiring curator action, leave the v1 map serving with its actual version, and never clip the lock, drop navigation, or borrow section bytes. Curator action is explicit; retry alone cannot relax this bound. The locked-v1 migration fixture sizes directory_ownership at its v1 per-section maximum and uses an index that overflows. When the header fits, assert the unchanged locked bytes, complete child traversal and whole-document limit together; when it does not, assert the named refusal and unchanged serving v1 map, with no partial v2 publication. Paginated read API and MCP consumer must ship together and get authority witnesses.

D12 migration and rollback​

Do not change the meaning of repo-map-v1. A version-aware registry recomputes both approved hashes from exact tuples; accepting an arbitrary version/hash is not compatibility. Admission binds the selected immutable envelope to each run.

Proposed explicit manager operation upgrades one setup with expected revision: lock scoped setup, agent and policy rows; reject unrelated ownership or stale revision; fence prior work; compute all three records server-side; validate the candidate tuple before commit; commit the new revision atomically. No independent agent-surface write to model/enablement may break this relationship (#3614's boundary remains a dependency, not assumed already delivered). Budget cap remains explicit and saved, never reset upward during transition. Refusal leaves the old tuple intact. Active old work cannot publish after the revision moves.

Existing maps remain v1 artefacts with honest provenance until their first v2 run publishes. Do not run a migration that bulk relabels generated content. For the two existing maps named by the milestone, prove read compatibility and three-record transitions first with disposable state copies under task-owned identities. Mutating the actual founder repositories needs separate authorization; no such authorization is implied here. Preserve all curator locks and denial state through transition. Version, identity and model changes must be tested concurrently with revocation, removal and replacement.

Rollback selects an installed approved v1 policy through the same explicit transaction only if the requested repository fits v1. A large repository that does not fit refuses regeneration; it is not silently resampled as complete. Do not drop v2 storage on rollback; old binaries must refuse unsupported v2 operations safely. Existing source denial remains authoritative. The final HLD must pin the minimum compatible deployment/rollback sequence before approval.

D13 measurement protocol and stop conditions​

Required authorization record before any source pull or charged call: the founder records the fixture and finite trial authorization in a comment on core#3680, the D13 authorization venue. The coordinator records the deployed experiment go there separately; amendment approval is not measurement permission.

  • A disposable copy of a real large repository: owner, URL, provider host, exact commit, provenance/license authorization, and confirmation that source may be sent to the chosen model destination. Product repositories remain read-only and are not silently repurposed as fixtures.
  • Disposable org/team/repo and registered generator identity, approved host profile, permitted coordinator-operated deployment, exact endpoint/model and provider, finite saved agent cap and maximum spend for the experiment.
  • Explicit trial caps for transfer/object/source/result bytes, entries, bodies, attempts, model calls/input/output, wall-clock and peak scratch disk/memory. Caps are trial stop conditions, not final product limits; no value defaults to unlimited. The coordinator must authorize any deployed-composition run.
  • A sealed list of task descriptions and independently established target directories, prepared before viewing generated output. Use held-out tasks for the acceptance assessment; document ambiguous/multi-location answers in advance.

The current deployed v1 refuses >10,000 entries by design. Do not alter its flags or hash to obtain this measurement. A v2 design experiment therefore needs an explicitly approved isolated measurement composition; alternatively a source-only inventory can run first under separately specified finite local caps. Source-only inventory is not token, model, runtime or navigation evidence. This prerequisite is a real measurement dependency, not a proposal to bypass v1.

Post a run record containing commit, fixture byte/file population, class, transfer bytes, object-store peak, full manifest entries/bytes, top-level directory count and root-index overflow-page count, excluded entries by reason, eligible files, selected bodies/bytes, maximum excerpt, actual input and output tokens per stage, provider/model, attempts, repairs, model calls, usage row ids/counts/cost, total wall-clock and per-stage latency, peak memory, result/root/child byte counts and cleanup proof. Logs contain no source or secrets.

For navigation, the target is the independently declared directory the task actually belongs in, at its actual depth. Report correct/incorrect/unknown counts per target depth: top-level answers from the root and deeper answers through child-page traversal. A correct top-level answer alone does not discharge D11 or count as a correct deeper target. Publish the predeclared exact/multi-target match rule and safe directory-label examples. Unknowns remain in the denominator. Report observed accuracy and a proposed acceptance threshold separately; a founder approves the target, not a post-hoc claim that whatever was observed is sufficient. Repeat enough to expose cold/warm and model variability; the run-count/budget is approved before paid repeats.

HLD acceptance also derives a supportable refresh cadence and shown staleness bound from measured cold/warm generation duration, actual usage cost and the finite approved budget. Do not promise a cadence independently of full regeneration cost; if the bound cannot be supported, revise the proposed service expectation before acceptance. Tier placement and size-class metering remain a founder decision at the V7 amendment acceptance review on #3680, informed by this measurement; no pricing or tier decision is made here.

Envelope dimensionv1 implementedv2 proposed limit
Provider attempts80 (GitHub; V3 specifies GitLab 160)pending D13
Manifest entries / bytes10,000 / 8 MiBpending D13
Bodies / per-file / total source48 / 16 KiB / 512 KiBpending D13
Transfer / object store / peak memoryno v2 clone envelopepending D13
Model calls / input / output tokens8 / 128,000 / 16,000pending D13
Generated result bytes / deadline64 KiB / 900 spending D13
Root document24,000 UTF-8 bytesretain 24,000 bytes
Child page / total pages / index entriesno child pagespending D13
Navigation correct / total; thresholdno V7 measurementpending D13
Size-class boundariesv1 hard limits, not a class modelpending D13

D14 on-prem binding​

Approved source-host profile and model endpoint are separate configurations. The generator calls its own governed Model Gateway. That gateway selects the tenant-owned endpoint bound to the exact agent/model, with BYOK held in the existing credential service. Existing route authority, clearance, enablement, quota, budget and usage gates remain mandatory. The generator holds neither provider keys nor permission to set a new arbitrary destination. No FastRouter fallback on endpoint timeout, unknown route or model mismatch. Source-host TLS, DNS/redirect allowlisting cannot authorize the model endpoint; both need their own approved profiles. Prove denied routes produce no external provider call and no map; success produces exact tuple-attributed usage.

Implementation briefs — drafts only, not authorization or filed issues​

Dependency order after founder PRD/HLD approval and V3: approved host profile + transport seam; ingestion; baseline migration and hierarchical extraction may then develop against one versioned contract, with coherent publication before any activation. These briefs remain in Tier C, not milestone 37.

1. Generalize governed transport​

Goal: resolve the provider/host-qualified registered repository through V3's adapter seam for both REST metadata and pinned fetch. Constraints: preserve all GitHub regressions, one per-credential budget, no arbitrary URL or credential scope widening. Acceptance: dual-host and cross-org/team/epoch negative cases, redirect/DNS/profile revocation refusal, actual GitHub and GitLab pinned fixture success. Files: internal/repomapgen/{transport,probes}.go, V3 provider seam. Verification to implement: scoped transport/classifier tests plus a negative control deleting the host equality predicate must fail its exact witness.

2. Ephemeral pinned object ingestion​

Goal: complete tree and bounded evidence from the exact commit without running source. Constraints: D10, D13 caps, no ambient config/hooks/submodules/LFS, no secrets in logs/argv/URLs, no shared team volume. Acceptance: deterministic manifest, truncated/oversized refusal, cancellation/revoke/orphan purge, no read beyond authorized commit/repo. Files: new adapter behind snapshot source interface and run-owned cleanup integration in internal/repomapgen. Verification to implement: actual disposable Git repository transport/cleanup suite, malicious config and symlink/submodule fixtures, and mutation removing terminal purge must fail its witness. Do not use founder repos as fixtures.

3. Hierarchical extraction, storage and consumers​

Goal: navigable directory pages and bounded root index with cited evidence. Constraints: six root kinds, byte bounds, no unsupported ownership claims, all reads source-gated, locked sections preserved. Acceptance: exact pinned path validation, complete page traversal, no cross-tenant/withheld reads, root and page mandatory headers, curator divergence, D13 held-out navigation assessment. Files: internal/repomapgen/generation_output.go, internal/reporegistry, proto and actual MCP/client read consumers; schema only in this eventual slice. Verification to implement: real Connect/MCP page read tests and disposable DB RLS/BYPASSRLS mismatch pairs, UTF-8 cap tests, missing-source-gate mutation RED.

4. Baseline v2 and explicit migration​

Goal: publish the D13-approved envelope and upgrade the coherent three-record tuple atomically. Constraints: #3614 guard, saved finite budget, no silent v1 relaxation, no active-run publication after revision change. Acceptance: real transaction/concurrency rollback witnesses, mixed hashes/versions refuse, v1 read compatibility, both existing-map shapes tested on disposable copies, usage reconciliation and downgrade refusals for oversized repositories. Files: internal/repomappolicy, generator provisioning/store/gates and MG policy consumer. Verification to implement: policy boundary suite, actual three-record integration under RLS/BYPASSRLS, negative control omitting one record update RED.

5. Approved self-hosted source and on-prem model profile​

Goal: make the V3 host profile and D14 model binding executable in the eventual Tier C deployment. Constraints: operator/platform-admin profile writer, team cannot authorize new host, no FastRouter on-prem, distinct source/model egress, no new public route assumed. Acceptance: exact fixture through approved host and tenant gateway, refused unknown hosts/routes, TLS/redirect/DNS and isolation witnesses, attributed usage, on-prem provider-outage refusal without fallback. Files: V3 host profile/egress resolver, governed generator/MG binding and runbook. Verification to implement: task-owned two-host fixture and metered endpoint test; mutation enabling fallback must fail a no-egress witness. Security/profile and new dependency approvals remain explicit gates.

Closure ledger​

  • PRD amendment: proposed, founder approval outstanding. The one approval venue is core#3680: the founder's approved names the accepted proposal revision and decisions, including tier placement/metering after D13. PR review approvals do not replace that human decision.
  • HLD: this draft; final HLD issue requires D13 numbers and founder approval.
  • Ingestion ADR: draft after D10 direction; pin subprocess versus library and obtain explicit dependency approval before implementation.
  • PRD acceptance edit, after the founder decision on #3680: update the canonical #2995 issue body and this markdown mirror together, inserting accepted §17 before the changelog, setting both **Version**: 1.5 headers, adding the v1.5 changelog entry, and adding per-depth navigation accuracy to §2 with the named V7 held-out directory-navigation assessment instrument. Update the #2995 registry row's version cell to 1.5 and replace its pending annotation with the dated approval reference in the same acceptance act. Cross-check issue, mirror and registry before declaring the amendment accepted; until that fold, the canonical body remains authoritative and the proposal is not shipped PRD text.
  • Fixture / measured envelope / accuracy: unavailable, no run performed.
  • Implementation briefs: drafted above; not filed, no implementation begun.
  • Tier C closure: full deployed disposable large-repo generation, navigation, on-prem route, coherent migration and source cleanup proofs; no partial pass.