Skip to content

feat(m8): Agent 资产 base+overlay 分层与用户级覆盖 (#493) - #494

Merged
Shadow-Azure merged 2 commits into
mainfrom
agent/asset-layering-a3721288161b
Dec 5, 2026
Merged

Shadow-Azure merged 2 commits into
mainfrom
agent/asset-layering-a3721288161b

Conversation

@ZTGolem

@ZTGolem ZTGolem commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

This is by an automated agent, not a human.

What

Issue #493 changes asset_override from a whole-source replacement to a base + overlay asset model:

  • The template source is always resolved as the base layer; asset_override is the overlay.
  • Both layers are resolved and validated independently, then merged by the control plane into one immutable effective snapshot.
  • Merge identity follows the issue: skills by directory name, commands by runtime path, subagents by frontmatter name. Overlay wins on the same identity; a duplicate identity inside one layer returns asset_layer_merge_conflict.
  • The effective bundle is the only input the runner materializes, under the user-level CLAUDE_CONFIG_DIR (/testbed/.runtime-home/.claude). The project .claude is removed so Claude Code's opposite skill/subagent scope precedence never decides a conflict.
  • Snapshot manifests, the 202/progress response, and status/results now carry source_id, repo_url, and layers (base/overlay source, commit, validation, and per-asset provenance); older snapshots are exposed as base-only.
  • Resolve-time source validation is now cached and single-flight per (source_id, commit, install/init, validation_version) in the API process, so different asset_paths over the same commit do not repeat install/init.

The runner also moves a source-mode build's generated .claude tree into the user-level config dir, so artifact-only and source-mode paths converge on one effective tree.

Review

A structured review is recorded in plans/2026-12-05-pr494-review.md. It found and this branch fixes the candidate-identity bug in the effective snapshot, the merge digest/unique-race edge, zero-asset project .claude removal, the validation-cache bounds/ref echo, layer error attribution, consistent layer echoes, per-key runtime setup merge, source-mode move failure handling, and unsafe-path handling. Two low-severity follow-ups remain: the per-key validation lock map is not pruned, and a rare unique-constraint merge race can leave an orphan bundle object (same pattern as the existing resolve path). Neither affects the requested result.

Scope and limitations

This PR is the P3 slice that #493 describes as an independent PR. It does not add the separate validation worker/queue (P2), and it does not change the asset_paths default inheritance rules beyond the overlay semantics above. Source-mode layers still run their install/init on the API host during resolve; a source-build install that expects /asset-source at evaluation time still needs the P2 validation worker. The validation cache is process-local; the durable snapshot request cache remains the cross-process reuse mechanism.

No UI files changed, so there is no Before/After visual comparison for this PR. The API read-model change is additive: asset gains source_id, repo_url, and layers, while resolved_commit/asset_snapshot_id/requested_ref keep their previous meaning.

Verification

  • CI on head a2e9a34: all checks pass — backend (PostgreSQL pytest + migration dry-run), docs, flow-offline, flow-online (including the required Project link), runner, web and deployment contract.
  • pytest tests/backend (SQLite, full suite) — passed.
  • node --test tests/**/*.test.mjs / npm test — 130 passed.
  • npm run lint:docs and npm run verify:docs — passed (docs and i18n pairing updated).
  • npm run verify:flow and the PR diff flow gate — passed.
  • New coverage: cross-layer skill/agent/command override, within-layer identity conflict, provenance/manifest, merge cache reuse, base-only compatibility, validation cache across different asset_paths, and runner user-level materialization + project .claude removal.

Part of #493.

This pull request was produced by dsh-superagent under the ZTGolem account.

模板资产作为 base 层,asset_override 作为 overlay 层分别解析与校验,
控制面按 Skill 目录名、Subagent frontmatter name、Command 运行时路径
合并为 effective 快照;overlay 同名覆盖,层内冲突返回
asset_layer_merge_conflict。

Runner 只物化 effective bundle 到 CLAUDE_CONFIG_DIR
(/testbed/.runtime-home/.claude) 并移除项目 .claude,source-mode 的
生成树也迁移到用户级目录。快照 manifest、202/进度、status/results 记录
base/overlay source、commit、validation 与逐资产 provenance;旧快照按
base-only 兼容。

按 (source, commit, install/init, validation_version) 复用 resolve
校验结果,单进程单飞,不因 asset_paths 不同重复 install/init。
@ZTGolem ZTGolem added this to the 问题修复 milestone Dec 5, 2026
两轮独立检视发现并修复:
- effective 快照自身 identity 改取 overlay commit/source,base 只留在
  asset_layers.base,避免 run 摘要/对比/自进化把候选标成 base。
- 合并 selection digest 纳入两层 source/commands,唯一冲突回退校验层身份。
- 无资产源时也移除项目 .claude;.runtime-home 先删后建防软链。
- 校验缓存加上限并在命中时覆盖当前 ref;base 错误标 asset_layer=base;
  asset_snapshot_json 统一合成 layers;runtime setup 按 key 合并;
  source-mode 搬迁检查源目录并返回明确错误;非法路径不再静默跳过。
- 补对应回归断言与检视记录。
@Shadow-Azure
Shadow-Azure merged commit 032af22 into main Dec 5, 2026
8 checks passed
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.

2 participants