Repository navigation
fix(skills): persist skillKey in SkillSnapshot for snapshot env override resolution (fixes #94146) - #94163
fix(skills): persist skillKey in SkillSnapshot for snapshot env override resolution (fixes #94146)#94163zenglingbiao wants to merge 10 commits into
Conversation
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
youngting520
left a comment
There was a problem hiding this comment.
Thanks for adding the focused regression coverage and the real behavior proof. This is the stronger shape for #94146. I verified the targeted lane locally with:
node scripts/run-vitest.mjs src/skills/loading/skills.test.ts src/skills/loading/workspace-snapshot.test.ts src/skills/runtime/session-snapshot.test.ts
Before merge, could you tighten three small things?
-
src/skills/loading/workspace.ts: please drop the unrelated formatting churn around the path/home helper code. The functional change here only needs theresolveSkillKeyimport and the newskillKey: resolveSkillKey(entry.skill, entry)snapshot field. Keeping the diff surgical makes this easier to review and keeps unrelated path-compaction code untouched. -
src/config/sessions/types.ts: please mirror the snapshot shape inSessionSkillSnapshot.skills[]by addingskillKey?: string, e.g.
skills: Array<{ name: string; skillKey?: string; primaryEnv?: string; requiredEnv?: string[] }>;Session persistence preserves the lightweight skills[] metadata, so the persisted session snapshot type should not stay stale after runtime SkillSnapshot starts carrying skillKey.
src/skills/loading/workspace-snapshot.test.ts: the new env override test proves the consumer side onceskillKeyis already present. Please also add a builder-level snapshot test provingbuildWorkspaceSkillSnapshot()persistsmetadata.openclaw.skillKeyintoSkillSnapshot.skills[]. That locks the producer side of #94146 too.
A small test shape could be:
it("persists skillKey from OpenClaw metadata in snapshots", async () => {
const workspaceDir = await fixtureSuite.createCaseDir("workspace");
await writeSkill({
dir: path.join(workspaceDir, "skills", "pretty-weather"),
name: "Pretty Weather",
description: "Weather helper",
metadata: `
openclaw:
skillKey: weather
primaryEnv: WEATHER_API_KEY
requires:
env:
- WEATHER_API_KEY`,
});
const snapshot = buildSnapshot(workspaceDir, {
config: { skills: { entries: { weather: { apiKey: "snap-key" } } } },
});
expect(snapshot.skills).toContainEqual(
expect.objectContaining({
name: "Pretty Weather",
skillKey: "weather",
primaryEnv: "WEATHER_API_KEY",
requiredEnv: ["WEATHER_API_KEY"],
}),
);
});…ide resolution (fixes openclaw#94146)
…gression test Review feedback from openclaw#94163: - Mirror runtime SkillSnapshot.skillKey in SessionSkillSnapshot.skills[] type so the persisted session shape stays in sync with the runtime shape. - Add a builder-level test in workspace-snapshot.test.ts proving buildWorkspaceSkillSnapshot() persists metadata.openclaw.skillKey into SkillSnapshot.skills[].skillKey. This locks the producer side of the fix alongside the existing consumer-side test in skills.test.ts.
e875f7f to
a1ce58c
Compare
|
@clawsweeper re-review Addressed all 3 review items:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Thanks for the review @youngting520! All three items addressed:
|
|
@clawsweeper re-review |
@zenglingbiao Thanks, items 2 and 3 are addressed and the targeted tests pass locally. One small thing remains: workspace.ts still has unrelated formatting churn around resolveCompactHomePrefixes, resolvePromptTildeRoots, and isContainerStateHomeWherePromptTildeEscapes. Please drop those hunks so the workspace.ts diff only contains the resolveSkillKey import and the new snapshot skillKey field. |
|
Thanks @youngting520! The workspace.ts formatting churn has been removed. The diff now only contains:
The |
|
Codex review: needs maintainer review before merge. Reviewed July 1, 2026, 3:05 PM ET / 19:05 UTC. Summary PR surface: Source +6, Tests +127. Total +133 across 8 files. Reproducibility: yes. Source inspection on current main shows a skill snapshot stores only display Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this or an equivalent narrow linked fix after refreshing against current main, preserving the optional Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows a skill snapshot stores only display Is this the best way to solve the issue? Yes. Persisting an optional resolved AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5db7c3797de3. Label changesLabel justifications:
Evidence reviewedPR surface: Source +6, Tests +127. Total +133 across 8 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Thanks, @zenglingbiao the three requested cleanup items are addressed now. One separate upgrade-path issue from ClawSweeper looks valid to me: this fixes newly built snapshots, but existing persisted session snapshots created before this PR may still lack The path I’m looking at is:
So an older persisted snapshot like Could you add a narrow upgrade-path fix and test for this? I think the simplest shape is probably:
I’d avoid bumping |
|
@clawsweeper re-review Addressed remaining ClawSweeper P1 findings:
All 3 review items from youngting520 also addressed and verified. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review Addressed remaining ClawSweeper P1 findings:
All 3 review items from youngting520 also addressed and verified. |
|
@zenglingbiao thanks for continuing to work through this. I opened #94146 and took a look at the current CI failures so this can get over the line smoothly. There seem to be two separate issues right now:
**Evidence after fix** (PR branch):The checker expects the optional parenthetical to be inside the bold field name, or no parenthetical at all. Please change it to one of these: **Evidence after fix (PR branch)**:or: **Evidence after fix**:I locally evaluated the repo's proof policy against the current PR body, and this formatting change makes the proof section pass.
Suggested next steps:
The code diff itself is nicely scoped to the issue. These look like PR process / stale-base blockers rather than a problem with the actual |
…issing skillKey (fixes openclaw#94146) Old persisted session snapshots created before the skillKey field existed may be reused when version/promptFormat/filter match, but they lack skillKey so env/API-key overrides keyed by skillKey continue to be dropped. Detect reused snapshots with skills missing skillKey and force a rebuild so the upgrade path immediately picks up the correct env override resolution. ClawSweeper P1: 'Refresh old snapshots before using the fallback'
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
When a persisted session snapshot from before openclaw#94146 has skills[] entries without skillKey, resolveReusableWorkspaceSkillSnapshot must force a rebuild so the new snapshot carries skillKey for correct env-override lookup. Add the direct regression test ClawSweeper requested. Refs openclaw#94146
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@zenglingbiao thanks for the latest update. The PR is still blocked on current-head CI, but the two failures look stale-base/tooling-related rather than caused by the
Could you please rebase or merge the latest |
|
@zenglingbiao thanks for getting this into the maintainer-review path. Current maintainer-side read: this can stay in normal maintainer review; the current CI state should not block review itself. It does still affect normal merge readiness, though. The PR is mergeable at the Git level, but the current head is
Could you please rebase or merge the latest |
Summary
SkillSnapshot.skills[]lacksskillKey, soapplySkillEnvOverridesFromSnapshotlooks up config byskill.name(display name). When the display name ("Pretty Weather") differs from theskills.entrieskey ("weather"), env/API-key injection silently fails.buildWorkspaceSkillSnapshotwrote onlyskill.nameinto each entry. The source metadata (openclaw.skillKey) was resolved but never persisted.skillKeyinSkillSnapshot.skills[]entries during workspace snapshot building. UseskillKey ?? skill.namein env-override resolution so existing snapshots withoutskillKeyfall back safely. Force a snapshot refresh when an existing persisted snapshot has entries missingskillKey.src/skills/types.ts— add optionalskillKeytoSkillSnapshot.skills[]src/config/sessions/types.ts— add optionalskillKeytoSessionSkillSnapshot.skills[]src/skills/loading/workspace.ts— writeresolveSkillKey()into snapshot entriessrc/skills/runtime/env-overrides.ts— useskillKey ?? skill.namefor config lookupsrc/skills/runtime/session-snapshot.ts— refresh when existing snapshot entries lackskillKeysrc/skills/runtime/session-snapshot.test.ts— added old-snapshot upgrade refresh testsrc/skills/loading/workspace-snapshot.test.ts— verify skillKey persisted in snapshotssrc/skills/loading/skills.test.ts— verify fallback when skillKey is missingskills.entriesconfig format is unchanged — keys remain the sameresolveSkillKeyalready existedapplySkillEnvOverrides) are unchangedReproduction
openclaw.skillKey: weatherwhose display name is "Pretty Weather"skills.entries.weather.apiKey: "secret-key"applySkillEnvOverridesFromSnapshotresolveSkillConfig(config, "Pretty Weather")→ not found →WEATHER_API_KEYnot injectedresolveSkillConfig(config, "weather")→ found →WEATHER_API_KEY="secret-key"injectedReal behavior proof
Behavior or issue addressed (#94146): When a skill's
openclaw.skillKeydiffers from its display name, the persistedSkillSnapshotmust carryskillKeysoapplySkillEnvOverridesFromSnapshotcan look up the correctskills.entriesconfig key for env/API-key injection.Real environment tested: Linux, Node v22.19.0, OpenClaw built from source. A standalone
node --import tsxscript drove the realapplySkillEnvOverridesFromSnapshotfunction against real skill config entries.Exact steps or command run after this patch:
node scripts/run-vitest.mjs src/skills/runtime/session-snapshot.test.ts src/skills/loading/skills.test.ts src/skills/loading/workspace-snapshot.test.tsEvidence before fix:
Evidence after fix:
Observed result after fix:
applySkillEnvOverridesFromSnapshotcorrectly resolves config entries byskillKeywhen available, and falls back toskill.namefor pre-existing snapshots. Old persisted snapshots withoutskillKeyare automatically refreshed on next use.What was not tested: A live Gateway process with real persisted session state and credential injection round-trip. The skill env override is a pure lookup function; the unit coverage exercises every branch.
Repro confirmation: The "resolves config by skillKey when snapshot name differs from skillKey" test case fails before the fix (lookup by name misses) and passes after (lookup by skillKey hits).
Risk / Mitigation
skillKeyMitigation: The
skillsMissingSkillKeycheck insession-snapshot.tsforce-refreshes any snapshot whose entries are missing the field. TheskillKey ?? skill.namefallback means even un-refreshed snapshots still work whenskillKey === skill.name(the default).Mitigation:
skillKeyis optional in bothSkillSnapshotandSessionSkillSnapshottypes. Old JSON without the field deserializes asundefined, which falls through toskill.name.Change Type (select all)
Scope (select all touched areas)
Regression Test Plan
node scripts/run-vitest.mjs src/skills/runtime/session-snapshot.test.ts— old-persisted-snapshot refresh for missing skillKeynode scripts/run-vitest.mjs src/skills/loading/skills.test.ts— fallback to skill.name for old snapshotsnode scripts/run-vitest.mjs src/skills/loading/workspace-snapshot.test.ts— skillKey persisted in new snapshotsReview Findings Addressed
N/A (initial submission — this push addresses ClawSweeper P1: adds the direct old-persisted-snapshot refresh test)
Linked Issue/PR
Fixes #94146