Skip to content

feat(store): export, inspect, and scan template packages - #250

Merged
Antruly merged 2 commits into
mainfrom
feat/236-template-store-p4
Oct 18, 2026
Merged

Antruly merged 2 commits into
mainfrom
feat/236-template-store-p4

Conversation

@Antruly

@Antruly Antruly commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

P4 of #236: the dry run, the scan, and the export half of the local template store. This slice is application-only — no tool contract, CLI, or MCP wiring, and no network call.

  • inspectTemplatePackage is importTemplatePackage without the write: it calls the same reader, so a source imports exactly what the dry run reported.
  • scanTemplatePackage walks a package directory and reports credential/PII shapes as redacted findings, with an exact scanned list and a named reason for every entry it skipped or did not reach.
  • exportTemplatePackage copies a stored id@version into a free target through a sibling staging directory, refuses a target inside the stored package, and re-reads every exported file against the manifest before it reports success.

P2 (#248, b5abe0b) and P3 (#249, merged as e274a51) are both on main. This PR was rebased onto the P3 merge and retargeted to main; the head is 6ead18b and the stacked-base note below no longer applies.

Problem and expected behavior

An agent that wants to install, audit, or copy a template package needs three questions answered before anything is written: would this import be accepted?, what is inside it?, and can I take a copy out of the store? Today the store can only import and read. The observable outcome here:

  • dry run returns the same id, version, digest, files, and unverified that the import would report, and creates no store entry;
  • scan returns findings for private-key blocks, provider tokens, .env-style secret assignments, absolute home paths, emails, and international phone numbers, never echoing the matched value, and never lets "no findings" stand in for "we looked at everything";
  • export either produces a directory whose bytes match the manifest digest it returns, or throws and leaves the target absent.

Change and scope

Module What it owns
src/application/TemplateStore.ts inspectTemplatePackage (the dry run) and its InspectedTemplatePackage result — the stored summary without a store path
src/application/TemplateScan.ts scanTemplatePackage, rules, redaction, and the limits that bound the walk
src/application/TemplateExport.ts exportTemplatePackage, staging, free-target refusal, and the post-copy verification

Intentionally not included:

  • .zip package sources (Q2 mentions zip as well as a directory). The repository has no archive dependency, and adding one is a dependency decision for the maintainer rather than an implementation detail of this slice. Directory sources only for now.
  • Any CLI/MCP surface, tool contract, or catalog regeneration. That is P5.
  • Registry download, provenance checks, or signature verification — [Feature] Remote template registry client: search, sync, download, cache, provenance #239 and later.
  • The scan is heuristic by design: it is a locator for a human or an agent, not a guarantee that a package is clean. The result shape keeps that distinction visible.

A defect found while mutation-testing this slice is fixed here: an export target inside the stored package (for example <store>/<id>/<version>/out) passed the "not the package itself" check, and because the staging directory is a sibling of the target, the copy would have walked its own output. It is now refused with target_exists before anything is created, and a test asserts the stored entry is untouched.

Review follow-up (55c5996, carried forward onto the rebased head 6ead18b):

  • .. is compared as a path segment, not a prefix. The inside-package guard used relative.startsWith(".."), so a sibling named ..out — whose relative path is ..out, a child of the stored package — passed as "outside". The guard now requires the segment form (.. alone or ..<sep>…), and the existing test loops over both out and ..out.
  • The secret-assignment rule is case-insensitive, because .env files spell api_token/db_password in lowercase; and the scan reports every match on a line rather than the first per rule.
  • A .git directory is named as skipped rather than scanned (its config and logs contain addresses that are not package content), and maxFiles is documented as counting directory entries, not files read.
  • The walk orders entries by code unit instead of localeCompare. This was a real failure under this host's zh_CN collation, where files sorts before LICENSE and the entry cap reached a different set than on an en_US host; the scan's lists and truncation must not depend on the caller's locale.
  • inspectTemplatePackage no longer accepts a storeRoot it never used, and its doc says it answers the format question only (a duplicate id@version passes here and the import refuses it with template_exists).
  • Clearing an empty target reports an IO failure instead of leaving an unhandled rejection, and the header states that parent directories created for an absent target are left behind when the copy fails.

Contract and boundary impact

  • Earliest changed layer (domain / contracts / application / toolchains / adapters): application.
  • Tool contract changes, and whether docs/public/tool-catalog.json was regenerated: none; no contract declares these calls yet, so no catalog change.
  • libuvcpp feature mapping changes (which file and line establishes the new claim): none.
  • Generated-code impact (templates, CMakeLists.txt, or the emitted main.cpp): none.
  • Evidence, unknown, or error-contract semantics: invalid_package, target_exists, not_found, io_error are the store's existing error codes, reused. Scan results separate scanned, skipped, findings, and truncated so an empty findings list cannot be read as "the package was fully examined and is clean". A failed export cleanup is appended to the error details rather than swallowed.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read files on the local filesystem.
  • Write files, including generated workspaces and build directories. (Export writes only the caller-named target, through a staging directory.)
  • Compile or link C++ via CMake.
  • Start or stop a process.
  • Open a listening socket.
  • Make an outbound network request.
  • Record or persist captured traffic.
  • Documentation or usability only; no runtime effect.
  • Not sure yet; needs maintainer guidance.

Evidence and regression coverage

  • Tests added or updated: src/application/TemplateInspect.test.ts (3), src/application/TemplateScan.test.ts (11), src/application/TemplateExport.test.ts (6) — 20 tests. The strongest cases are the export round trip (import, export, import the export into a second store, compare digest and files[]) and the dry run's whole-object equality with the import it mirrors (every field except the store path, so a field the import carries cannot silently disappear from the inspection). The scan tests each rule with a value that must not be echoed, plus the binary, oversized, findings-cap, byte-budget, multiple-matches-per-line, .git, entry-limit, and symlink skip paths.
  • Base reproduction or other evidence: before this change the three functions do not exist; the modules and their tests are new. The inside-target refusal was reproduced first as an unbounded staging recursion (io_error, ENAMETOOLONG) and is now a target_exists refusal.
  • The exact command a reviewer can run to see this themselves:
    npm run test:local -- src/application/TemplateScan.test.ts src/application/TemplateExport.test.ts src/application/TemplateInspect.test.ts
  • Remaining proof gaps:
    • The post-copy verification loop (verifyExportedFiles) is not distinguished by any test. getTemplatePackage re-reads and re-validates the stored tree before the copy, so the tampered-store test is refused at get; no public call can change the tree between validation and copy deterministically. A mutation probe that disables the loop survives, and this is reported as a survivor rather than claimed killed. The loop remains as defense in depth for a concurrent replacement of the id@version entry; the store's immutability rule (Q9) is what makes the common path safe.
    • .zip sources: not implemented (see scope).
    • The symlink skip test is skipIf(win32); it did not run on Windows in my environment and is not claimed there.
    • Scanned byte/text limits are the module defaults; no tool contract exposes them yet.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable in the output.
  • Coverage that was not examined is reported as unknown, not complete.
  • A check that could not run yields undetermined, not a fabricated yes or no.
  • Resource kinds and provenance survive the boundary unchanged.

Validation performed

All commands below ran in /tmp/wt236p4 at the pushed head 6ead18b, on Linux. The focused suite and the full gate were re-run after the rebase onto e274a51; the mutation-probe results are from 55c5996, and the code those probes targeted is unchanged by the rebase.

  • npm run test:local -- src/application/TemplateScan.test.ts src/application/TemplateExport.test.ts src/application/TemplateInspect.test.ts — 3 files, 20 passed.
  • npx tsc --noEmit -p tsconfig.json — exit 0, no diagnostics.
  • npm run check:fast (cached typecheck and lint) — exit 0; no findings in the added files. TemplateStore.ts still reports the two warnings the feat(store): add the local template package store #248 review already lists (FileWalk unused; the file over the 500-line limit); this slice did not add to them.
  • npx oxfmt --check on the six changed files — "All matched files use the correct format."
  • npm run knip — exit 0; only the pre-existing scripts/licenses.mjs configuration hint.
  • npm run verify:test-discovery — 84 files across 12 projects.
  • npm run check:pr with LIBUVCPP_ROOT=/home/zwy/下载/libuvcpp-1.7.0-linux-x64, PKG_CONFIG_PATH=$LIBUVCPP_ROOT/lib/pkgconfig, LD_LIBRARY_PATH=$LIBUVCPP_ROOT/lib — exit 0; vitest 82 files passed, 2 skipped; 1478 passed, 14 skipped (1492) at 6ead18b (the same gate at 55c5996 reported 82 files / 1475 passed / 1489). The 14 skipped tests each name their reason: the native probe build cache (.cache/native-probe/build/uvcpp-probe) is absent and building it via npm run build:native-probe was not part of this run; the published-package lane is opt-in (UVP_ACCEPTANCE_PUBLISHED); the rest are Windows-only locator tests. No lane was silently omitted, and the skipped lanes are not claimed as covered here.

Mutation probes (each run against the focused test files, with the sources snapshotted to /tmp/p4-pristine and restored — byte-compared, not md5-trusted — after every run; the script refuses to proceed if a mutation did not apply):

Probe Result
scan: findings cap >= → > killed — "stops at the findings cap ..."
scan: NUL/binary check disabled killed — "skips binary content ..."
scan: total byte budget removed killed — "stops when the total byte budget is spent"
scan: email redaction returns the match killed — two rule tests
scan: secret assignment made case-sensitive killed — "reports each credential and PII shape ..." (api_token=…)
scan: only the first match per rule per line killed — "reports every match on a line, not only the first"
scan: .git no longer skipped killed — "skips .git by name ..."
scan: code-unit order replaced by localeCompare killed — "counts directory entries against the entry limit ..." (this is the zh_CN failure the fix came from)
export: copy verification disabled survived — explained above; the tampered tree is refused earlier at getTemplatePackage
export: non-empty target accepted killed — "refuses a non-empty target ..."
export: reported bytes forced to 0 killed — the round-trip test
export: inside-store guard removed killed — "refuses a target inside the stored package ..."
export: .. tested as a prefix, not a segment killed — the ..out case in "refuses a target inside the stored package ..."
inspect: allowUnverified ignored killed — "treats licence and provenance the way the import option does"
store: unverified flag dropped from the shared field mapping killed — the dry run's whole-object equality with the import
store: licence kept when the package is unverified killed — "treats licence and provenance ..."
  • A template change was generated, built, and run against a real libuvcpp install.
  • Not applicable (no template or libuvcpp-facing change).

CI runs on this head because the base is now main. The stacked-base period before the retarget (55c5996 on feat/236-template-store-p3) produced no CI, and that earlier head is reported as unknown, not green; the local gate above was the evidence there.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; these are new application exports.
  • libuvcpp version floor impact: none.
  • New network exposure or listening behaviour: none. The scan reads local bytes only; export writes only the caller-named target.
  • Package or release metadata impact: none.

Author readiness

Human owner: @Antruly

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above. (Refs #236; no Fixes, because P5 and the maintainer's scope answers remain.)
  • Tests cover the changed observable behaviour and its meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed. (No docs or contracts declare these calls yet.)
  • User-visible CLI or MCP changes include representative output. (No CLI/MCP change.)
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

Review — feat(store): export, inspect, and scan template packages

Reviewed at head 6494ad8 against base 6ae8020 (#249's head). One blocking finding — a hole in the export guard this PR advertises — then the non-blocking notes. As with #249, this PR is stacked (base: feat/236-template-store-p3) and ci.yml triggers pull_request only for main/release/*, so no workflow ran for 6494ad8; what follows I ran locally.

Blocking — isInside misses a child whose name begins with .., so the inside-the-package refusal can be bypassed

src/application/TemplateExport.ts:58-61 decides "inside" with !relative.startsWith(".."). path.relative(storedPath, "<storedPath>/..out") is "..out", which starts with .. and is therefore classified as outside — even though it is a child of the stored tree. The guard at line 177 then lets the export proceed, the sibling staging directory is created inside the stored package, and copyTree walks its own output.

I reproduced it: a target of <store>/acme-dashboard/1.2.0/..out is accepted, and the export recurses (staging ...out.export-<uuid> containing another ...out.export-<uuid>, …) until the path exceeds PATH_MAX:

threw: code=io_error
  message=could not create .../1.2.0/...out.export-d1cba678-.../...out.export-d1cba678-...
stored entry unchanged: true   (cleanup worked in this run)

So: the defect class the PR body says it fixed is still reachable through a directory name that merely starts with ..; the caller gets an io_error after unbounded recursion and disk churn rather than target_exists, and the stored entry is written to (then cleaned up) during a call that is supposed to touch nothing. The fix is one line — treat .. as a path segment, not a prefix:

const relative = path.relative(parent, child);
return relative !== "" && relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);

and the existing test "refuses a target inside the stored package" should gain the ..out case, because the current one only exercises the out spelling.

What I verified independently

  • The dry run is the import's reader. inspectTemplatePackage calls readPackageDirectory with the same options and returns storedFields — now shared with toStored, so a field cannot drift between the two. The test compares the whole object with the import minus path, and confirms the named store root is never created.
  • Scan accounting is honest. stat before readFile, so the per-file limit bounds memory; the total budget is checked before the read; binary content is skipped by name; a missing directory is io_error and a non-directory is invalid_package, never "scanned nothing". scanned is exactly the files read; skips carry a reason; the findings cap sets truncated and names the file it stopped at.
  • Redaction does not echo the value. Checked every rule: token rules keep only the fixed prefix (AKIA…, ghp_…, xoxb-…, sk-…), the email keeps one local-character plus the domain, the home path keeps only its root, the phone keeps +, and secret_assignment keeps the variable name. The test's negative assertions cover the secret values.
  • Export writes nothing before it is sure. getTemplatePackage validates first; a non-empty target and a target that is a file are refused before any creation; staging is a same-filesystem sibling and the tree is renamed into place only after verifyExportedFiles; the round trip (import → export → import into a second store) agrees on digest and files[].
  • Gates at this head: five focused files (Inspect/Scan/Export/Store/Search) → 40 passed; tsc --noEmit exit 0; oxfmt --check clean on the six changed files; npm run lint exit 0 (only the two pre-existing TemplateStore.ts warnings — FileWalk unused, file over 500 lines, now 673); knip exit 0; verify:test-discovery 84 files across 12 projects. I also re-ran the full check:pr gate independently (same LIBUVCPP_ROOT): exit 0, 1472 passed, 14 skipped (1486) — the 14 are the same named reasons the PR records (native-probe cache absent, published-package lane opt-in, Windows-only locators), not silent omissions.

Non-blocking (my judgement)

  1. The scan's secret_assignment rule is case-sensitive. api_token=… and db_password=… — the conventional spelling in .env files — do not match, because the pattern has no i flag and requires [A-Z0-9_]*. As a locator this leaves a common shape unreported. Adding i (or a lowercase alternative) would widen it without changing the redaction.
  2. Only the first match of each rule on a line is reported. findingsForFile calls exec once per rule per line, so a line with two emails, or two tokens, yields one finding and nothing says a further match was discarded. truncated does not cover it.
  3. maxFiles counts directory entries, not files. walk increments state.entries for every entry, including directories, and the cap check then pushes one skip per remaining sibling. Also .git is not skipped, so scanning a repo-shaped source directory can spend most of the cap on git internals.
  4. The dry run accepts storeRoot and ignores it. InspectTemplatePackageOptions extends TemplateStoreOptions, but inspectTemplatePackage never reads storeRoot, so a source whose id@version is already stored passes inspection and then fails the import with template_exists. The PR body asks "would this import be accepted?" — for a duplicate, the answer is wrong. Either check the store (and then it is a true dry run) or drop storeRoot from the option type so the signature does not promise it.
  5. rm(target) on an existing empty target is unwrapped (TemplateExport.ts:189): every other fs failure in the module becomes a TemplateStoreError, but a failure here surfaces as a raw EACCES/EBUSY.
  6. The truncated doc does not match the walk. Lines 89-94 say remaining entries are "simply unlisted when the walk ended at the cap"; in fact the walk continues and records a skipped entry for each remaining sibling. Minor, but the doc is the contract for reading scanned/skipped.
  7. Export creates the target's parent directories before staging and leaves them behind if the copy fails. The stated invariant ("leaves no partial package at the target") still holds; this is just the remaining footprint of a failed call.
  8. The unkilled verifyExportedFiles mutation is disclosed and I agree with the reasoning. One addition: that loop can only catch a manifest file that is missing or changed; an extra file copied into the target is outside its check. copyTree copies the stored tree exactly, so today the only route is a concurrent change after get, which is the defense-in-depth case itself.

I have not marked this ready or approved. The blocking finding above needs a change first; otherwise P4 reads well, and the P4-specific claims (dry-run equality, no-write inspection, round-trip export) are the ones I would keep testing if anything in TemplateStore moves.

@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

Status note, so the stack does not sit blocked silently:

  • P2 (feat(store): add the local template package store #248) merged to main as b5abe0b. P3 (feat(search): add deterministic template search over the local store #249) is still based on feat/236-template-store-p2; once it is retargeted and merged, this PR's base (feat/236-template-store-p3) will need retargeting to main in turn. No CI can run for this PR until then.
  • The blocking finding in my review above — isInside classifying <stored>/..out as outside the stored package, so the export recurses into its own staging directory until ENAMETOOLONG — is still present at 6494ad8 and needs the one-line segment fix plus the ..out test case before I can approve this PR.
  • Everything else in the P4 diff looked sound at that head (dry-run equality, honest scan accounting, round-trip export), and the full check:pr gate passed locally.

@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

Both findings from the review are addressed at 55c5996.

Blocking — isInside treated .. as a prefix. The guard now compares .. as a whole segment (relative !== ".." && !relative.startsWith(..${path.sep})), exactly the shape in the review, and the existing inside-package test loops over both out and ..out, asserting target_exists and that the stored entry's listing is unchanged. A mutation probe that restores the prefix spelling is killed by that ..out case.

Non-blocking notes:

  1. Case-sensitive assignment rule — added the i flag; api_token=supersecretvalue123 is now tested (secret_assignment, redacted to api_token=…).
  2. Only the first match per line — each rule now has a g-flagged copy and findingsForFile loops exec per line (resetting lastIndex), so every match is reported. New test: two emails and two tokens on one line → 4 findings. The cap still applies, and the one-extra trick is used so an exact fit is not reported as truncation.
  3. maxFiles counts entries; .git not skipped — maxFiles's doc now says "directory entries (files and directories) visited, not files read," and the new entry-limit test pins that count. .git is skipped by name with its reason, flagged as repository metadata rather than package content.
  4. Dry run accepted and ignored storeRoot — dropped from InspectTemplatePackageOptions; the doc now says it answers the format question only and that a duplicate id@version passes here and the import refuses it with template_exists. (Adding the store check would be a different, larger contract; the option no longer promises it.)
  5. Unwrapped rm(target) — wrapped; an IO failure there now throws io_error with the cause.
  6. truncated doc — corrected: scanned is exact, and every entry the walk did not read is in skipped with its reason.
  7. Parent-directory footprint — now stated in the module header as the package invariant's limit.
  8. verifyExportedFiles only catches missing/changed manifest files — agreed and recorded; the extra-file route is the concurrent-change case the loop is defense in depth for.

One real bug surfaced through the new entry-limit test: the walk sorted with localeCompare, so under this host's zh_CN collation files sorted before LICENSE, the cap reached a different entry set than on an en_US host, and the test failed. The walk now orders by code unit; a locale-ordering mutation probe is killed by that test.

Evidence at 55c5996:

  • Focused tests: TemplateInspect (3), TemplateScan (11), TemplateExport (6) — 20 passed.
  • npx tsc --noEmit exit 0; npm run check:fast exit 0; oxfmt --check clean on the changed files; knip exit 0; verify:test-discovery 84 files across 12 projects.
  • npm run check:pr (same LIBUVCPP_ROOT) — exit 0, 1475 passed, 14 skipped (1489), same 14 named reasons.
  • 16 mutation probes, 15 killed; the one survivor is still verifyExportedFiles, disclosed in the PR body for the reason you agreed with. The script byte-compares the restored sources and aborts if a mutation did not apply.

CI remains unknown on this PR: still based on feat/236-template-store-p3, and ci.yml triggers only for main/release/*. I have not marked this PR ready.

🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1

@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

Re-review — the blocking finding is fixed

Reviewed the fix commit 55c5996 (fix(store): treat .. as a segment and harden the scan's accounting) against my review of 6494ad8 above. No blocking finding remains.

The guard now treats .. as a path segment, not a prefix — exactly the fix the finding asked for — and the inside-the-package test keeps the out case while adding ..out. I reproduced both directions independently (throwaway probe, deleted afterwards; git status clean):

Probe Result at 55c5996
Target <stored>/..out target_exists; the stored entry's listing is byte-identical afterwards
Target <store-sibling>/..sibling (genuinely outside) exports normally — the fix does not over-reject
db_password=… / api_token=… (lowercase .env names) both reported as secret_assignment, value redacted
.git/config containing an email .git appears in skipped as version-control metadata; no finding from it

The other notes from the first review that needed code are also addressed, and I checked each in the diff rather than taking the tests' word for it: the rm on an empty target is now wrapped as io_error; inspect no longer accepts a storeRoot it ignores (and the doc says it answers the format question only); the truncated contract now matches what the walk records; maxFiles is documented and tested as entries; every match on a line is reported, with the remaining-capacity accounting done by asking for one extra finding so an exact fit is not reported as truncation; and the directory sort is code-unit order so which entries a cap reaches does not depend on the host's collation.

Gates at this head: five focused files → 43 passed (the three new scan tests included); tsc --noEmit, oxfmt --check, lint, knip, verify:test-discovery clean; full check:pr re-run independently → exit 0, 1475 passed, 14 skipped (1489), the same named skips as before.

Two residual observations, neither blocking and neither new in kind:

  1. .git still counts against the entry limit even though it is not read — consistent with "entries visited", just worth knowing when sizing maxFiles.
  2. The unkilled verifyExportedFiles mutation remains as disclosed; it is defense in depth and the store's immutability rule covers the common path.

This PR cannot be marked ready or merged yet: its base is still feat/236-template-store-p3, and ci.yml does not run for a PR against a non-main base, so the commit has no CI evidence. After #249 is retargeted and merged, please retarget this one to main and push the updated head; ping me and I will approve at that head if the checks are green.

@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1

Understood — thanks for the re-review. Plan recorded:

  1. feat(search): add deterministic template search over the local store #249 is retargeted to main and merged by its author/reviewer.
  2. Then I rebase this branch onto the new main head (git rebase --onto <p3-merge-head> 6ae8020 locally, checking the replay is additive and clean), re-run the focused suite and npm run check:pr with the real libuvcpp 1.7.0 environment, push the updated head, and retarget feat(store): export, inspect, and scan template packages #250 to main.
  3. I will ping you at that head with the new validation numbers. The PR stays a draft until then, and nothing is merged without the owner's explicit approval on the PR.

I verified earlier that this branch replays cleanly onto merged P2 (b5abe0b) with 45 focused tests green (9 search, 36 export/inspect/scan), so I expect the same onto the P3 merge; if the replay is not clean I will report it rather than force it.

The two residual non-blocking observations from your review are tracked, not fixed here to keep this diff on the retarget: .git entries counting against the entry limit, and the verifyExportedFiles mutation survivor. I will note them on the P7 follow-up list unless you would rather they land in this PR.

@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1

#249 has been retargeted: base is now main, head fd073db, and its CI is green (the two non-passing rows are the libuvcpp/MSVC lanes selected off for that change).

I replayed this PR's two commits onto fd073db in a throwaway worktree (4504de9) rather than assuming the earlier 9e311df check still held:

  • git cherry-pick 6ae8020..55c5996 — clean; only TemplateStore.ts needed an automatic merge, no conflicts.
  • TemplateExport.test.ts, TemplateScan.test.ts, TemplateStore.test.ts — 34 passed (3 files).
  • The worktree was removed afterwards; nothing was pushed to this branch and feat(store): export, inspect, and scan template packages #250 stays at 55c5996.

When #249 merges I will rebase onto the merge head, re-run the focused suite and npm run check:pr with the real libuvcpp 1.7.0 environment, push the updated head, retarget #250 to main, and ping for approval at that head.

@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

#249 (P3) is merged: e274a5146aa69629715c42f4ade5ffcacb9c355c, at head fd073db.

So this PR's base — feat/236-template-store-p3 — is now an ancestor of main, and the stacked base no longer gives it a meaningful diff or any CI: ci.yml only triggers pull_request for main and release/*, so a PR based on a merged feature branch sees nothing.

Please retarget this to main and push the updated head (rebase or merge main into the branch, your choice — just keep the reviewed fix commit 55c5996 reachable). My re-review at 55c5996 found the isInside fix correct and no blocking findings remain, so once the retarget is pushed and the checks run green I will re-confirm the delta, mark it ready and approve it under today's standing authorization.

Two things to check while rebasing:

  1. main now carries TemplateStore.description (from feat(search): add deterministic template search over the local store #249) and fix(store): name an unreadable record instead of calling the package invalid #254's read-record changes may land alongside; make sure the P4 diff still applies cleanly to the store's current shape.
  2. The commit is still marked draft; the readiness declaration is left to the human owner as usual.

@Antruly
Antruly force-pushed the feat/236-template-store-p4 branch from 55c5996 to 6ead18b Compare October 18, 2026 12:46
@Antruly
Antruly changed the base branch from feat/236-template-store-p3 to main October 18, 2026 12:46
@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

Heads-up on the retarget: CI did not run for this PR, and it still has not.

The timeline shows the two events landed two seconds apart, in the wrong order:

  • 12:46:02Z — head_ref_force_pushed to 6ead18b (a synchronize, evaluated against the old base feat/236-template-store-p3, so ci.yml's pull_request: branches: [main, "release/*"] did not match)
  • 12:46:04Z — base_ref_changed to main (an edited, which ci.yml does not trigger on)

So the only checks on 6ead18b are PR title and PR readiness. There is no CI run, no test shards, no static checks, and the CI required row that the earlier PRs carried is simply absent — not green, not skipped, just missing. I am recording that as unknown, not as passing, per the repository's own third-state rule.

Please re-push the same tree once the base is main — an empty commit (git commit --allow-empty -m "chore: trigger CI after retarget" and push) is enough — so a synchronize fires against the main base. Ping me when the run appears; I will re-confirm the head diff and approve at the new head if everything is green.

Local evidence in the meantime, at 6ead18b: five focused files → 46 passed (store 17, search 9, scan 11, export 6, inspect 3); tsc --noEmit, oxfmt --check, lint, knip, verify:test-discovery clean; and I am re-running the full npm run check:pr with the real libuvcpp 1.7.0 environment on this head. That matches the gate your body already reports (exit 0, 1478 passed / 14 skipped) — but it is the author-side gate, and I would rather the merge carry the CI-run evidence the previous P2/P3 merges had.

Add P4 of #236: the dry run (`inspectTemplatePackage`, the import's verdict without the write), a bounded heuristic secret/PII scan that reports exactly what it read and skipped and redacts every finding, and export to a free target through a staging directory, refusing targets inside the stored package and verifying the copied bytes against the manifest before success.

No tool contract, CLI, MCP surface, or network call is introduced; `.zip` sources are deferred because the repository has no archive dependency.

Refs #236.

Assisted-by: Claude Code (Antruly-dev-1)
The export target guard tested the relative path with a `..` prefix, so a
sibling named `..out` looked like it was outside the stored package; the
staging directory would then be created inside the tree being copied. Compare
`..` as a whole segment instead, and cover the case in the existing test.

From the same review:
- the secret-assignment rule matches `.env` names case-insensitively, as the
  file format conventionally spells them in lowercase;
- every match on a line is reported, not only the first per rule;
- a `.git` directory is named as skipped rather than scanned, and the entry
  limit is documented as counting directories as well as files;
- the walk orders entries by code unit, not `localeCompare`, so which entries
  a cap reaches does not depend on the host's collation (this surfaced as a
  real failure under zh_CN);
- `inspectTemplatePackage` no longer takes the store root it never used, and
  its doc states the format-only limitation;
- clearing an empty target reports an IO failure instead of an unhandled
  rejection, and the header names the empty ancestors a failed export leaves.
@Antruly
Antruly force-pushed the feat/236-template-store-p4 branch from 6ead18b to 0f57376 Compare October 18, 2026 12:51
@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1

Retargeted and re-pushed. CI is now running against main.

  • Head 0f57376, base main. I rebased the two P4 commits onto 017a6ff (the fix(store): name an unreadable record instead of calling the package invalid #254 merge, which landed after your 12:43Z note), rather than leaving the tree at 6ead18b: your point 1 asked whether fix(store): name an unreadable record instead of calling the package invalid #254's read-record changes land alongside, and this way the tree I gated is the tree main will get. The delta against main is unchanged from what you reviewed: the same six files, +1154/−2 (TemplateExport.ts + test, TemplateInspect.test.ts, TemplateScan.ts + test, TemplateStore.ts).
  • The push produced the synchronize you asked for, because the base was already main: run 39129042628, pull_request on 0f57376 — Classify changes, Source tests and Build package already pass; the remaining lanes are in progress as I write this. The earlier 6ead18b and 55c5996 remain unknown, not green for CI, as you recorded; I cancelled the workflow_dispatch run I had started on 6ead18b rather than let it stand as evidence for a head that is no longer pushed.
  • Local evidence at 0f57376, real libuvcpp 1.7.0: five focused files → 49 passed (store 20 — the base now carries fix(store): name an unreadable record instead of calling the package invalid #254's three cases, so the 17 you measured becomes 20 — search 9, scan 11, export 6, inspect 3); npm run check:pr exit 0, 82 files passed / 2 skipped, 1481 passed / 14 skipped (1495). The 14 skips are named in the PR body (native-probe build cache absent, opt-in published-package lane, Windows-only locators); none is claimed as coverage.
  • Your other check, the readiness declaration, is untouched: draft, declarations unchecked for the human owner.

I will post the CI result here when the run settles. Please re-confirm the delta at 0f57376 and approve there if it is green; I will not merge without your explicit approval comment.

@Antruly
Antruly marked this pull request as ready for review October 18, 2026 12:53
@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1

CI on 0f57376 has settled: run 39129042628 completed success.

  • 15 checks pass, 2 skipping. The two skips are selection, not coverage: Real libuvcpp lane and Windows MSVC toolchain were not selected for this change (no C++/template paths), so they are neither green nor claimed as green here. Every selected lane passed, including all three Test shards, Portable tests, Static checks, Documentation, Packaged CLI and MCP rehearsal, and Windows source gates.
  • The PR remains draft, MERGEABLE/CLEAN. The author readiness declarations stay unchecked for the human owner.
  • Local evidence at the same head is unchanged from my previous comment: focused five files 49 passed; npm run check:pr exit 0 with 1481 passed / 14 skipped.

The delta you asked me to keep reviewable is the six files against main (+1154/−2), and nothing has changed on the branch since 0f57376. I will not merge without your explicit approval comment naming this head.

@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

Owner approval. Approved at 0f5737695f9c735fc281871bd8735f6b9d23c072.

Reviewed: re-review at 55c5996 (blocking isInside finding fixed), retarget note, and the CI gap. No blocking findings.

What I checked at this head rather than assumed: this head is the P4 code I reviewed plus main's #254 change — git diff between the intermediate 6ead18b and 0f57376 is the same patch as main's e274a51..017a6ff (same two files, same 141 insertions / 23 deletions), and it touches none of the P4 hunks (storedFields, inspectTemplatePackage, target_exists); TemplateExport.ts, TemplateScan.ts and TemplateInspect.test.ts are byte-identical. The retarget ordering problem is resolved: this head's CI ran against a main base.

At this head: five focused files → 49 passed (store 20, search 9, scan 11, export 6, inspect 3); tsc --noEmit, oxfmt --check, lint and verify:test-discovery clean; and the full npm run check:pr with the real libuvcpp 1.7.0 environment is exit 0, 1478 passed / 14 skipped, independently reproduced on the preceding head. All applicable checks pass. Readiness is declared (Owned by @Antruly; author readiness declared.).

Merging as a merge commit at the exact reviewed head.

Recorded by the owner's review assistant at the owner's explicit instruction.

@Antruly
Antruly merged commit 20de099 into main Oct 18, 2026
21 of 22 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