Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
6c5f051
feat(install): render bundle agents to Codex TOML at install (#3714)
danielmeppiel Nov 19, 2026
9daf57b
test(install): cover Codex bundle agent rendering and guard its owner…
danielmeppiel Nov 20, 2026
8e25e32
docs(changelog): note Codex bundle agent rendering (#3714)
danielmeppiel Nov 20, 2026
dd52e99
test(install): give the user-scope bundle audit a user manifest (#3714)
danielmeppiel Nov 20, 2026
58a11c1
fix(install): key -g bundle agent collisions relative to their root (…
danielmeppiel Nov 20, 2026
980bb3a
test(spec): bundle Codex agents honour req-tg-006 and req-tg-015 (#3714)
danielmeppiel Nov 20, 2026
3dc9331
test(install): user-scope bundle agent lock and audit run in $APM_HOM…
danielmeppiel Nov 20, 2026
56b1e08
test(install): services.py LOC budget after rebasing on 0.37 main (#3…
danielmeppiel Nov 20, 2026
f70cd41
test(install): classify #3714 test modules and repoint the #3705 ledg…
danielmeppiel Nov 21, 2026
8b1de0b
docs: say bundle agents are rendered to Codex TOML at install (#3714)
danielmeppiel Nov 20, 2026
727dbd8
Merge main into danielmeppiel-improved-lamp
danielmeppiel Nov 21, 2026
9f590ff
fix(install): harden bundle Codex agent render (#3714)
danielmeppiel Nov 21, 2026
773d78f
fix(install): strict Codex fields for bundle agents; drift skips exte…
danielmeppiel Nov 21, 2026
5a80be1
Merge main (0c349e03) into danielmeppiel-improved-lamp
danielmeppiel Nov 21, 2026
0f2040e
docs: note bundle Codex agents with empty fields are skipped (#3714)
danielmeppiel Nov 21, 2026
7d9015b
test: TOCTOU regression patches the read boundary, not the renderer o…
danielmeppiel Nov 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .apm/architecture/owners/install-deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@
},
{
"id": "bundle-native-layout-lowering",
"decision": "Bundle-native directory and filename lowering to APM primitive kinds and target deploy layout",
"owner": "bundle/plugin_layout.py (PLUGIN_LAYOUT, plugin_command_prompt_name) consumed by install/local_bundle_paths.py (_lower_to_target)",
"decision": "Bundle-native directory and filename lowering to APM primitive kinds and target deploy layout, including which packed agents are rendered (codex_agent) instead of copied",
"owner": "bundle/plugin_layout.py (PLUGIN_LAYOUT, plugin_command_prompt_name) consumed by install/local_bundle_paths.py (_lower_to_target, bundle_render_format_id); rendered Codex agents deploy through install/local_bundle_agents.py via AgentIntegrator._render_codex_agent and _deploy_rendered_agent",
"selectors": [
"src/apm_cli/bundle/plugin_layout.py",
"src/apm_cli/install/local_bundle_paths.py"
"src/apm_cli/install/local_bundle_paths.py",
"src/apm_cli/install/local_bundle_agents.py"
],
"guards": ["install-deployment-bundle-native-layout"]
},
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- The registries reference documents the enterprise publish, install and cold-CI `--frozen` workflow, now verified end to end against the Registry HTTP API on every PR. (#4015)
- `apm install <bundle>` renders bundle agents to Codex TOML in `.codex/agents/` instead of skipping them; agents Codex cannot load (empty description or body) are skipped with a warning, and other targets still copy bundle files. (closes #3714, #4007)
- The CLI reference lists every deprecation with its replacement, the version that deprecated it and its removal horizon; warning text is unchanged. (closes #4019, #4035)

### Changed
Expand Down
8 changes: 6 additions & 2 deletions CONFORMANCE.json
Original file line number Diff line number Diff line change
Expand Up @@ -3034,15 +3034,17 @@
},
{
"behavioral_tests": [
"tests/spec_conformance/test_local_bundle_agent_reqs.py::test_bundle_codex_agent_diagnoses_dropped_capability_restriction",
"tests/spec_conformance/test_manifest_reqs.py::test_consumer_diagnoses_lossy_agent_capability_conversion"
],
"conformance_class": "consumer",
"id": "req-tg-006",
"keyword": "MUST",
"section": "8.5",
"status": "active",
"test_count": 1,
"test_count": 2,
"tests": [
"tests/spec_conformance/test_local_bundle_agent_reqs.py::test_bundle_codex_agent_diagnoses_dropped_capability_restriction",
"tests/spec_conformance/test_manifest_reqs.py::test_consumer_diagnoses_lossy_agent_capability_conversion"
]
},
Expand Down Expand Up @@ -3211,6 +3213,7 @@
},
{
"behavioral_tests": [
"tests/spec_conformance/test_local_bundle_agent_reqs.py::test_bundle_codex_agent_keeps_native_model_settings",
"tests/spec_conformance/test_manifest_reqs.py::test_codex_claude_model_value_preserved_verbatim[claude-sonnet-4-5]",
"tests/spec_conformance/test_manifest_reqs.py::test_codex_claude_model_value_preserved_verbatim[haiku]",
"tests/spec_conformance/test_manifest_reqs.py::test_codex_claude_model_value_preserved_verbatim[inherit]",
Expand All @@ -3223,8 +3226,9 @@
"keyword": "MUST",
"section": "8.5.1",
"status": "active",
"test_count": 6,
"test_count": 7,
"tests": [
"tests/spec_conformance/test_local_bundle_agent_reqs.py::test_bundle_codex_agent_keeps_native_model_settings",
"tests/spec_conformance/test_manifest_reqs.py::test_codex_claude_model_value_preserved_verbatim[claude-sonnet-4-5]",
"tests/spec_conformance/test_manifest_reqs.py::test_codex_claude_model_value_preserved_verbatim[haiku]",
"tests/spec_conformance/test_manifest_reqs.py::test_codex_claude_model_value_preserved_verbatim[inherit]",
Expand Down
4 changes: 2 additions & 2 deletions CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ APM implements the proposed staged-replacement recovery capability (req-lk-023).
| [req-tg-003](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-003) | MUST | 8.5 | consumer | active | 1 / 2 | - |
| [req-tg-004](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-004) | MUST | 4.2.1 | consumer | active | 2 / 3 | - |
| [req-tg-005](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-005) | MUST | 8.5 | consumer | active | 13 / 14 | - |
| [req-tg-006](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-006) | MUST | 8.5 | consumer | active | 1 / 1 | - |
| [req-tg-006](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-006) | MUST | 8.5 | consumer | active | 2 / 2 | - |
| [req-tg-007](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-007) | MUST | 8.5 | consumer | active | 1 / 1 | - |
| [req-tg-008](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-008) | MUST | 8.5.3 | consumer | active | 8 / 8 | - |
| [req-tg-009](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-009) | MUST | 8.5.1 | consumer | active | 2 / 2 | - |
Expand All @@ -196,7 +196,7 @@ APM implements the proposed staged-replacement recovery capability (req-lk-023).
| [req-tg-012](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-012) | MUST | 8.5.6 | consumer | active | 7 / 7 | - |
| [req-tg-013](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-013) | MUST | 8.5.7 | consumer | active | 6 / 7 | - |
| [req-tg-014](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-014) | MUST | 8.5.8 | consumer | active | 2 / 2 | - |
| [req-tg-015](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-015) | MUST | 8.5.1 | consumer | active | 6 / 6 | - |
| [req-tg-015](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-015) | MUST | 8.5.1 | consumer | active | 7 / 7 | - |
| [req-tg-016](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-016) | MUST | 8.5.9 | consumer | active | 1 / 2 | - |
| [req-tg-017](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-017) | MUST | 8.5.9 | consumer | active | 2 / 3 | - |
| [req-tg-018](docs/src/content/docs/specs/openapm-v0.1.md#req-tg-018) | MUST | 8.5.10 | consumer | active | 9 / 9 | - |
Expand Down
3 changes: 2 additions & 1 deletion docs/src/content/docs/consumer/install-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ apm install ./dist/review-skills-1.1.0.zip --target copilot
```

APM checks the files against the hashes `apm pack` recorded in the bundle,
deploys them and records them in `apm.lock.yaml`. It does not edit an existing `apm.yml`;
deploys them and records them in `apm.lock.yaml`. Files are copied, except
agents for Codex, which are rendered to TOML in `.codex/agents/`. It does not edit an existing `apm.yml`;
in a project without one it creates the same minimal `apm.yml` that `apm install <pkg>` does, so
`apm audit --ci` can check the install. A reinstall
removes bundle MCP and LSP servers that are no longer shipped, are denied or are not
Expand Down
4 changes: 3 additions & 1 deletion docs/src/content/docs/producer/build-a-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ apm install ../review-plugin

To check the bundle the way a non-APM consumer receives it, install it from
disk: `apm install ./build/review-plugin-0.1.0`. APM rejects the bundle if any
file differs from the hashes embedded in its lockfile. More in
file differs from the hashes embedded in its lockfile. Install copies bundle
files into each target's layout, except that it renders agents to TOML for
Codex. More in
[Test a package locally](../test-packages/).

## Next
Expand Down
6 changes: 6 additions & 0 deletions docs/src/content/docs/reference/cli/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@ apm install ./my-bundle.zip --as custom-name
apm install ./my-bundle --target opencode
```

Bundle files are copied into each target's layout, except agents for Codex:
those are rendered to TOML in `.codex/agents/` (with `-g`, `~/.codex/agents/`
or `$CODEX_HOME/agents/`), and the lockfile records the rendered hash. An agent
that cannot be rendered, or whose name, description or body is empty (Codex
rejects those), is skipped with a warning.

:::note[Claude bundles only]
This imperative route deploys Claude plugin bundles (the default `apm pack`
output). The bundle's `hooks.json` and `hooks/` scripts are registered through
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ symlinked source files and names each skipped link in a warning.

`apm install <bundle>` (a packed Claude plugin bundle) registers plugin hooks
like a source install once the bundle key is approved; see
[Hook files](#hook-files).
[Hook files](#hook-files). It copies other bundle files into each target's
layout, except agents for Codex, which it renders to TOML in `.codex/agents/`.

**Recommendation for marketplace publishers:** use `.apm/<type>/` for
every primitive. This is the only layout that is symmetric between
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
_subdir_python,
)
from scripts.architecture_linter.facts import FactsProvider
from scripts.architecture_linter.groups.common import checked_facts, violation
from scripts.architecture_linter.groups.common import checked_facts, forbid_text, violation
from scripts.architecture_linter.models import Rule, Violation

_AGENT_PLUGINS_PREFIX = "src/apm_cli/agent_plugins/"
Expand Down Expand Up @@ -300,6 +300,7 @@ def _check_legacy_skill_membership(provider: FactsProvider) -> tuple[Violation,

_PLUGIN_LAYOUT = "src/apm_cli/bundle/plugin_layout.py"
_LOCAL_BUNDLE_PATHS = "src/apm_cli/install/local_bundle_paths.py"
_LOCAL_BUNDLE_AGENTS = "src/apm_cli/install/local_bundle_agents.py"
_INSTALL_SERVICES = "src/apm_cli/install/services.py"
_TARGET_NAME_COMPARISON = re.compile(r"\btarget\.name\s*(?:==|!=)|(?:==|!=)\s*target\.name\b")

Expand Down Expand Up @@ -335,11 +336,47 @@ def _check_bundle_native_layout(provider: FactsProvider) -> tuple[Violation, ...
"PLUGIN_LAYOUT.get(head)",
"for primitive_kind in spec.primitive_kinds:",
"_retarget_basename(parts[-1], mapping, spec.apm_basename_fn)",
'_UNSUPPORTED_PLUGIN_FORMAT_IDS = frozenset({"gemini_command", "codex_agent"})',
'_UNSUPPORTED_PLUGIN_FORMAT_IDS = frozenset({"gemini_command"})',
'_RENDERED_PLUGIN_FORMAT_IDS = frozenset({"codex_agent"})',
),
"local bundle deployment must route through PLUGIN_LAYOUT and TargetProfile.primitives",
)
)
# Codex bundle agents render through AgentIntegrator, never a copy (#3714).
findings.extend(
_require_subs(
provider,
inv,
_RID_BUNDLE_LAYOUT,
_INSTALL_SERVICES,
("if _bundle_render_format(", "skipped += _deploy_bundle_codex_agent("),
"the bundle deploy loop must hand rendered-format agents to local_bundle_agents",
)
)
findings.extend(
_require_subs(
provider,
inv,
_RID_BUNDLE_LAYOUT,
_LOCAL_BUNDLE_AGENTS,
(
"integrator._render_codex_agent(",
"resolve_links=integrator.resolve_links",
"integrator._deploy_rendered_agent(",
"managed_files=None",
),
"bundle Codex agents must render and deploy through AgentIntegrator",
)
)
findings.extend(
forbid_text(
provider,
rule_id=_RID_BUNDLE_LAYOUT,
path=_LOCAL_BUNDLE_AGENTS,
needles=("write_text", "write_bytes", "shutil", ".open("),
message="bundle Codex agents are written only by AgentIntegrator._deploy_rendered_agent",
)
)
for path in (_LOCAL_BUNDLE_PATHS, _INSTALL_SERVICES):
facts, failures = checked_facts(provider, path, _RID_BUNDLE_LAYOUT, require_python=True)
if failures:
Expand Down
19 changes: 10 additions & 9 deletions src/apm_cli/core/deployment_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,12 +1284,15 @@ def record_local_bundle_files(
staged: Collection[str] = (),
staged_hashes: Mapping[str, str] | None = None,
staged_fallback_hashes: Mapping[str, str] | None = None,
targets: Mapping[str, str] | None = None,
) -> None:
"""Persist imperative bundle files without making them replayable source.

*scope* is the install scope that deployed *files*; their rows record
it, so a user-scope bundle keeps ``scope: user`` (#3995). It has no
default: the owner never guesses a scope.
default: the owner never guesses a scope. *targets* names the target
of a claim its path cannot attribute (under an external root such as
``$CODEX_HOME``), so audit resolves it through that target (#3714).

*staged* is compile input under ``apm_modules/<slug>/.apm/`` (#3705):
it is recorded in ``local_staged_files`` and never claimed. Every prior
Expand Down Expand Up @@ -1327,11 +1330,11 @@ def record_local_bundle_files(
merged_hashes,
)

scope_value = scope.value
DeploymentLedgerCodec._mark_local_bundle_paths(
lockfile,
prior_bundle_paths.union(files),
scopes=dict.fromkeys(files, scope_value),
scopes=dict.fromkeys(files, scope.value),
targets=targets,
)
lockfile.local_staged_files = sorted(
set(lockfile.local_staged_files).union(staged, retired_paths)
Expand Down Expand Up @@ -1663,10 +1666,11 @@ def _mark_local_bundle_paths(
bundle_paths: frozenset[str],
*,
scopes: Mapping[str, str] | None = None,
targets: Mapping[str, str] | None = None,
) -> None:
"""Mark existing ledger rows as hash-audited imperative bundle output.

*scopes* records the install scope of a path's bundle claim.
*scopes* and *targets* record the install scope and target of a claim.
"""
if not bundle_paths:
return
Expand All @@ -1679,11 +1683,8 @@ def _mark_local_bundle_paths(
_require_local_bundle_hash(path, record.content_hash)
owners = tuple(owner for owner in record.owners if owner != _LOCAL_BUNDLE_OWNER)
scope = (scopes or {}).get(path, record.locator.scope)
locator = (
record.locator
if scope == record.locator.scope
else replace(record.locator, scope=scope)
)
target = (targets or {}).get(path, record.locator.target)
locator = replace(record.locator, scope=scope, target=target)
del records[key]
records[locator.key] = DeploymentRecord(
locator=locator,
Expand Down
5 changes: 5 additions & 0 deletions src/apm_cli/install/drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,11 @@ def diff_scratch_against_project(
from apm_cli.core.deployment_ledger import DeploymentLedgerCodec

local_bundle_paths = DeploymentLedgerCodec.local_bundle_paths(lockfile)
# An absolute claim under an external target root ($CODEX_HOME) is compared
# rebased onto that root, as its tracked claim is (#3714).
local_bundle_paths |= ReplayClaims.rebased(
local_bundle_paths, project_root, targets=tuple(targets), absolute_only=absolute_claims_only
)
if local_bundle_paths:
scratch_files = {
relative_path: path
Expand Down
17 changes: 17 additions & 0 deletions src/apm_cli/install/drift_claims.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ def rebase(claims: dict[str, str]) -> dict[str, str]:
hashed = set(rebase(dict.fromkeys(hashed_claims, "")))
return cls(tracked, claimed_prefixes(tracked, hashed, project_files), frozenset(shared))

@staticmethod
def rebased(
paths: Collection[str],
project_root: Path,
*,
targets: tuple[Any, ...],
absolute_only: bool,
) -> frozenset[str]:
"""Return *paths* rebased onto *project_root* the way :meth:`build` rebases claims."""
from apm_cli.install.audit_target_roots import claims_for_root

return frozenset(
claims_for_root(
dict.fromkeys(paths, ""), project_root, absolute_only=absolute_only, targets=targets
)
)

def unclaimed(self, rel: str) -> bool:
"""Return True when no lock entry, directory claim or shared config covers *rel*."""
return not (rel in self.tracked or rel.startswith(self.prefixes) or rel in self.shared)
Loading