Files
PaperClipAI/packages
DottaandPaperclip b4cef7c8c8 fix(runner): load assigned skills by their granted runtime name (#21445)
## Thinking Path

> - Paperclip manages AI agents and their assigned skills.
> - Runner copies each assigned skill into a private provider home.
> - Paperclip gives company skills a unique runtime name.
> - OpenCode reads the name from the skill document.
> - The copied document kept the source name, so the assigned name
failed to load.
> - This change aligns the copied name with the granted name.
> - Agents can then find the skill under the name in their assignment.

## Linked Issues or Issue Description

**What happened?**

OpenCode rejected an assigned review skill name with a generated suffix.
It listed the source name instead. The agent made another lookup before
the review continued. See the [Braintrust
pattern](https://www.braintrust.dev/app/Paperclip/p/Paperclip%20Staging/patterns/27ff1ec9-4579-4ea1-ab6b-caae8d2a833d).

**Deployment mode**

Local Linux Runner with OpenCode 1.18.34. Staging recovery is not
tested.

**Expected behavior**

The provider discovers each assigned skill under its granted runtime
name.

**Steps to reproduce**

1. Assign a company skill whose source document has `name: review`.
2. Give it the runtime name `review--abc123`.
3. Copy it into the provider home through
`materializeNativeRuntimeSkills`.
4. Run OpenCode skill discovery in that home. Before this fix, it lists
`review`.

**Paperclip version or commit**

The baseline snapshot was inspected at
`43bdd773e901391e298415c5d039b2fc6a975bf7`. The current fix includes
master `89e65754189a3d73832562cbd28b90edf6ff52b8`.

Related-work search found no other repair for this name mismatch. PR
#14427 changes gateway hints and does not repair this skill projection.

## What Changed

- Align the top-level `name:` value in the disposable provider snapshot
before its existing read-only seal.
- Keep the admitted source, asset digest, runtime naming, collision
checks, and access controls unchanged.
- Support CRLF line endings, root mapping indentation, and complete
literal or folded name values.
- Cover unchanged source, bundled skill bytes, and documents without
frontmatter.

## Hypothesis and thesis for a fix

**Hypothesis:** Paperclip advertises the granted name, but OpenCode
indexes the original frontmatter name. The raw trace and actual local
OpenCode discovery confirm the mismatch.

**Thesis for a fix:** The shared native skill materializer owns the
provider copy. Align its name before sealing the copy. OpenCode, Codex,
and ACPX use this boundary. Legacy direct adapters use other paths and
are outside this change.

Saved source assets carry forward without migration. New provider copies
receive the aligned name. No saved session schema or authority contract
changes.

## Verification

- Added CRLF, literal, and folded regression cases. All three failed on
the earlier implementation; the LF case passed.
- `pnpm --filter @paperclipai/paperclip-runner exec vitest run
src/drivers/runtime-context-skill-name.test.ts
src/drivers/runtime-context-materializer.test.ts`: 24 tests pass.
- `pnpm --filter @paperclipai/paperclip-runner exec tsc -p tsconfig.json
--noEmit`: passes.
- Actual installed OpenCode `debug skill --pure`, with an isolated HOME
and XDG paths: without alignment it lists `review` and the granted-name
assertion fails. With this fix it lists `review--abc123`. The source
bytes stay unchanged.
- `git diff --check`: passes.
- ACPX and Copilot runtime-host suites: 84 tests pass. Total focused
checks: 108 tests pass.
- `pnpm verify` returned exit 2: the new test is outside the resolved
dependency graphs. Required CI supplies broad coverage.
- At `72b55119`, Greptile reached 5/5 with no unresolved threads.
Typecheck, build, Runner suites and E2E passed. General server shard
9/12 exposed an outdated remote-staging assertion; two other shards were
interrupted by runner shutdown.
- Updated remote-staging assertions for the granted nested name and
unchanged source. Reproduced the old assertion failure locally; all 35
remote-staging tests pass with standard umask 022. The default
restrictive mask caused a separate exact-mode assertion failure on the
initial local run.
- Current head `059e7b26`: aggregate CI verify, typecheck, build, all
server/Runner suites, E2E, Canary Dry Run, and Runner support pass.
Greptile is 5/5 with all threads resolved; Snyk succeeds. No pending or
failed checks. Superagent is neutral after a scan-workflow error, so no
security scan pass is claimed.

## Risks

The change affects native providers that share this materializer.
Existing symlink, overlap, unsafe-name, and read-only controls still
apply. The tests check those existing paths.

The local proof runs real provider discovery and checks the staged file.
It does not run a model or a staging agent task. Staging recovery
remains unverified. No merge or deployment is included.

## Model Used

OpenAI Codex, GPT-6, with tool use and code execution. Earlier work used
Codex; its exact model ID is not retained in the task evidence.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes:` / `Closes:`
/ `Refs:` OR (b) described the issue in-PR following the relevant issue
template
- [x] I have not referenced internal/instance-local Paperclip issues or
links
- [ ] My branch name describes the change and contains no internal
ticket id (the existing branch is retained for continuity)
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes (this
report describes the internal behavior)
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-12-05 04:14:46 -08:00
..