Skip to content

perf(path-security): read HOME once per -g walk; prove new dirs from a proven ancestor (#5838 slice 4) - #5843

Open
Daniel Meppiel (danielmeppiel) wants to merge 123 commits into
mainfrom
fix-5838-slice4-path-safety
Open

Daniel Meppiel (danielmeppiel) wants to merge 123 commits into
mainfrom
fix-5838-slice4-path-safety

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: a3c1bbd9fbd49efd468b6e4d867ec3619dbfeb0f

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Red-first 4056955 fails on #5842's head (Path.home() 46,456 vs < 1000) and passes after the fix (314 fresh, 50 re-pass).
↑ The path-safety and -g link suites (24 modules plus tests/unit/utils): 2,339 passed.
↑ AUD co-signed the design: 4a GO, with HOME read per call, not per command.
↑ Proof descent (4b part 1): red-first 133381b, parity cells against Path.resolve(), link-check mutation turns 6 cells red; unit utils/install/integration plus the link lifecycles: 10,162 passed.
↑ AUD SECURITY GO on 4b part 1; c8ec3603 floor PASS at e5e4b85.
↑ AUD SECURITY GO on B3 at d8e0f0b. CI at d8e0f0b reds were test/data-only (AQ004 count cell, macOS-measured path_home rows), fixed; tests/quality 1040 passed locally.
↑ Merged signed #5834 (5b83983) for the train-5 promise catalog (sorted union, checked against both sides).
↑ QL mutants on the downward proof walk are pinned (test-only 38fb19b): file (M2), volatile (M3) and unreadable (M4) components each turn a cell red; M6 (store guard alone) is equivalent, since recall already requires the current generation.
↑ QL signed 38fb19b (CI 47171522465, tier2 47171522090).
↑ Rows re-measured on the composed train-5 tip d7b9a2f plus this PR (scratch #5853, Linux): every row held. Three were tightened in the rows-only a3c1bbd: lstat 14,189 and 17,842, realpath 1,405.
↓ CI at a3c1bbd not observed yet.
↓ test_machine_yaml.py::...[deep-flow-nesting] fails locally on the base too (local PyYAML build); not touched here.
↓ CI on this head is not observed yet; the Linux path_home rows come from a macOS measure and may need a correction from CI.

Description

Slice 4a of #5838 (path safety). Stacked on #5842 (slice 2a), then #5841 and #5839.

Every -g write walks the path from HOME down and lstats each component, so a link flipped in after planning is still met. For each component, _on_root_path asked whether it sits between HOME and a harness root, and read Path.home() once per root. On the 14-plugin world that is 46,456 HOME lookups (about 357 of 371 ms of the walk under cProfile). The walk now reads HOME once per call and passes the prefix down.

Unchanged: every component under HOME is still lstat'd at write time; the per-link verdict memo keyed by link identity; HOME is read per call, not per command (AUD).

The perf worlds now use a link-free temp root. On macOS /tmp is a link to /private/tmp, which defeats resolve_path's per-command proofs and doubles lstat; on Linux the root is unchanged.

Test-only: the update-notice cells in tests/unit/core/test_output_mode.py clear APM_E2E_TESTS, which silences the notice, so they pass in a session that sets it.

Budget rows measured on the composed train-5 tip d7b9a2f plus this PR (scratch #5853).

cost: 0 syscalls added; Path.home() 46,456 -> 314 (fresh 14), with rows in tests/perf/count_budgets.json.

4b (part 1): prove new directories down from a proven ancestor (utils/realpath.py, the R1 proof owner). Before the writes, about 470 resolves target files in directories not created yet. R1 proves only an existing parent, so each took a full walk. Below this command's deepest proven ancestor, each component now costs one lstat: an existing plain directory is proven; the first missing component ends the walk, since nothing below it exists and the path resolves to itself; a link, a file, a volatile name or an error takes the full resolve as before. Linux keeps its kernel form and is unaffected.

  • cost: integrate lstat 21,637 -> 13,853 (-36%, macOS, link-free 14-plugin world, tracer counters).
  • Red-first 133381b: test_a_file_in_directories_not_yet_created_costs_one_lstat and [existing-dirs] fail on the base. Parity cells (link, file, volatile) match Path.resolve(). A mutation dropping the link check turns 6 cells red, including the RT6 red-team cells.

4b (part 2, AUD B3): the project and deploy roots are resolved once per command (realpath.resolve_root, used by the ledger locator). The answer is recalled only while the proof generation is unchanged, so any rename, delete or recreate APM performs resolves it again. File paths are still resolved on every call.

  • cost: -1,067 integrate lstat; 0 added.
  • Red-first 7dbefb8: 20 locators resolve the root 20 times (expected 1); a root released by an APM rename and replaced by a link is recalled stale. Mutation: ignoring the generation turns the swap cell red.

B1 (thread one resolution per file) is skipped by the floor review: after part 1 each file costs one leaf lstat, which is already O(files). The write seam is unchanged (B2).

Guards pinned by mutation: file, volatile and unreadable components on the downward walk, and a root resolve parked across a forget.

Reviews: AUD GO on 4a and 4b part 1, and c8ec3603 floor PASS at e5e4b85 (lstat -24%, realpath -39% on the link-free world; linked HOME flat).

Issue and approved scope

Issue: Refs #5838 (slice 4a of the floor plan)

Human scope-approval comment: #5838 (comment)

Does this PR complete the issue, or what remains? It does not. 4b and later floor-plan slices remain.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
promise: P-PERF-count-budgets -- a -g install reads HOME once per write walk; every component under HOME is still lstat'd at write time (source: #5838 scope record, AUD slice 4 co-sign)
cell: OP=install SCOPE=user SRC=local PRIM=skill(plugin) TGT=opencode, fresh 14 and re-pass 23   owner: utils/path_security.py foreign_user_link
instrument: today test -> tests/integration/test_local_plugin_install_cost.py::test_user_scope_link_walk_reads_home_once_per_write (extends the #5838 cost module) + calls.path_home rows
oracles: [call counts, link-safety suites unchanged]  decisive: path_home < 1000 (fresh and re-pass)
failing-before: 40569559 -> assert 46456 < 1000
passing-after: 12 passed (cost module); 2,339 passed (link-safety suites)
guard+mutation: n/a     ledger: n/a (performance)
hints executed: none printed

All local runs went through the host local-test.sh guard, with APM_E2E_TESTS=1. Lint mirror, all clean: ruff@0.15.12 check and format; pylint R0801 (src and scripts); lint-auth-signals.sh; complexity ratchet; taxonomy --changed; architecture boundaries.

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

…t collected fails

A required cell in tests/quality/harness_conformance.json must earn a passing
receipt. Until now ReceiptWitnessPlugin only checked witnesses that passed, so
a skipped witness left its required cell unproven without failing anything.

- ReceiptWitnessPlugin fails a skipped or xfailed witness of a required cell
  (setup or call phase), naming every cell and the skip reason. A cell that no
  longer applies leaves through the contract (applies()), not a run-time skip.
  Skips of nodes that witness no required cell stay skips.
- harness_ratchet.uncollected_witnesses(): every required witness node must be
  collected (pytest --collect-only over the witness modules), so a renamed or
  unparametrized witness is refused.
- Mutation tests: a required witness that skips fails the gate (pytester), a
  skip outside required cells stays a skip, and a dropped node is named as
  not collected.

Refs #5796

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…easured; plain skips and untracked xfails fail

Refs #5796

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…quired cells

A required cell's witness passes with a receipt, or is a strict
KnownFailure listed in required_known_failing whose tracking equals the
ledger issue, whose issue is open (closed-issue gate), and whose failure
matches. Any other xfail, a skip in any phase, an uncollected node or a
strict XPASS fails. The ledger only shrinks against the merge-base; a
base without the section compares against the frozen 8-cell #5797 set.

Refs #5796

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Adds src/apm_cli/lens/: model.py, the stdlib-only interface contract of the
apm list inventory (frozen dataclasses Source, Evidence, HarnessRef,
Location, Item, CoverageCell, NotVisible, Inventory), and verdict.py, the
only evidence -> state judgment (state, folder_content, item_state).

Registers the lens-observation owner with guard
registry-delegation-lens-observation: model.py imports only the standard
library, only verdict.py writes an APM health state, and no lens module
writes, deletes, spawns or opens a socket. One mutation case proves it.

Refs #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
J13 step 1 now runs 'apm run --list' against an O1 golden captured from
today's 'apm list' (the 0.39 scripts table), and asserts it runs nothing.
Step 4's diagnose advice moves to 'apm run --list'.

Refs #5756

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
'apm run --list' prints the 'apm list' scripts table or the No scripts
found panel byte-for-byte, exits 0 and runs nothing, so bare 'apm list'
can switch to the agent-config inventory. The script-not-found hint and
the docs now point to 'apm run --list'.

Refs #5756

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #5756

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Adds the test-only R0 layer of the apm list test plan: structured oracles,
pending-witness promises, laws, schema, mutations and static guards. No
committed cells: every HC-LIST promise stays pending-witness, so the
harness ratchet is untouched.

- oracles.Evidence gains json_equal and rows_equal (parsed path plus
  expected value), checked inside check_obligation; a mismatch or an
  unparseable output fails with no receipt.
- tests/lifecycle/list_oracle.py is the one parser of apm list output
  (schema-validated JSON views; text rows by header column spans; summary
  and footer by exact clause and line).
- HC-LIST-01..15 and HC-LIST-03.targets appended to harness_contract.py
  as pending-witness; HC-LIST-07 carries scopes=(user,) with a citation.
- P-LAW-list.* laws in the property catalog as forward laws citing #5745;
  the ledger guard accepts a law only when bug-referenced or forward with
  a cited issue.
- JSON Schema plus 4 outcome fixtures; S137 AST guard; C6 clone proof;
  tests/lifecycle/mutations/list.yaml.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
lens/apm_layers.py reads one scope's lockfile once and turns its deployment
ledger rows into logical items: kind and name come from the target layout,
rows for one physical path are deduped (targets kept apart), and
projections of one package item collapse into one item with several
locations. Each unique physical file is classified once through
deps/file_provenance.classify_file (made public at its owner). Folder items
get a bounded recursive name walk without link following: a file outside
the record makes the folder modified, a partial walk leaves it
unverifiable. Recorded values that escape their root are rejected
lexically, before any filesystem call. 'orphaned' is not produced in 0.40
(declared is 'yes' for every locked owner).

Refs #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
'apm run --list' no longer imports from list_cmd, whose scripts body goes
away when bare 'apm list' switches to the inventory. The renderer lives
in run.py (a new module would need an architecture owner); output stays
byte-identical. The list_cmd unit cases are ported to test_run_list.py.

Refs #5756

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
lens/inventory.build(ctx) reads each requested scope's APM layer once, asks
the reader package for native observations (an empty scan until the readers
land) and joins them: a native observation at or inside a path an APM item
lists is dropped, so one physical path is one location; a scope whose
lockfile is unreadable turns its native items into not-checked. APM
locations take HARNESSES from the reader records and keep ledger targets
apart. --target and NAME selection run before states are summarised, and
under exactly one --target same-name copies get the documented ORDER
(higher/lower with order_rank, coexist, or unknown; a missing copy is
never ranked). The context carries the keys the renderer needs.

Refs #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…es detection

The build input key for the --target selection is 'harnesses' (the target
vocabulary guard rejects a raw targets read in src). build() resolves the
detected harnesses (signal folders at the project and home roots, apm.yml
targets and ledger targets, kept to harness reader records) and passes the
selection and the detected set to the readers' scan. ORDER under one target
now uses the readers' tier_of and the record's ranked/coexist/unknown rule:
copies in one tier tie, and a copy whose tier cannot be read is unknown.

Refs #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
MCP ledger rows (uri locators under target mcp, one per runtime) become MCP
claims instead of file items. The inventory joins each claim to the
readers' observation of that server name for that runtime at that scope:
the location takes the observed config path and entry pointer, the
observation is claimed (not listed again as unrecorded), and the entry is
compared with the recorded fingerprint through the ownership owner's
mcp_native_hash, imported only when an entry is compared. Entry values are
read only for that comparison and never returned; the item carries the
readers' keys-only shape. An entry not observed is unverifiable.

Refs #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Mark test_run_list.py as component (it writes apm.yml and drives Click),
and keep the docs truthful while bare 'apm list' still lists scripts.

Refs #5756

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Run tests/quality/test_list_{conformance_guards,oracle}.py in the
  ratchet contracts job (ci.yml and merge-train.yml, kept identical).
- P-LAW-list.* forward laws are phase 0: no spine transition covers them
  until the list observation invariant lands.
- list_oracle: the command kind and Commands section; an empty inventory
  summary has no clause; rows() refuses -v detail lines, and details()
  attaches them to the row above.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
User-scope APM items now say they are declared in the $APM_HOME manifest,
shown as ~/.apm/apm.yml when it sits under the home root; project items
keep apm.yml.

Refs #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The oracle unit test credited a pending-witness cell id; use a neutral
cell id so the pending-witness leak guard stays clean.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Under -g the project scope has no root, so context.roots values may be
null. Reader order rules name the item kind (skill), unlike sources
(skills); HC-LIST-10 now applies where a skill rule is recorded.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…paths

- Item names drop any extension the registry gives the primitive, so one
  instruction deployed as name.instructions.md and name.md is one item.
- ORDER ranks each copy by the tier of its best location the target reads;
  only copies sharing a best tier tie.
- Recorded paths that map to no primitive layout, and paths not confined to
  their root, are coverage cells, never a made-up 'file' item; 'canvas'
  joins the kind vocabulary.
- User-scope rows under $HOME are matched under the target root install
  resolves (root variables such as CLAUDE_CONFIG_DIR honoured).
- Path dedupe and the ancestor manifest hint are separator-agnostic
  ('../apm.yml' on every OS).
- The folder walk cap is a read_layer parameter, so tests pass it instead
  of patching the owner.

Refs #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #5746, #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #5746, #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…rows

Refs #5746, #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Link ownership through path_security.user_owned_link, native activation keys
from native_plugins.settings, no target-vocabulary reads, records.py counted
as registry data by the harness-literal guard, and a vendor file name is not
the removed plugin-lifecycle symbol.

Refs #5746, #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…eeps its teeth

Refs #5746, #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #5746, #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…olders by descriptor

Folds AUD F1-F3: the managed-settings ownership gate is re-checked on fstat,
subfolders below a root are opened O_NOFOLLOW and listed by descriptor, and the
tombstone exemption applies only to the quoted installed_plugins.json name.

Refs #5746, #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… evidence

not_visible[].os and record OS rows use linux, macos and windows (sys.platform
mapped once). A plugin activation entry in a settings file now sets configured
and evidence_source on the install record with the same plugin id (narrowest
scope, then the file read last); an entry with no install record is one plugin
item with present no. Install records carry plugin@marketplace ids. Tests are
Windows-safe (bytes for frontmatter, absolute tmp system paths).

Refs #5746, #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #5746, #5754

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ine bypass

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Windows CI showed stat signatures cannot tell a same-size in-place
rewrite apart: NTFS mtime ticks are 100 ns and os.stat's st_ctime is
the creation time there; Linux's coarse kernel clock leaves the same
gap within a tick. Per AUD (K1-K4):
- LockFile._read_document reads the text through read_lockfile_text on
  every read (its link and regular-file refusals included) and recalls
  only when the full text is identical; only parse, validation, build
  and adoption are memoized;
- the key also carries adoption's other inputs: whether the path is the
  user scope root, and the home directory;
- the registry YAML memo reads the file each call and reparses only
  when its text changed;
- staged-entry identity, the forget on commit/remove/restore, pickled
  independent copies and the clear at pipeline start are kept.

The plugin journeys' fs.lockfile_reads rows return to #5839's values:
every read now reads the file, and the saving is the build (19 reads
build 5 LockFile objects on the 14-plugin world, 19 on #5839).

cost: one raw read per LockFile.read, as before #5838; no stat calls.

Refs #5838

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve normalizes a local plugin in a staging directory with an opaque
name. Normalization names a root-declared skill, and a manifest without
a name, after the directory it runs in, so reusing that image deployed
the root skill a second time under the staging name. Reuse now refuses
an image whose synthesized paths or metadata carry the staging name;
integrate normalizes it at its destination as before.

Refs #5838

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve normalizes a local plugin in an opaque staging slot. A
root-declared skill installed at user and project scope deploys once,
under the plugin's name, and is normalized again at its destination.
Red at bcd7a45 (the slot name deployed as a second skill).

Refs #5838

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The staging-name check read only apm.yml and the top-level .apm
metadata. It now reads every file normalization added, by path and by
content; a file that cannot be read as text still refuses reuse.

Refs #5838

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
APM_E2E_TESTS=1 turns the update notice off, so these cells failed in
any session that set it for the serve_offline perf modules. They now
clear it for themselves.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…irst)

Resolve walks every component of a path into directories not created
yet, even below a directory this command already proved link-free: on
the 14-plugin world that is about 470 full walks before the writes.
The cells expect one lstat for the first missing component, the same
answer as Path.resolve(), and no proof past a link, a file or a
volatile component.

Refs #5838

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A path whose directory is not proven yet was resolved by a full walk.
Below this command's deepest proven ancestor, each component now costs
one lstat: an existing plain directory is proven, the first missing
component ends the walk (nothing below it exists, so the path resolves
to itself), and a link, a file, a volatile name or an error takes the
full resolve as before. Linux keeps its kernel form.

Refs #5838

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel Daniel Meppiel (danielmeppiel) changed the title perf(path-security): read HOME once per -g write walk (#5838 slice 4a) perf(path-security): read HOME once per -g walk; prove new dirs from a proven ancestor (#5838 slice 4) Dec 3, 2026
… (red-first)

Each recorded path resolved the project root again: 20 locators, 20
root resolves. The cells expect one per command, and a root that an
APM rename released and a link replaced to be resolved afresh.

Refs #5838

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The locator resolved the project root, and an external deploy root, for
every path it encoded. realpath.resolve_root keeps a root's answer for
the command and drops it with the link-free proofs, so any rename,
delete or recreate APM performs resolves it afresh. File paths are still
resolved on every call.

Refs #5838

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The B3 count cell patched the owner's resolve_path (AQ004); it now
counts lstat calls on the root under the proof form. The path_home
rows take the values Linux PR CI measured at d8e0f0b (337 and 71).

Refs #5838

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel
Daniel Meppiel (danielmeppiel) marked this pull request as ready for review December 3, 2026 18:07
Copilot AI balanced review requested due to automatic review settings December 3, 2026 18:07
A regular file, a volatile directory and an unreadable component below
a proven directory each fall back to the full resolve and prove
nothing; a link later swapped into the volatile directory is refused.
A root resolve parked across a forget and a swap is never recalled.

Refs #5838

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Caches can return stale roots and deployment locators, user-scope remediation recommends the wrong install command, and the import-footprint test can pass despite command failure.

4 open issues
What changed in this PR

This PR reduces repeated work in APM’s install path, focusing on path resolution for multi-plugin installs under #5838. The supplied changes also include the read-only inventory and scripts-listing transition.

Changes:

  • Reduce HOME lookups, path walks, plugin normalization, discovery and repeated parsing.
  • Add inventory state handling and move script listing to apm run --list.
  • Extend performance checks, lifecycle coverage, architecture guards and documentation.
File Description
tests/​unit/​utils/​test_realpath_proof_lifetime.py Tests resolution costs and invalidation.
tests/​unit/​scripts/​test_architecture_runner.py Registers the observation rule.
tests/​unit/​scripts/​test_architecture_removed_plugin_tombstone.py Tests removed-symbol detection.
tests/​unit/​scripts/​test_architecture_harness_literals.py Allows reader registry literals.
tests/​unit/​lens/​test_verdict.py Tests inventory state judgments.
tests/​unit/​lens/​test_model.py Checks model import boundaries.
tests/​unit/​lens/​readers/​test_reader_records.py Validates reader records.
tests/​unit/​lens/​readers/​__init__.py Adds reader test package.
tests/​unit/​lens/​_list_fixtures.py Supplies synthetic inventories.
tests/​unit/​lens/​__init__.py Adds lens test package.
tests/​unit/​integration/​test_hook_shared_scope_claims.py Isolates memo counting.
tests/​unit/​install/​test_sources_selection.py Updates install context mocks.
tests/​unit/​install/​test_sources_materialisation.py Updates materialization mocks.
tests/​unit/​core/​test_runnable_prompts.py Updates script-listing advice assertion.
tests/​unit/​core/​test_remediation_commands_catalog.py Documents inventory remediation coverage.
tests/​unit/​core/​test_output_mode.py Enables update notices during tests.
tests/​quality/​test_lifecycle_bug_ledger.py Validates forward lifecycle laws.
tests/​quality/​test_known_cells_cite_open_issues.py Tests forward-law issue tracking.
tests/​quality/​promise-catalog.json Registers inventory and performance promises.
tests/​quality/​known_cell_issues.py Tracks forward laws and harness failures.
tests/​quality/​known_cell_issue_states.json Adds tracked issue states.
tests/​quality/​generated_obligations.json Adds scripts-output obligation.
tests/​lifecycle/​scenarios/​_list_kit.py Provides inventory lifecycle helpers.
tests/​lifecycle/​oracles.py Checks parsed inventory evidence.
tests/​lifecycle/​obligations.py Rejects unproven skipped witnesses.
tests/​lifecycle/​machines/​_spine_kit.py Checks inventory against lifecycle state.
tests/​lifecycle/​list_contract/​fixtures/​no-match.json Adds empty-result fixture.
tests/​lifecycle/​list_contract/​fixtures/​error.json Adds usage-error fixture.
tests/​lifecycle/​list_contract/​fixtures/​drift-unknown.json Adds drift and uncertainty fixture.
tests/​lifecycle/​list_contract/​fixtures/​clean.json Adds clean inventory fixture.
tests/​lifecycle/​journeys/​index.yaml Updates scripts journey command.
tests/​lifecycle/​journeys/​goldens/​J13/​01.txt Records scripts-listing output.
tests/​lifecycle/​journeys/​consumer/​J13-run-scripts.yaml Tests scripts-listing transition.
tests/​lifecycle/​driver.py Supports global inventory invocation.
tests/​integration/​test_remaining_modules_coverage.py Updates install context mocks.
tests/​integration/​test_perf_count_budgets.py Adds multi-plugin performance journeys.
tests/​integration/​test_local_bundle_hooks_lifecycle.py Clarifies inventory coverage in comments.
tests/​integration/​test_list_import_diet.py Checks inventory import footprint.
tests/​integration/​test_install_sources_classification.py Updates source classification mocks.
tests/​integration/​test_failure_next_step_lifecycle.py Exercises revised script-listing advice.
tests/​integration/​test_coverage_phase4.py Removes relocated scripts tests.
tests/​integration/​test_architecture_pack_lockfile_read.py Includes read memo ownership.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds observation-rule mutation.
tests/​integration/​test_architecture_lockfile_write_authority.py Updates reader routing expectation.
tests/​fixtures/​perf/​plugins.py Builds deterministic plugin workloads.
tests/​fixtures/​perf/​counters.py Adds function-call counters.
tests/​fixtures/​perf/​count_budgets.py Registers plugin journeys and counters.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.text_json_agree.json Defines text/JSON agreement law.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.scripts_transition.json Defines scripts transition law.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.read_only.json Defines read-only inventory law.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.nondisclosure.json Defines output nondisclosure law.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.json_contract.json Defines JSON output law.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.hostile_input.json Defines hostile-input handling law.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.honesty_vocabulary.json Defines inventory vocabulary constraints.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.extra_files.json Defines extra-file detection law.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.exit_contract.json Defines inventory exit codes.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.confinement.json Defines path confinement law.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.ci_isolation.json Defines CI scope isolation.
tests/​fixtures/​lifecycle_bug_ledger/​property_catalog/​list.audit_is_the_gate.json Separates observation from audit enforcement.
tests/​benchmarks/​spawn_counter/​sitecustomize.py Instruments calls with thread-safe counters.
src/​apm_cli/​utils/​realpath.py Extends proofs and caches root resolution.
src/​apm_cli/​utils/​path_security.py Reuses HOME within each walk.
src/​apm_cli/​utils/​content_hash.py Exposes hashed payload paths.
src/​apm_cli/​security/​content_scanner.py Uses regex-based character scanning.
src/​apm_cli/​primitives/​discovery.py Shares one discovery snapshot.
src/​apm_cli/​lens/​verdict.py Centralizes inventory state judgments.
src/​apm_cli/​lens/​ci_scope.py Determines CI scope restrictions.
src/​apm_cli/​lens/​__init__.py Introduces observation package.
src/​apm_cli/​integration/​prompt_integrator.py Defers resolver initialization.
src/​apm_cli/​integration/​instruction_integrator.py Defers resolver initialization.
src/​apm_cli/​integration/​agent_integrator.py Defers resolver initialization.
src/​apm_cli/​integration/​__init__.py Loads public exports lazily.
src/​apm_cli/​install/​sources.py Reuses validated plugin images.
src/​apm_cli/​install/​source_helpers.py Avoids repeated digest recording.
src/​apm_cli/​install/​run_memos.py Centralizes install memo resets.
src/​apm_cli/​install/​pipeline.py Invokes centralized memo reset.
src/​apm_cli/​install/​phases/​resolve.py Records reusable plugin images.
src/​apm_cli/​install/​phases/​finalize.py Skips unnecessary hint discovery.
src/​apm_cli/​install/​local_plugin_image.py Validates same-run plugin reuse.
src/​apm_cli/​install/​context.py Stores reusable plugin records.
src/​apm_cli/​deps/​registry/​config_loader.py Memoizes unchanged YAML parsing.
src/​apm_cli/​deps/​lockfile.py Reuses lockfile document snapshots.
src/​apm_cli/​deps/​lockfile_write_authority.py Invalidates snapshots after writes.
src/​apm_cli/​deps/​lockfile_read_memo.py Stores independent lockfile snapshots.
src/​apm_cli/​deps/​file_provenance.py Exposes shared byte classification.
src/​apm_cli/​core/​script_runner.py Updates script-listing advice.
src/​apm_cli/​core/​remediation.py Adds missing-item remediation.
src/​apm_cli/​core/​deployment_ledger.py Uses cached containment roots.
src/​apm_cli/​commands/​run.py Adds --list scripts output.
src/​apm_cli/​commands/​deps/​__init__.py Loads dependency commands lazily.
src/​apm_cli/​commands/​__init__.py Removes eager command imports.
src/​apm_cli/​cli.py Updates inventory help and offline dispatch.
scripts/​architecture_linter/​groups/​registry_delegation.py Includes observation checks.
scripts/​architecture_linter/​checks/​registry_lens_observation.py Guards read-only observation boundaries.
scripts/​architecture_linter/​checks/​registry_harness_literals.py Recognizes reader registry ownership.
scripts/​architecture_linter/​checks/​marketplace_bundle_and_audit.py Allows vendor install-record filenames.
scripts/​architecture_linter/​checks/​contracts_lockfile_write_authority.py Follows extracted document reader.
scripts/​architecture_linter/​checks/​contracts_lockfile_regular_read.py Updates regular-read routing checks.
scripts/​architecture_linter/​checks/​contracts_lockfile_generator.py Updates version-warning routing checks.
packages/​apm-guide/​.apm/​skills/​apm-usage/​commands.md Documents inventory and scripts commands.
docs/​src/​content/​docs/​troubleshooting/​index.md Explains inventory versus packages.
docs/​src/​content/​docs/​troubleshooting/​common-errors.md Updates script recovery advice.
docs/​src/​content/​docs/​reference/​cli/​run.md Documents run --list.
docs/​src/​content/​docs/​reference/​cli/​preview.md Updates scripts-listing link.
docs/​src/​content/​docs/​integrations/​canvas.md Documents canvas inventory visibility.
docs/​src/​content/​docs/​consumer/​install-packages.md Updates scripts-listing reference.
changelog.d/​5843.fixed.md Records HOME lookup reduction.
changelog.d/​5842.fixed.md Records deferred resolver initialization.
changelog.d/​5841.fixed.md Records discovery and parsing reuse.
changelog.d/​5839.fixed.md Records normalization and scanning improvements.
changelog.d/​5812.breaking-changes-and-upgrade-notes.md Explains scripts-listing migration.
changelog.d/​5812.added.md Announces inventory output.
changelog.d/​5806.added.md Announces run --list.
.github/​workflows/​merge-train.yml Runs inventory quality checks.
.github/​workflows/​ci.yml Runs inventory quality checks.
.apm/​architecture/​owners/​install-deployment.json Registers plugin reuse and memo ownership.
.apm/​architecture/​owners/​core-runtime.json Registers observation ownership.
.apm/​architecture/​owners/​contracts-tooling.json Registers lockfile read memo ownership.

Review effort: Balanced

"orphaned-packages-prune", "apm prune", "remove the orphaned packages"
)
# apm list: APM-recorded items whose deployed files are absent (fresh clone).
LIST_MISSING_ITEMS = _entry("list-missing-items", "apm install", "deploy {count}")
Comment on lines +35 to +39
def _version(path: Path, kind: str, payload: Any) -> tuple[str, Any, tuple[bool, str]]:
"""*payload* plus the inputs adoption reads besides the bytes (user scope, home)."""
from ..core.scope import is_user_scope_root

return (kind, payload, (is_user_scope_root(path.parent), str(Path.home())))
Comment on lines +358 to +360
hit = memo.get(key)
if hit is not None and hit[0] == seen:
return hit[1]
"import sys\n"
"from click.testing import CliRunner\n"
"from apm_cli.cli import cli\n"
"CliRunner().invoke(cli, ['list', '-f', 'json'])\n"
Measured on Linux PR CI on train-5 tip d7b9a2f composed with this PR
(scratch #5853): install-g-14-plugins lstat 14,189; the 23-plugin
re-pass lstat 17,842 and realpath 1,405. Every other row held.

Refs #5838

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-integration Run the full integration suite (ci-integration.yml) on this PR before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants