Skip to content

docs(plan): live skill access for app-user sessions (Option A β€” review only) - #72

Open
cryptolir wants to merge 2 commits into
mainfrom
docs/app-user-skill-access
Open

cryptolir wants to merge 2 commits into
mainfrom
docs/app-user-skill-access

Conversation

@cryptolir

Copy link
Copy Markdown
Owner

Plan doc for codex review β€” not for merge. Design + security review of giving Havaya app-user sessions access to the live dashboard skills.

Problem

App-user chats on life run sandboxed (tools.fs.workspaceOnly: true). They already see the live dashboard skills in their system prompt, but the per-user file jail blocks them from read-ing the SKILL.md to apply them β€” which is exactly why the Drive summary method had to be hard-embedded ("Live skill vs embedded copy").

Proposal (Option A)

A narrow, read-only load_skill({ name }) gateway tool: resolves a skill name to its SKILL.md content server-side (from the shared home, which gateway code can read even though the model's file tools are jailed), realpath-confined under <home>/skills/. The per-user jail is untouched; skills arrive through an additive, name-validated, read-only channel. The app-session skills prompt is rewritten to "call load_skill(name)" and drops the absolute host path.

Options B (mirror skills into the jail) and C (read-only skills exception in the core workspaceOnly jail) are compared in Β§4 β€” A chosen for the smallest isolation blast radius.

What I'd like reviewed

  • The Β§6 security model (name-only input, realpath confinement, jail untouched).
  • The Β§9 open questions: tool scope (app-only vs all sessions), the cleanest prompt branch point given the cached skillsSnapshot, name matching, whether v1 should serve a skill's sibling files, the content byte cap, and the regression surface for normal sessions.

Doc: docs/experiments/plans/app-user-skill-access.md. pnpm check:docs green.

πŸ€– Generated with Claude Code

…-only)

Plan doc for giving Havaya app-user sessions read-only access to the live
dashboard skills via a name-scoped `load_skill` gateway tool, without
weakening the per-user file jail. Review-only (not for merge) β€” codex design
+ security review requested. Options A/B/C compared; A chosen for the
smallest isolation blast radius.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

@cryptolir cryptolir left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plan review feedback for PR #72:

  1. [P1] Realpath confinement under <home>/skills/ conflicts with the actual merged skill roots.
    The plan says load_skill should match loadWorkspaceSkillEntries() but then realpath-confine SKILL.md under <skillsHome>/skills/. Current loadWorkspaceSkillEntries() merges extra, bundled, managed, personal agents-skills, project agents-skills, and workspace skills, with workspace highest precedence. So a skill visible in the prompt may legitimately resolve outside <workspace>/skills/ unless it has been dashboard-synced there. Either constrain the app prompt/tool to workspace-synced skills only, or realpath-confine against the matched entry's trusted source root, not only <home>/skills/.

  2. [P1] load_skill must use the same filtered/prompt-visible skill set, not raw entries.
    The plan's resolution step uses loadWorkspaceSkillEntries(skillsHome) and matches by name. That raw list includes skills that may later be filtered out by shouldIncludeSkill, skillFilter, eligibility, or disableModelInvocation. If load_skill can load names outside the app-visible prompt, it becomes a side channel to hidden/non-invocable skills. Build the tool's allowlist from the same promptEntries/snapshot used to render the app prompt.

  3. [P2] App-only registration needs to handle _no-app-user sessions explicitly.
    The doc says register only when isAppUserSession(sessionKey). But isAppUserSession can be true while resolveAppUserId fails, and those sessions are intentionally jailed into _no-app-user. If load_skill is registered there, a malformed app session with no resolved user still gets shared skill access. That may be acceptable, but it should be a conscious choice. I would gate on resolved app user id, not just :app:.

  4. [P2] Sibling filenames can leak more than needed.
    Returning sibling filenames is lower risk than contents, but it can still reveal implementation detail or accidental files in the skill dir. For v1 I would omit files entirely unless a real target skill needs it, or list only allowlisted doc-like files after filtering dotfiles/temp files.

Answers to the open questions:

  • Tool scope: app sessions with resolved appUserId only.
  • Prompt branch point: pass an app-skill-loading mode into the same skills prompt builder/snapshot path, so the visible prompt list and load_skill allowlist cannot drift.
  • Name matching: trim input, exact canonical match after that. Avoid case-insensitive unless collisions are explicitly rejected/handled.
  • Sibling files: not in v1. Add file only once a skill demonstrably needs it.
  • Content cap: 24 KB is reasonable; truncate with truncated: true, but include a clear instruction that truncated skills may be incomplete.
  • Carve-out: remove the dead host carve-out, and commit life-access-scope source to git before more host-only edits accumulate.
  • Regression surface: normal sessions should be untouched; add a byte-for-byte prompt snapshot test for normal sessions.

…v 2)

Address the four findings + open-question answers on PR #72:
- [P1] confine each load against the matched entry's own trusted root (baseDir),
  not a hardcoded <home>/skills/, so multi-root (bundled/managed) skills resolve.
- [P1] tool allowlist = the same filtered, prompt-visible snapshot, not raw
  loadWorkspaceSkillEntries (no hidden-skill side channel).
- [P2] gate on a resolved app user via the #71 resolveAppUserId ??
  appUserIdFromSessionKey fallback (turn-1-safe); exclude _no-app-user.
