Skip to content

fix: link sibling skills from skills to the deployed copy (#5733) - #5741

Merged
Daniel Meppiel (danielmeppiel) merged 20 commits into
mainfrom
danielmeppiel-pgm-engineer-sibling-links
Dec 2, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 20 commits into
mainfrom
danielmeppiel-pgm-engineer-sibling-links

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Fixes #5733; follows #5539.

#5539 (for #5531) made agents, instructions, prompts and commands link a sibling skill to its deployed copy. This PR does the same for skills: a Markdown link inside a skill that targets a file the same install deploys into the same harness skills folder now points at the deployed copy, and the #fragment is kept. Any other in-package link keeps the apm_modules/ link (the #1160 fallback). Before, committed .agents/skills/ linked into gitignored apm_modules/ and broke on a fresh clone.

  • Per-folder map: SkillIntegrator._distinct_skill_roots builds the deployed-skill map once per distinct skills folder in both promotion paths, using the effective pairing and the full skill target list. It replaces the two copies of the per-root loop.
  • Collision preflight: skill_preflight.find_unmanaged_conflicts renders each destination with the same per-folder map (one resolver per folder), so identical files are adopted instead of refused as false collisions.
  • Earlier-version projection: projected_resolve_links(deployed_links=True, source_plan=locked) renders the locked source with the locked plan's own deployed-sibling map, using the link scope (target, pairing, skill targets) that init_link_resolver records. A ref bump on a fresh clone therefore adopts committed output in the new link form, also when the new version renames or drops the linked sibling file. Collision preflight caches each folder's resolver together with its scope.
  • Upgrade path (fail-closed): an unreceipted, claimed skill tree is also adopted when every member equals, byte for byte, the pre-fix rendering of the same source (sibling links through apm_modules/, from BaseIntegrator.legacy_resolve_links). One rendering per tree; the ownership check is unchanged. The second render runs only after the receipt short-circuit and an empty first compare. An edited link, a mixed-form tree or an unclaimed tree is refused as before.
  • Planned skill map: the memoised planned_skill_files (fix: resolve sibling skill links for instructions, prompts, and commands (#5531) #5539) is now returned as a read-only MappingProxyType and also keyed by the package install path.
  • fix: resolve sibling skill links for instructions, prompts, and commands (#5531) #5539 fallout: test_mixed_case_materialization_lifecycle (Integration, never run on the fork PR) now accepts the deployed skill copy for every primitive, and adds a non-deployed link so a mixed-case apm_modules/ link still carries the stale-casing step.
  • This repository: .agents/skills/docs-sync/SKILL.md is re-rendered (two lockfile hash lines), and test_governance_consumers now checks it against the deployed-sibling rendering, still byte-exact.

Upgrade note: apm audit reports committed pre-fix sibling links as drift until the next apm install re-renders them (regent ruling: no audit tolerance).

Out of scope: bin/ links; compile-time AGENTS.md links.

Issue and approved scope

Issue: Fixes #5733

Human scope-approval comment: #5733 (comment) (scripts/governance/eligibility.cjs: record-present, review contact danielmeppiel).

This PR completes #5733. #5531 was completed by #5539.

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-INV-I7 -- a deployed skill linking to a file the same install deploys into the same skills folder resolves to the committed deployed copy; other links keep apm_modules (source: #5733)
instrument: today test -> tests/integration/test_sibling_skill_agent_link_lifecycle.py::test_primitive_links_to_sibling_skill_resolve_on_a_fresh_clone (skill rows), ::test_issue_5733_skill_to_skill_links_resolve_on_a_fresh_clone (reporter fixture, #identity)
oracles: [I2 byte-stable reinstall, I3 audit --ci, I6 ascii, fresh-clone oracle, lockless reinstall adopts identical bytes]
failing-before: red-first 3bc852dc on main -> skill rows and the #5733 cell red
guard+mutation: install-deployment-skills-root-derivation MutationCase text moved to the shared-root lambda; manual mutations: no preflight map -> lockless reinstall refused; projection without the locked plan -> both ref-bump cells red (incl. test_ref_bump_renaming_a_linked_sibling_on_fresh_clone_adopts_locked_output, red-first); no legacy render -> pre-fix upgrade refused
ledger: tests/fixtures/lifecycle_bug_ledger/bugs/5733.json
promise: P-INV-I3/I7 -- an upgrade from pre-fix output: audit --ci and install --frozen agree; install adopts only an exact single-form, claimed tree
instrument: ::test_upgrade_from_pre_fix_output_rerenders_sibling_links[pre-fix-output|user-edited-link|mixed-form-tree|unclaimed-identical-tree]
decisive: the pre-fix tree is adopted and re-rendered to the deployed bytes; the negatives exit 1 and keep the tree and lockfile bytes

Perf (security co-owns perf; macOS, measure mode, main vs head): fs.stat_calls is at or below main on every install journey, for example install-g-50-skills 9145 -> 9142 and install-cold 12455 -> 12452.

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.

apm-spec-waiver: deployed-copy link rendering is not normed by any OpenAPM v0.1 requirement

Agent assessment

Sami (Yshuro) and others added 5 commits November 26, 2026 18:24
…nds (#5531)

Signed-off-by: Yshuro <yshuro1080@gmail.com>
Signed-off-by: Yshuro <yshuro1080@gmail.com>
Red-first cells for #5733 and #5531: skills, instructions, prompts and
commands that link to a sibling skill deployed into the same harness
folder must link the deployed copy (fragment kept) and survive a fresh
clone; non-deployed files and siblings deployed only to another folder
keep the apm_modules link.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Skills, instructions, prompts and commands now get the deployed-file map
agents got in #5529: a link to a file this install deploys into the same
harness skills folder names the deployed copy, fragment kept; other
in-package links keep the apm_modules link.

- instruction, prompt and command integrators pass target, source plan,
  pairing and skill targets to init_link_resolver (rule preflight too)
- skill promotion builds the map once per distinct skills root
- skill collision preflight renders with the same per-root map, so
  identical files are adopted, not refused
- the earlier-version projection re-roots the map, so a ref bump on a
  fresh clone still adopts committed output

Closes #5733, closes #5531.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 2, 2026 10:02
apm-spec-waiver: deployed-copy link rendering is not normed by any OpenAPM v0.1 requirement

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

Link-rendering mismatches for renamed assets and legacy output can cause installs or updates to reject untouched, lock-claimed skills when deployment receipts are absent.

2 open issues
What changed in this PR

Extends deployed sibling-skill links from agents to skills, instructions, prompts, and commands, addressing #5531 and #5733 so committed output works without apm_modules/.

Changes:

  • Threads target selection through shared link rendering.
  • Aligns skill preflight and locked-source replay with deployed links.
  • Adds lifecycle coverage, documentation, and a changelog entry.
File Description
tests/​integration/​test_sibling_skill_agent_link_lifecycle.py Covers primitive links, pairing, and fresh clones.
tests/​integration/​test_lock_derived_expected_state_lifecycle.py Updates ref-bump link expectations.
tests/​integration/​test_architecture_owner_rule_mutations.py Adjusts the skills-root mutation.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​5733.json Records skill-link regression coverage.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​5531.json Records other primitive-link coverage.
src/​apm_cli/​integration/​skill_preflight.py Uses per-folder link maps for comparisons.
src/​apm_cli/​integration/​skill_integrator.py Shares distinct-root promotion setup.
src/​apm_cli/​integration/​prompt_integrator.py Passes skill selection into prompt rendering.
src/​apm_cli/​integration/​instruction_integrator.py Configures target-aware instruction rendering.
src/​apm_cli/​integration/​command_integrator.py Configures target-aware command rendering.
src/​apm_cli/​integration/​base_integrator.py Re-roots link maps for locked-source replay.
src/​apm_cli/​install/​template.py Passes pairing into skill preflight.
src/​apm_cli/​install/​services.py Threads pairing through primitive dispatch.
docs/​src/​content/​docs/​producer/​write-primitives.md Documents deployed-copy links and fallback.
changelog.d/​5741.fixed.md Announces the sibling-link fix.

Review effort: Balanced

An unreceipted skill tree in the pre-fix apm_modules link form is
adopted and re-rendered; a user-edited link, a mixed-form tree and an
unclaimed identical tree are refused and kept. audit --ci and
install --frozen agree before and after.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- BaseIntegrator.init_target_link_resolver is the one entry the
  target-driven integrators share (removes the duplicated preamble)
- adoption of an unreceipted, claimed skill tree also accepts the exact
  bytes of the pre-fix rendering (sibling links through apm_modules),
  one rendering per tree, ownership still required; anything else is
  refused as before
- re-render the repository's own .agents/skills/docs-sync/SKILL.md
- the cold-restore fixture keeps its sibling link and adds a link that
  is still rewritten
- changelog: run apm install once after upgrading

apm-spec-waiver: deployed-copy link rendering is not normed by any OpenAPM v0.1 requirement

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>
…ntry

- drop the bin/ link threading (skip_bin): out of scope for #5531; the
  planned skill map keeps excluding bin/ as before
- BaseIntegrator.init_target_link_resolver is the one entry the agent,
  instruction, prompt and command integrators use (no duplicated
  preamble)
- lifecycle cells for instructions, prompts and commands: fresh-clone
  oracle, a non-deployed file and an other-harness sibling keep the
  apm_modules link, reinstall and audit --ci converge
- docs: links from every primitive name the deployed sibling copy
- lifecycle bug-ledger row for #5531

apm-spec-waiver: deployed-copy link rendering is not normed by any OpenAPM v0.1 requirement

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>

# Conflicts:
#	docs/src/content/docs/producer/write-primitives.md
#	src/apm_cli/install/services.py
#	src/apm_cli/integration/base_integrator.py
#	src/apm_cli/integration/instruction_integrator.py
#	tests/fixtures/lifecycle_bug_ledger/bugs/5531.json
#	tests/integration/test_sibling_skill_agent_link_lifecycle.py
Every primitive of a package asks for the same target's deployed-skill
map; memoising it per live source plan (cleared when the plan is
collected) walks the skill trees once per target, as agents alone did
before, instead of once per primitive.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The memoised deployed-skill map is returned as a read-only mapping and
keyed by the package install path too.

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

# Conflicts:
#	docs/src/content/docs/producer/write-primitives.md
#	src/apm_cli/integration/base_integrator.py
#	src/apm_cli/integration/skill_preflight.py
#	tests/integration/test_sibling_skill_agent_link_lifecycle.py
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel Daniel Meppiel (danielmeppiel) changed the title fix: link sibling skills from every primitive to the deployed copy fix: link sibling skills from skills to the deployed copy (#5733) Dec 2, 2026

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

The projection uses the current file inventory, so a ref bump that renames or removes a linked sibling can produce an incorrect link and reject an unchanged fresh clone without receipts.

2 open issues
1 resolved since last review

Review effort: Balanced

- projected_resolve_links(deployed_links=True) renders the locked source
  with the deployed-sibling map of the locked plan (LockedSkillSources),
  using the link scope init_link_resolver records; no locked plan means
  no projection, so adoption keeps refusing. A ref bump that renames the
  linked sibling no longer refuses committed output on a fresh clone.
- collision preflight caches each skills folder's resolver with its scope
- cells: ref bump renaming a linked sibling (red-first); ref-bump
  mixed-form, unclaimed and unpinned trees refuse and keep their bytes
- mixed-case lifecycle: every primitive links the deployed skill; a
  non-deployed file keeps the mixed-case apm_modules link for the
  stale-casing repair path (#5539 change; Integration never ran on it)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit ef53e98 into main Dec 2, 2026
101 of 103 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-pgm-engineer-sibling-links branch December 2, 2026 13:53
@danielmeppiel Daniel Meppiel (danielmeppiel) mentioned this pull request Dec 2, 2026
5 of 10 tasks
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.

[BUG] Skill-to-skill links rewrite to gitignored apm_modules in vendored output

3 participants