feat(pi): materialize effective plugin worker tools

This commit is contained in:
2026-08-27 17:24:16 +08:00
parent c4dd8923a0
commit fd891ff3bb
12 changed files with 617 additions and 212 deletions

View File

@@ -0,0 +1,120 @@
# Task: Implement ML-03 Pi worker resource materialization
## Identity
- Task ID: 20260827-plugin-ml03-worker-materialization-9b2e6c41
- Mode: Feature
- Branch: codex/20260827-plugin-ml03-worker-materialization-9b2e6c41-plugin-ml03-worker-materialization
- Worktree: D:\Datas\OthersProjects\makelore-plugin-ml03-worker-materialization-9b2e6c41
- Base commit: c4dd8923a0076920e8a7fd8820fdc01bdfde1760
- Owner: plugin_ml03_worker_materialization
- Status: Ready for integration
## Scope
- Implement ML-03 dynamic Pi worker resource materialization from exact coordinator
frontier `c4dd8923a0076920e8a7fd8820fdc01bdfde1760`.
- Own only the Pi resource loader, extension host, runtime, worker process,
subagent child, `makelore-runtime` extension, the five named Pi-focused tests,
and this task record.
- Resolve one worker-resource snapshot before Skill materialization and extension
registration; carry effective Skills, frozen catalog revision, tool declarations,
allowed names, bridge allowlist, write-lease membership, and explicit CLI tools.
- Preserve core tools/Skills, keep child plugin catalog empty, remove the obsolete
static Data Service CLI allowlist, and prove disabled/re-enabled/old-worker and
child-denial behavior.
## Intent And Constraints
- Follow implementation spec sections 7.2-7.3 and 10.2, ticket ML-03, and detailed
design sections 8.5-8.7. The server catalog and ML-02 registry/envelope are the
authoritative upstream contracts; do not duplicate or alter them.
- Parent plugin exposure is the intersection of valid package, project selection,
selected Skill grant, permitted role, and verified policy. Known-disabled Skill
assignments remain in config/UI but do not enter the effective snapshot; truly
unknown assignments retain existing invalid-configuration behavior.
- A worker run freezes its catalog. Main-side invocation remains authoritative and
rechecks current selection; declarations are never authority. Child workers get
no plugin Skills/tools and no permission broadening.
- No Host, Renderer, preview, adapter, registry, P1 billing, generic endpoint,
arbitrary code/MCP/hooks, or static Data Service list changes. If an upstream
interface is semantically insufficient, stop and report to the coordinator.
- Test-first. Use the exact pinned pnpm version. Keep the worktree isolated and
clean; return one implementation commit with sole parent the exact base.
## Project Context Loaded
- Task ID/mode/branch/worktree/base match the Git-common owner record exactly.
- Concurrent Task Gate passed: `check_project_docs.py` succeeded and
`task_context.py start`/`status --json` show this task owns the isolated worktree.
- Planning Gate passed on 2026-08-27 after reading the required entry documents,
current integrated snapshot, accepted Pi runtime decision, relevant architecture,
domain/evidence/reflection/commitment/stale indexes, and peer task records.
- Other active local tasks include the client coordinator and historical/unrelated
planning tasks; the coordinator owns only its integration record/branch and no
ML-03 implementation files. No unresolved semantic conflict or ownership overlap
affects this ticket. The integrated memory predates the plugin work; the frozen
implementation spec, ticket graph, and exact ML-02 frontier control this task.
## Plan
1. Inspect the exact ML-02 frontier's Pi seams and existing tests without changing
files; map current resource/extension/worker/child contracts to the frozen ML-03
requirements.
2. Add failing focused tests for one-snapshot effective resource resolution,
declaration/bridge/CLI agreement, disabled and re-enabled assignments, old
worker refusal, child denial, and unchanged core behavior.
3. Implement the smallest cohesive changes within the owned files, preserving the
existing Pi 0.84.2 product contracts and project write-lease semantics.
4. Run owned focused tests plus relevant Pi regressions, typecheck, scoped/full
lint as appropriate, and diff/doc gates; investigate and fix only failures in
owned scope.
5. Update this record with exact outcome/evidence/follow-ups, run task-aware doc
drift, and complete task_context to `ready_for_integration` on a clean one-commit
worktree.
## Outcome
- Implemented the ML-03 effective worker snapshot flow. Parent and child openers
resolve the capability registry once before materialization/registration and
pass the resulting effective Skill entries, catalog revision, and plugin tool
definitions through resource-loader and extension-host. Plugin Skill paths now
resolve from the fixed bundled package roots; disabled assignments therefore do
not reach the worker while the assigned configuration remains untouched.
- Pi extension contexts carry the frozen revision, effective Skill IDs, exact
declarations, dynamic bridge names, and `projectWriteLease` names. The bundle
registers only the declarations in that context and applies leases from the
declaration metadata. Child registrations force empty plugin tool exposure.
- Pi CLI defaults contain only the fixed core profile. Parent runtime workers
explicitly pass the fixed core profile plus the registration's plugin names;
the static Data Service CLI list was removed. Bridge requests accept bounded
string tool names but reject names outside the worker's frozen plugin set,
while retaining the fixed core product bridge tools.
- Owned tests cover plugin Skill resource roots, catalog metadata, dynamic
declaration/schema materialization, bridge denial for an unregistered tool,
dynamic lease metadata, core-only defaults, real Pi declaration/CLI agreement,
and enabled-to-disabled-to-re-enabled worker materialization without rewriting
the retained Agent assignment.
## Verification
- Owned focused (maxWorkers=1):
`tests/unit/pi-resource-loader.test.ts`, `pi-extension-host.test.ts`,
`pi-extension-bundle.test.ts`, `pi-worker-process-real.test.ts`, and
`pi-rpc-foundation.test.ts`: 43 passed, 2 skipped (staged-runtime gated).
- All `tests/unit/pi-*.test.ts` regressions with one worker: 30 files passed,
169 passed, 2 skipped.
- `pnpm typecheck`: passed.
- `pnpm lint:check`: passed with five pre-existing warnings in
`src/pages/Home/index.tsx` and `src/pages/Makelore/index.tsx`; no errors.
- `git diff --check`: passed.
## Follow-ups
- Coordinator ML-04 must wire the already-optional capability registry into
the production composition and keep its own Host/Renderer ownership; this
task intentionally did not edit composition or product-tools files.
## Promotion Candidates
- None.