Skip to content

Asset record support: budget-neutral reader, declared repo_meta + assessment block, trust-rule tests - #2

Merged
settletop-niles merged 9 commits into
mainfrom
feat/asset-record
Aug 10, 2026
Merged

settletop-niles merged 9 commits into
mainfrom
feat/asset-record

Conversation

@settletop-niles

Copy link
Copy Markdown
Contributor

Implements Part A (Tasks 1-7) of the authoring-MCP plan (spec: CodeRoot-Open-Source docs/superpowers/specs/2026-08-09-authoring-mcp-design.md).

What

  • record.py: tolerant asset-record.json reader — malformed = absent, never raises (incl. RecursionError on adversarial nesting); field-level defects drop fields, all-rejected dependency lists collapse to absent rather than serving a false "zero dependencies" declaration
  • Budget-neutral selection: the record is always read, never consumes any shared budget, never sets capped, never displaces another file (cap 40, per-file 16KiB)
  • Marker-scan exclusion at the sole scan_text call site — an adversarial record produces zero marker hits (non-vacuity control test included)
  • ALLOWLIST_VERSION 7 → 8 (forces corpus re-acquisition on rollout)
  • DirectSource.acquire emits declared_created_by/maintained_by/created_at on repo_meta (acquired branch only — the unchanged branch deliberately omits them; CodeRoot preserves prior values there)
  • assemble.build serves a declared block (technologies + model_access fact envelopes, source declared: asset-record.json) — excluded from build_payload, so content_fingerprint is byte-identical with/without a record
  • Trust-rule tests: the suppressor cannot introduce a type; an adversarial record ("mcp server", "agent", provider env vars) changes nothing but declared — whole-payload equality, mutation-tested during review (fingerprint leak, prose leak, suppressor promotion all caught)

Verification

645 passed, 2 skipped (pre-existing corpus-gated). Ruff: no new lints. Two adversarial review rounds on the spec + per-task reviews + whole-branch final review (verdict READY, all four classification channels independently re-verified).

Rollout note: deploy order matters — see the plan's rollout notes (stop workers → migrate → deploy → restart); deploying this before the OSS counterpart while old workers run causes a silent corpus-wide NULL-stamp on the declared columns.

🤖 Generated with Claude Code

select_source_paths appends record paths (basename == RECORD_BASENAME)
after every existing pass, outside all shared budgets: never counts
toward total/mtotal/src_files, never sets capped, never displaces any
other selected file. Oversized bodies (>RECORD_MAX_BYTES) are skipped;
overflow beyond _RECORD_MAX_FILES=20 subdir records is dropped
silently without flipping capped.
Spec §7 channel 2: a record naming provider env vars or "mcp server" must
never generate persisted marker_hits from its own text. Adds
_skip_marker_scan(path) guarding the single shared scan_text call site in
_scan_present_blobs, which every scan pass in GitContentFetcher.fetch
(manifest pre-scan, source pre-scan, final re-scan over the selected set)
routes through -- one guard covers all of them.
…anch

DirectSource.acquire parses asset-record.json (record.parse_record) out of
the freshly fetched files and merges declared_created_by,
declared_maintained_by, declared_created_at into a copy of repo_meta.
ONLY on the `acquired` branch: `unchanged` fetches no files, so the record
is unreadable there, and emitting None keys would look identical to "record
removed" to CodeRoot's executor, which preserves prior DB values on that
branch (Task 8).

Updates test_acquire_result_carries_repo_meta_on_both_branches to reflect
the now-asymmetric key sets between the two branches.
assemble.build now computes record.declared_block(content) after the subdir
filter (so a subdir subject reads its own re-rooted asset-record.json) and
serves it at assessment["declared"] (technologies/model_access fact envelopes,
or None). Deliberately not threaded into build_payload/compute_fingerprint —
content_fingerprint stays byte-identical with and without a record, verified
by the existing fingerprint-parity tests plus a manual check.

Updates the pinned assessment-shape test to sixteen keys.
…0; F402 rename

- _clean_technologies: a dependencies list where every entry is rejected (or
  which starts empty) now collapses to None instead of [], so declared_block
  never asserts a false "zero dependencies" fact.
- _RECORD_MAX_FILES raised from 20 to 40 to match _SKILL_MAX_FILES parity — a
  monorepo with >20 subdir records is a legitimate case, not adversarial; the
  per-file RECORD_MAX_BYTES cap already bounds the worst case at 640KiB of
  budget-neutral reads.
- git_fetch._ls_tree: rename the loop variable `record` to `entry` (ruff F402,
  was shadowing the `record` module import).
- content.py record pass: reorder the basename-equality check ahead of the
  `not in selected` membership tests (cheaper, runs first); note the terminal
  record pass in select_source_paths's docstring.
@settletop-niles
settletop-niles merged commit e9022a1 into main Aug 10, 2026
4 checks passed
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