- [P2] drop the sibling files list from v1.
Plus: trim+exact name match, 24KB cap with truncated flag, remove the dead
life-access-scope carve-out and commit that hook to git, normal-session prompt
snapshot regression test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@cryptolir

Copy link
Copy Markdown
Owner Author

Thanks β€” all four findings folded into Rev 2 (e15f2d387); no blockers, the design got tighter.

[P1] Multi-root confinement β€” fixed. load_skill now confines each load against the matched entry's own trusted root (skill.baseDir), not a hardcoded <home>/skills/, so a legitimately prompt-visible bundled/managed/personal skill resolves correctly while traversal/symlink-escape stays denied. (Β§5.1 step 3.)

[P1] No hidden-skill side channel β€” fixed. The tool's allowlist is now the same filtered, prompt-visible snapshot that renders the app prompt (via the shared builder/snapshot path), never raw loadWorkspaceSkillEntries. You can only load what you can see; filtered / disableModelInvocation / ineligible skills are unreachable. (Β§5.1 step 1 + Β§5.3.)

[P2] _no-app-user gating β€” adopted, and it ties into the just-shipped #71: gating on the session-entry resolveAppUserId alone would make skills unavailable on a new session's first turn (the exact bug #71 fixed for app_profile). So the tool gates on resolveAppUserId(sessionKey) ?? appUserIdFromSessionKey(sessionKey) β€” resolved app users get it on turn 1; _no-app-user sessions are excluded. Noted that skills are non-private, so this is a deliberate consistency/defence-in-depth choice. (Β§5.2.)

[P2] Sibling files β€” dropped files from v1; a guarded file param is deferred until a skill demonstrably needs helper contents. (Β§5.1 step 5.)

Open-question answers β€” all taken as you suggested: trim + exact match against the de-duplicated snapshot (no case-insensitive); 24 KB cap with truncated: true + a "may be incomplete" hint; remove the dead isWorkspaceSkillRead and commit life-access-scope to git before more host-only edits accumulate; add a byte-for-byte normal-session prompt snapshot regression test. (Β§9 collects these.)

pnpm check:docs green.

cryptolir added a commit that referenced this pull request Jun 18, 2026
…) (#74)

* feat(skills): load_skill tool for app-user sessions (live skills, jailed)

App-user sessions run jailed (tools.fs.workspaceOnly) and cannot read the shared
SKILL.md by path, so the live dashboard skills listed in their prompt were
unusable (the reason the Havaya Drive method was hard-embedded). Add a read-only,
name-scoped load_skill tool that resolves a skill NAME β€” from the same filtered,
prompt-visible set the model is shown β€” to its SKILL.md content, read server-side.
The per-user file jail is untouched.

Implements docs/experiments/plans/app-user-skill-access.md (Option A) with the
codex 4517821566 refinements:
- allowlist = the snapshot's resolvedSkills (filtered/prompt-visible), so it is
  never a side channel to disableModelInvocation/ineligible skills (#2);
- confinement against the matched entry's own baseDir, not a hardcoded path, so
  multi-root (bundled/managed/workspace) skills resolve; symlink-escape rejected (#1);
- gated on a resolved app user via resolveAppUserId ?? appUserIdFromSessionKey
  (turn-1-safe, excludes _no-app-user) (#3);
- 24KB cap + truncated flag; no sibling files in v1 (#4).
The app skills prompt lists name+description only (no <location>, no host-path
leak) and instructs the model to call load_skill; normal sessions unchanged.

Files: new src/agents/tools/load-skill.ts; buildAppSkillsPrompt in
skills/workspace.ts; buildSkillsSection app branch (system-prompt.ts) threaded via
buildEmbeddedSystemPrompt; appSkills wired through pi-tools -> openclaw-tools;
attempt.ts resolves the app user, builds the single skills source, and branches.

Gate: vitest load-skill 11 + system-prompt.skills 6 + save-user-section 13
(unchanged); tsgo clean on touched files; oxlint --type-aware 0/0; oxfmt.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(skills): address codex 4519976882 β€” tool-filter, compaction, limits

Three P2 fixes to the load_skill app-session path:
- [#1] derive appSkillLoad from the FINAL tool list (tools.some(load_skill)) rather
  than just appUserId, and suppress the app skills section when load_skill was
  filtered out by tool policy β€” so the model is never told to call a tool it does
  not have. The skills prompt is now built after tool creation in both attempt.ts
  and compact.ts.
- [#2] mirror the whole app-session skill branch in compact.ts, so app-user
  COMPACTION also gets the path-free app prompt + load-by-name (no <location> leak,
  no loss of the load_skill behavior).
- [#3] new limitAppSkills() applies the same maxSkillsInPrompt/char caps as the
  normal prompt; both the app prompt and the load_skill allowlist are built from it,
  so an app session can neither see nor load more skills than a normal prompt shows.

Gate: vitest load-skill 11 + system-prompt.skills 8 (+2 limitAppSkills) +
overflow-compaction; tsgo clean on touched files; oxlint --type-aware 0/0; oxfmt.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* docs(skills): clarify the load_skill allowlist is the prompt-limited subset

Codex recheck 4520156223 non-blocking nit: comments in load-skill.ts and the
appSkills option docs (openclaw-tools.ts, pi-tools.ts) described the allowlist as
the snapshot's resolvedSkills; after the limit fix it is the prompt-limited subset
(via limitAppSkills). Comment-only; keeps the security invariant easy to audit.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Liran Peretz <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>

This branch has not been deployed

No deployments
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.

1 participant