10 Commits
Author SHA1 Message Date
gitea-actions 912dd8ab23 Release v0.4.3 [skip release] [skip actions] 2026-11-09 08:39:45 +00:00
NotExpectedYet 387f7c3510 fix: override the shipped standard preset in the compaction overlay
Release / release (push) Successful in 9s
`presets/standard-compaction.patch.yml` inserted a second `preset-standard`
declaration. It happened to take effect because it applied last, but which of
the two declarations mounted was decided by the loader's duplicate-id handling,
and the composed tree carried two rows with the same id.

The file now overrides the shipped row by id, so the intent is explicit and only
one declaration exists. `test/presets.test.js` composes the shipped declaration
and the overlay through the harness's own patch engine and asserts one row, no
skipped patch, and the compaction budget applied — which the old insert form no
longer satisfies.
2026-11-09 08:30:11 +00:00
NotExpectedYet 40574505f2 fix: judge the working directory and the arguments a tool declares
The guard resolved relative paths against the session directory the conversation
started in, but the file tools resolve them against the session's *current*
working directory — which `working_directory` can change with no guard opinion.
In a `deny` facet, `cd /etc` followed by `read` of a relative path read from
/etc. The same mismatch made a shadowed tool invisible: this deployment installs
`dsh-better-edit`, which replaces `read` (argument `path`) and `edit` (argument
`file`), so a table written against the built-in `file_path` left the busiest
read tool unguarded — an outside file could be read with `deny` in force.

Now:

- `working_directory` is in the path table, so a `cd` outside the facet is
  refused (or put to the user, by mode) like any other out-of-facet path;
- a relative argument is judged against the directory the tool will actually
  use, read lazily from `ctx.workingDirectory`, and the implicit-search rule
  judges that same directory;
- path parameter names come from the tool's own declaration when the registry
  can supply one, so a shadowed tool is judged by the arguments it really takes;
- a delegated session started with a `subagent` `cwd` outside the parent's facet
  is clamped to the parent root instead of being scoped to the outside directory.

`undo_last_edit` (write-like) and the delegation tools join the table. Verified
against a profile with dsh-better-edit: in `deny` mode the outside `read`,
`edit`, `cd /etc` and `subagent cwd /etc` are all refused, while an inside read
still works — and the relative-read bypass from the same profile now stays
inside.
2026-11-09 08:30:07 +00:00
gitea-actions c48e9cabd9 Release v0.4.2 [skip release] [skip actions] 2026-11-06 07:22:02 +00:00
NotExpectedYet 4152c72730 docs: install the latest release, not the 0.1 line
Release / release (push) Successful in 9s
The install command pinned `#semver:^0.1.0`, and for a `0.x` package a caret
range stops before the next minor: `^0.1.0` can never resolve the `0.4.x` line,
so the documented command installs v0.1.4 rather than the current release.
`>=0.1.0` follows the tags the release workflow publishes, which is what the
paragraph promises, and the note now says why the range is not a caret.
2026-11-06 07:21:03 +00:00
NotExpectedYet 1697c24c3c test: fail when a preset drifts from the harness standard
The two files under `presets/` are frozen copies of the harness's `standard`
composition, and nothing noticed when the harness moved on — a missing row only
surfaced as a broken preset in a session, after the copy had already shipped.

`test/presets.test.js` now loads the installed harness's `standard` patch,
removes the deltas this bundle documents, and requires the remaining rows to
match exactly; it also resolves every plugin and subpath a preset names against
the harness scope, so a removed export fails the suite instead of a session.
Both checks skip when a checkout has no harness.

The scope search and the `js-yaml` link the comparison needs live in
`scripts/harness-scope.mjs` and `dev-links.mjs`; the search tries every
candidate scope because the legacy `profiles/node_modules` mirror is only a
snapshot of the installation.
2026-11-06 07:20:35 +00:00
NotExpectedYet 616cad75ce fix: rebuild both shipped presets from the harness standard
On dsh 0.2.2-rc.1 the harness folded `list_agents` into
`@deepseek-ai/dsh-tool-subagent-control` and stopped exporting its
`./list-agents` subpath. Both files under `presets/` are frozen copies of the
shipped `standard` composition, and the copy still named that row. A preset
declaration mounts every row it lists, so the row that could never start broke
the whole declaration: `facet` appeared on the roster with a `broken`
diagnostic and no session could compose it, which is why facet sessions stopped
resuming.

Both files are re-copied from the current `standard` patch and the three
documented changes are re-applied — the guard, the compaction budget, and the
persona's model-only prefix. The drift that came with the stale copy is fixed
with them: `time-context`, `tool-schedule` and `tool-plugin-market` are back,
`tool-subagent` uses the keys the harness reads (`modelSelection`,
`modelDiscovery`) instead of the retired `modelSelectionSettings`/`backgroundMode`,
`tool-fs` keeps `applyPatch: false`, and the plugin-manager row uses the shipped
`profileContext` condition.

The README now names this failure mode and why one dead row is fatal.
2026-11-06 07:20:32 +00:00
gitea-actions 7e75bcf79e Release v0.4.1 [skip release] [skip actions] 2026-10-19 08:58:21 +00:00
NotExpectedYet 9065a5c9d6 Merge branch 'master' of https://git.notexpectedyet.com/Not-Expected-Yet/dsh-facet
Release / release (push) Successful in 8s
2026-10-19 09:58:06 +01:00
NotExpectedYet 4bc4296494 fix: stop the facet preset naming a prompt variable the harness dropped
The preset's persona row copied the deployment's suffix, "Your working directory
is {{cwd}}". The harness substitutes only registered prompt variables and throws
on an unregistered one during prompt assembly — so when a harness release stopped
registering `cwd` (only `provider` and `model` remain), every session on this
preset failed its first turn with

  unknown prompt variable "{{cwd}}" in section "deployment:persona-suffix"

and chat was dead rather than degraded. The row now carries the prefix only.

The folder is stated where it can follow the session instead: the facet binding
already names the facet, and now names the session folder as well when the two
differ — which is every conversation that started higher up and was narrowed, and
exactly the case where relative tool paths need saying out loud.

`test/presets.test.js` makes this class of failure impossible to reintroduce
silently: it scans every shipped preset for a variable reference and requires the
name to be one the harness registers, and holds this bundle's own rule and
binding text to no references at all. Restoring the old suffix fails it.
2026-10-19 09:56:26 +01:00
14 changed files with 782 additions and 125 deletions

No files matched your search

+30
View File
@@ -2,6 +2,36 @@
Every release, newest first, generated from the commits in each release. Every release, newest first, generated from the commits in each release.
## v0.4.3 — 2026-11-09
### Fixed
- override the shipped standard preset in the compaction overlay
- judge the working directory and the arguments a tool declares
## v0.4.2 — 2026-11-06
### Fixed
- rebuild both shipped presets from the harness standard
### Documented
- install the latest release, not the 0.1 line
### Other
- fail when a preset drifts from the harness standard
## v0.4.1 — 2026-10-19
### Fixed
- stop the facet preset naming a prompt variable the harness dropped
## v0.4.0 — 2026-09-28 ## v0.4.0 — 2026-09-28
### Added ### Added
+87 -14
View File
@@ -74,7 +74,7 @@ because otherwise there would be no way to grant anything at all.
From the repository, following releases: From the repository, following releases:
```sh ```sh
dsh plugin --profile web add "git+https://git.notexpectedyet.com/Not-Expected-Yet/dsh-facet.git#semver:^0.1.0" dsh plugin --profile web add "git+https://git.notexpectedyet.com/Not-Expected-Yet/dsh-facet.git#semver:>=0.1.0"
dsh --profile web --dump-config | grep preset-facet # expect the row dsh --profile web --dump-config | grep preset-facet # expect the row
``` ```
@@ -84,13 +84,16 @@ Or from a checkout, while working on the plugin itself:
dsh plugin --profile web add "/path/to/dsh-facet" dsh plugin --profile web add "/path/to/dsh-facet"
``` ```
The `#semver:^0.1.0` fragment is the difference between an install that can be The `#semver:>=0.1.0` fragment is the difference between an install that can be
updated and one that cannot. Leave it off and pnpm resolves the default branch to updated and one that cannot. Leave it off and pnpm resolves the default branch to
a **commit** and records that commit in `pnpm-lock.yaml` — `dsh plugin update` a **commit** and records that commit in `pnpm-lock.yaml` — `dsh plugin update`
then has no version to move to, because there is nothing to move between. With then has no version to move to, because there is nothing to move between. With
the fragment, pnpm resolves against the repository's tags, which the release the fragment, pnpm resolves against the repository's tags, which the release
workflow creates on every push to `master`. The fragment needs a tag to resolve workflow creates on every push to `master`. The range is written `>=` rather
against, so it only works once the first release has been published. than `^` because this package is still `0.x`: a caret range stops before the next
minor, so `^0.1.0` can never reach the `0.4.x` line and would silently install an
old release. The fragment needs a tag to resolve against, so it only works once
the first release has been published.
Either way the command is `pnpm add` run inside the profile, and it registers the Either way the command is `pnpm add` run inside the profile, and it registers the
bundle in `dsh.profile.bundles` for you. A git-hosted plugin that builds on bundle in `dsh.profile.bundles` for you. A git-hosted plugin that builds on
@@ -231,12 +234,67 @@ its default is not 8192 but `headroomTokens`, 65536.
If you want that budget on *every* session rather than only scoped ones, If you want that budget on *every* session rather than only scoped ones,
`presets/standard-compaction.patch.yml` is an opt-in overlay that applies the `presets/standard-compaction.patch.yml` is an opt-in overlay that applies the
same row to the shipped `standard` preset. It is not in the bundle's default same row to the shipped `standard` preset. It overrides that row by id rather
than declaring a second one — with two declarations the mounted one would be
decided by the loader's duplicate-id handling rather than by the patch. It is not
in the bundle's default
patch list, and the header of that file explains why: a preset declaration patch list, and the header of that file explains why: a preset declaration
replaces the whole plugin list rather than merging into it, so the file is a replaces the whole plugin list rather than merging into it, so the file is a
frozen copy of `standard` that will not follow the harness when `standard` frozen copy of `standard` that will not follow the harness when `standard`
changes. changes.
### Preset drift, and why one dead row breaks the preset
A preset declaration mounts every row it lists, so a single row the harness no
longer provides fails the whole declaration rather than just that tool: the
roster shows the preset with a `broken` diagnostic and no session can compose it.
That is how this bundle broke on dsh `0.2.2-rc.1`. The harness folded
`list_agents` into `@deepseek-ai/dsh-tool-subagent-control` and stopped exporting
its `./list-agents` subpath; the frozen copy still named it, the row could never
start, and every session on the `facet` preset failed to resume.
`test/presets.test.js` now compares both files under `presets/` against the
`standard` preset of the installed harness — after removing the documented
deltas — and resolves every plugin name they list, so the next time the harness
moves a row the copy fails the tests instead of failing sessions.
### Prompt variables, and why the preset's persona has no suffix
Both preset files used to copy the deployment's persona line, *Your working
directory is {{cwd}}*. The harness registers prompt variables per section and an
unregistered reference **throws during prompt assembly**, which fails the entire
turn — not a warning, not a literal left in the text. That is not a hypothetical:
a harness release stopped registering `cwd` (only `provider` and `model` remain),
and every session on this bundle's preset failed with
`unknown prompt variable "{{cwd}}" in section "deployment:persona-suffix"`.
So neither preset carries that suffix now, and the folder is stated where it can
follow the session instead: `facet-guard`'s runtime binding names the facet, and
names the session folder too when the two differ — which is exactly the case
where relative tool paths need saying out loud. `test/presets.test.js` scans both
files for `{{…}}` and fails on any name outside `provider, model`, and the same
test holds this bundle's own rule and binding text to no references at all.
If a *deployment* still fails with that message on a non-facet preset, the
reference is in the deployment's own `system-prompt` config (`personaSuffix`) or
in a copy of the shipped `standard` patch, not in this bundle.
### The working directory is part of the scope
The file tools resolve a relative argument against the session's *current*
directory, and `working_directory` can change that. So the scope follows it: a
`cd` outside the facet is refused (or put to the user, by mode) like any other
out-of-facet path, and a relative `read`, `write` or `edit` is judged against the
directory the tool will actually use — not the one the conversation started in.
A delegated session started with its own `cwd` is clamped to the parent's facet;
it cannot be handed a wider scope by pointing it somewhere else.
A deployment can also shadow a built-in tool with one that names its path
argument differently — `dsh-better-edit` replaces `read` with `path` and `edit`
with `file`. The guard reads the argument names the tool actually declares for
the operations it guards, so a shadow is still judged; the table in
`lib/scope.js` is the fallback when the declaration cannot be read.
## What it does not cover ## What it does not cover
Honest boundaries, because each one is a decision rather than an oversight: Honest boundaries, because each one is a decision rather than an oversight:
@@ -249,8 +307,12 @@ Honest boundaries, because each one is a decision rather than an oversight:
outside its facet, having been told in the same prompt not to. A prompt is not outside its facet, having been told in the same prompt not to. A prompt is not
a guard, which is what the rest of this plugin is for. a guard, which is what the rest of this plugin is for.
- **Tools that name a path in a shape the table cannot read are not guessed at** — - **Tools that name a path in a shape the table cannot read are not guessed at** —
including MCP tools. See `PATH_ARGUMENTS` in `lib/scope.js`; it is a list of including MCP tools, and `present`'s nested `files[].path` (it shows the user a
tools whose path argument is a plain top-level string. file rather than reading it back to the model). See `PATH_ARGUMENTS` in
`lib/scope.js`; it is a list of tools whose path argument is a plain top-level
string. `apply_patch` is switched off in this bundle's preset for the same
reason — its paths live inside patch text — so a deployment that turns it on
gets no guard on it.
- **This guards the tool pipeline, not the filesystem.** There is no read seam in - **This guards the tool pipeline, not the filesystem.** There is no read seam in
the harness — `dsh-fs-sandbox` states plainly that "reads pass through the harness — `dsh-fs-sandbox` states plainly that "reads pass through
untouched: every mode permits reading" — so anything that reads through untouched: every mode permits reading" — so anything that reads through
@@ -264,7 +326,7 @@ Honest boundaries, because each one is a decision rather than an oversight:
Verified: Verified:
- 93 tests (`npm test`) over the scope algebra, the policy state, the guard, and - 107 tests (`npm test`) over the scope algebra, the policy state, the guard, and
the browser half — including that containment is decided on canonical targets the browser half — including that containment is decided on canonical targets
(a symlink inside the facet pointing outside it is refused), that a prefix is (a symlink inside the facet pointing outside it is refused), that a prefix is
not a parent (`/a/room` does not contain `/a/roommate`), that a malformed tool not a parent (`/a/room` does not contain `/a/roommate`), that a malformed tool
@@ -275,8 +337,17 @@ Verified:
is refused when the directory it defaults to is outside the facet, that a is refused when the directory it defaults to is outside the facet, that a
delegated session inherits its parent's root at any depth and is not a way back delegated session inherits its parent's root at any depth and is not a way back
out of a self-narrowing, that both listings normalise into one picker level and out of a self-narrowing, that both listings normalise into one picker level and
that a file listing the Host confines still leaves a browsable one, and that that a file listing the Host confines still leaves a browsable one, that no
every `facet` result satisfies the tool's own declared output schema. preset or contributed prompt text references a prompt variable the harness
does not register, that each shipped preset is the installed harness's
`standard` composition plus only its documented changes and names only plugins
the harness provides, that a `cd` outside the facet is refused while a
relative path is judged against the directory the tool will use, that a tool
shadowed onto different argument names is still guarded, that a delegated
session cannot be started outside its parent's facet, that the optional
compaction overlay replaces the shipped preset rather than adding a second
declaration, and that every `facet` result satisfies the tool's own declared
output schema.
- The bundle's patch layers parse, merge and land correctly against the real - The bundle's patch layers parse, merge and land correctly against the real
profile: `dsh --profile web --patch ./cordis.patch.yml --patch profile: `dsh --profile web --patch ./cordis.patch.yml --patch
./presets/facet.patch.yml --dump-config` shows `facet-policy`, `preset-facet`, ./presets/facet.patch.yml --dump-config` shows `facet-policy`, `preset-facet`,
@@ -334,15 +405,17 @@ would publish.
## Development ## Development
```sh ```sh
node scripts/dev-links.mjs # link the harness's cordis/schemastery/dsh-tools node scripts/dev-links.mjs # link the harness's cordis/schemastery/dsh-tools/js-yaml
npm test npm test
``` ```
`dev-links.mjs` links rather than installs those three packages, and for `dev-links.mjs` links rather than installs those four packages, and for
`@deepseek-ai/cordis` that is a correctness requirement rather than tidiness: a `@deepseek-ai/cordis` that is a correctness requirement rather than tidiness: a
second copy of Cordis means a second `Context` class, two service registries in second copy of Cordis means a second `Context` class, two service registries in
one process, and a plugin whose services are invisible to the harness that loaded one process, and a plugin whose services are invisible to the harness that loaded
it. it. `js-yaml` is there so the preset-drift tests can read the harness's own
`standard` patch; the scope search both share lives in
`scripts/harness-scope.mjs`.
## Layout ## Layout
@@ -354,7 +427,7 @@ lib/scope.js the pure half — argument extraction, text, reason
lib/guard.js preset row: rule, binding, tool, pre-execute guard lib/guard.js preset row: rule, binding, tool, pre-execute guard
presets/facet.patch.yml the `facet` agent preset presets/facet.patch.yml the `facet` agent preset
presets/standard-compaction.patch.yml optional: the same budget for `standard` presets/standard-compaction.patch.yml optional: the same budget for `standard`
test/ 93 tests test/ 107 tests
``` ```
`client/client.js` is a browser half rather than a module the host imports, and `client/client.js` is a browser half rather than a module the host imports, and
+58 -9
View File
@@ -101,6 +101,49 @@ export function apply(ctx, config) {
return true return true
} }
} }
/**
* The directory a relative argument will actually resolve against.
*
* The file tools resolve against the session's *current* working directory
* (`ctx.workingDirectory`), which the `working_directory` tool can change; the
* session header keeps the directory the conversation started in. Judging
* `../../x` against the header would ask the wrong question — after a `cd`, a
* relative read resolves somewhere else entirely — so the guard asks the same
* service the tools ask. Read lazily and tolerantly: a deployment without the
* service keeps the header's directory, and a transient failure must not turn
* into a denial.
*/
const cwdNow = (agent) => {
const service = ctx.get('workingDirectory')
if (service === undefined || agent?.session === undefined) return undefined
try {
const cwd = service.get(agent.session)
return typeof cwd === 'string' && cwd !== '' ? cwd : undefined
} catch {
return undefined
}
}
/**
* The property names the tool declares, when the guard can see them.
*
* A tool can be shadowed per agent (`dsh-better-edit` replaces `read` and
* `edit` on the agent's own layer), and the shadow may name its path argument
* differently. Reading the declaration is what keeps the guard judging the
* argument the tool will actually use rather than the one the built-in took.
* An unreadable schema is not evidence that the path went away; the table
* still applies.
*/
const declaredParameterNames = (exec) => {
try {
const declared = exec.schema?.parameters ?? ctx.tools.get(exec.name, exec.agent)?.parameters
const properties = declared?.properties
if (properties === null || typeof properties !== 'object' || Array.isArray(properties)) return undefined
return Object.keys(properties)
} catch {
return undefined
}
}
// `off` is the one part that stays a mount-time decision. Deciding it here // `off` is the one part that stays a mount-time decision. Deciding it here
// means an `off` deployment contributes no rule, no binding and no tool — // means an `off` deployment contributes no rule, no binding and no tool —
@@ -182,29 +225,35 @@ export function apply(ctx, config) {
const scope = policy.scopeFor(exec.agent) const scope = policy.scopeFor(exec.agent)
if (scope === undefined) return undefined if (scope === undefined) return undefined
const paths = pathArgumentsFor(exec.name, exec.arguments) // Relative arguments are resolved by the tool against its current working
// directory, which `working_directory` can move; judge them against the same
// directory or the check answers for a path the tool will not use.
const cwd = cwdNow(exec.agent)
const current = cwd === undefined || cwd === scope.cwd ? scope : { ...scope, cwd }
const paths = pathArgumentsFor(exec.name, exec.arguments, declaredParameterNames(exec))
if (paths.length === 0) { if (paths.length === 0) {
// A tool that names no path is judged against the path it will actually // A tool that names no path is judged against the path it will actually
// use. For most of them that is nothing — a tool with no path argument // use. For most of them that is nothing — a tool with no path argument
// cannot leave the facet. For the ones whose own default is a directory it // cannot leave the facet. For the ones whose own default is a directory it
// is the session directory, which a narrowed facet does not contain, and // is the current working directory, which a narrowed facet does not
// "no opinion" there would hand the model a read the guard exists to // contain, and "no opinion" there would hand the model a read the guard
// refuse. The containment test is the same one; only the path is ours // exists to refuse. The containment test is the same one; only the path is
// rather than the model's. // ours rather than the model's.
if (!IMPLICIT_SESSION_PATHS.includes(exec.name)) return undefined if (!IMPLICIT_SESSION_PATHS.includes(exec.name)) return undefined
const verdict = await inside(scope, scope.cwd, exec.signal) const verdict = await inside(current, current.cwd, exec.signal)
if (verdict.inside) return undefined if (verdict.inside) return undefined
const kind = mode === 'deny' ? 'deny' : 'ask' const kind = mode === 'deny' ? 'deny' : 'ask'
return { kind, reason: implicitSearchReason({ cwd: scope.cwd, root: scope.root }) } return { kind, reason: implicitSearchReason({ cwd: current.cwd, root: scope.root }) }
} }
for (const raw of paths) { for (const raw of paths) {
const verdict = await inside(scope, raw, exec.signal) const verdict = await inside(current, raw, exec.signal)
if (verdict.inside) continue if (verdict.inside) continue
const kind = mode === 'deny' ? 'deny' : 'ask' const kind = mode === 'deny' ? 'deny' : 'ask'
return { return {
kind, kind,
reason: outsideReason({ cwd: scope.cwd, path: verdict.display, root: scope.root, mode: kind }), reason: outsideReason({ cwd: current.cwd, path: verdict.display, root: scope.root, mode: kind }),
} }
} }
return undefined return undefined
+8 -2
View File
@@ -165,7 +165,12 @@ export function createFacetPolicy(config) {
* *
* Inheritance is the same kind of test, and it is skipped when the user made a * Inheritance is the same kind of test, and it is skipped when the user made a
* declaration of their own: that is their decision about *this* session, and * declaration of their own: that is their decision about *this* session, and
* the point of inheriting is to answer the case where they made none. * the point of inheriting is to answer the case where they made none. A child
* whose own directory is *outside* the inherited root is clamped to the
* inherited root rather than trusted with its own: a delegated session may be
* started anywhere, and "somewhere else" is the one direction the invariant
* forbids. A child started inside the inherited root keeps its own, narrower
* directory.
* *
* @param {string|undefined} sessionId - the session. * @param {string|undefined} sessionId - the session.
* @param {string} sessionCwd - its resolved working directory. * @param {string} sessionCwd - its resolved working directory.
@@ -176,7 +181,8 @@ export function createFacetPolicy(config) {
const declared = declaredScope(sessionId)?.focus const declared = declaredScope(sessionId)?.focus
const stated = typeof declared === 'string' && declared.trim() !== '' const stated = typeof declared === 'string' && declared.trim() !== ''
const own = stated ? resolve(sessionCwd, declared) : sessionCwd const own = stated ? resolve(sessionCwd, declared) : sessionCwd
const base = !stated && inherited !== undefined && within(inherited, own) ? inherited : own const base =
!stated && inherited !== undefined ? (within(own, inherited) ? own : inherited) : own
const agentFocus = sessionId === undefined ? undefined : narrowed.get(sessionId) const agentFocus = sessionId === undefined ? undefined : narrowed.get(sessionId)
if (agentFocus !== undefined && within(agentFocus, base)) return agentFocus if (agentFocus !== undefined && within(agentFocus, base)) return agentFocus
return base return base
+69 -6
View File
@@ -42,16 +42,33 @@
* reliably from argv, so the facet is enforced on the file tools and `bash` * reliably from argv, so the facet is enforced on the file tools and `bash`
* remains a legitimate way out. The prompt says so rather than pretending * remains a legitimate way out. The prompt says so rather than pretending
* otherwise. * otherwise.
*
* The names are the union of what the harness's own tools declare and what the
* overrides this deployment installs declare. `dsh-better-edit` shadows `read`
* with `path` and `edit` with `file`, so a table written only against the
* built-in `file_path` left the busiest read tool unguarded. Where the tool's
* declared schema is available, {@link pathArgumentsFor} narrows this list to
* the names the tool actually declares and adds any name in
* {@link PATH_PARAMETER_NAMES}; the table is the fallback for a schema the
* guard cannot see. `working_directory` and the delegation tools are here
* because they change the directory later calls resolve against, and the child
* they start — both are part of the scope, not a separate one.
*/ */
export const PATH_PARAMETER_NAMES = Object.freeze(['file_path', 'path', 'file', 'dir', 'directory'])
export const PATH_ARGUMENTS = Object.freeze({ export const PATH_ARGUMENTS = Object.freeze({
read: ['file_path'], read: ['file_path', 'path'],
write: ['file_path'], write: ['file_path', 'path'],
edit: ['file_path'], edit: ['file_path', 'file', 'path'],
read_image: ['file_path'], read_image: ['file_path', 'path'],
undo_last_edit: ['path'],
grep: ['path'], grep: ['path'],
glob: ['path'], glob: ['path'],
str_replace_editor: ['path'], str_replace_editor: ['path'],
recall: ['path', 'focus'], recall: ['path', 'focus'],
working_directory: ['cd'],
subagent: ['cwd'],
subagent_fork: ['cwd'],
}) })
/** /**
@@ -80,6 +97,38 @@ export const IMPLICIT_SESSION_PATHS = Object.freeze(['grep', 'glob', 'recall'])
export const FACET_TOOL = 'facet' export const FACET_TOOL = 'facet'
export const WIDENING_ACTION = 'add' export const WIDENING_ACTION = 'add'
/**
* The parameter names the guard should read for one tool call.
*
* The table is the intent; the tool's declaration is the truth. When the call
* carries a schema (a PTC inner call) or the registry can supply one, the names
* are restricted to what the tool declares — that is what keeps a shadowed tool
* honest — and any declared parameter in {@link PATH_PARAMETER_NAMES} is added
* even when the table did not list it. With no readable schema the table is
* used unchanged: a declaration the guard cannot see is not evidence that the
* path went away.
*
* @param {string} toolName - the tool being called.
* @param {readonly string[]|undefined} declaredNames - property names from the
* tool's own parameter schema, when the guard can read it.
* @returns {readonly string[]|undefined} names to read, or undefined for an
* unguarded tool.
*/
export function pathParameterNames(toolName, declaredNames) {
const fallback = PATH_ARGUMENTS[toolName]
if (fallback === undefined) return undefined
if (declaredNames === undefined) return fallback
const declared = new Set(declaredNames)
const names = [
...new Set([
...fallback.filter((name) => declared.has(name)),
...declaredNames.filter((name) => PATH_PARAMETER_NAMES.includes(name)),
]),
]
return names.length > 0 ? names : fallback
}
/** /**
* Every path a tool call names, as the model wrote them. * Every path a tool call names, as the model wrote them.
* *
@@ -95,13 +144,15 @@ export const WIDENING_ACTION = 'add'
* *
* @param {string} toolName - the tool being called. * @param {string} toolName - the tool being called.
* @param {unknown} args - the raw model arguments. * @param {unknown} args - the raw model arguments.
* @param {readonly string[]|undefined} [declaredNames] - property names from the
* tool's own parameter schema, when the guard can read it.
* @returns {string[]} raw paths, in argument order. * @returns {string[]} raw paths, in argument order.
*/ */
export function pathArgumentsFor(toolName, args) { export function pathArgumentsFor(toolName, args, declaredNames) {
if (args === null || typeof args !== 'object') return [] if (args === null || typeof args !== 'object') return []
const record = /** @type {Record<string, unknown>} */ (args) const record = /** @type {Record<string, unknown>} */ (args)
const names = PATH_ARGUMENTS[toolName] const names = pathParameterNames(toolName, declaredNames)
if (names === undefined) return [] if (names === undefined) return []
const out = [] const out = []
@@ -233,6 +284,18 @@ export function facetContextText(input) {
// model needs a path it can reason about, and the user reading an approval // model needs a path it can reason about, and the user reading an approval
// prompt needs to see which folder they are being asked about. // prompt needs to see which folder they are being asked about.
const lines = [`facet: ${root}`] const lines = [`facet: ${root}`]
// The session folder is named only when it is not the facet — the case wherever
// the user narrowed a conversation that started higher up — because that is when
// the two differ and relative paths in tool calls need saying out loud.
//
// It used to be the deployment persona's suffix that stated this, through the
// `cwd` prompt variable. The harness stopped registering that variable, and an
// unknown one now throws during prompt assembly instead of rendering as text, so
// a static template cannot carry a per-session fact any more. This can: it is
// rebuilt for each request from the same header the tool calls resolve against.
if (typeof cwd === 'string' && cwd !== '' && cwd !== root) {
lines.push(`session folder: ${cwd} — relative paths in tool calls resolve here`)
}
if (extras.length > 0) lines.push(`granted outside it: ${extras.map((path) => displayPath(cwd, path)).join(', ')}`) if (extras.length > 0) lines.push(`granted outside it: ${extras.map((path) => displayPath(cwd, path)).join(', ')}`)
lines.push(`outside the facet: ${reach}`) lines.push(`outside the facet: ${reach}`)
return lines.join('\n') return lines.join('\n')
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "dsh-facet", "name": "dsh-facet",
"version": "0.4.0", "version": "0.4.3",
"private": true, "private": true,
"type": "module", "type": "module",
"description": "Scope an agent session to one facet of a multi-faceted system: the session's own folder, plus whatever files the user grants it.", "description": "Scope an agent session to one facet of a multi-faceted system: the session's own folder, plus whatever files the user grants it.",
+31 -35
View File
@@ -1,21 +1,33 @@
# Agent preset facet: one `@deepseek-ai/dsh-agent-preset` declaration inserted # Agent preset facet: one `@deepseek-ai/dsh-agent-preset` declaration inserted
# after the web patch. # after the web patch.
# #
# The composition is `standard` with two changes, and this file is the only place # The composition is the shipped `standard` patch with three changes, and this
# either of them is decided: # file is the only place any of them is decided:
# #
# * compaction is configured (see the `compaction` row below) so the pressure # * compaction is configured (see the `compaction` row below) so the pressure
# trigger is a budget rather than a formality. The shipped ratio is 0.80 of a # trigger is a budget rather than a formality. The shipped ratio is 0.80 of a
# 1,000,000-token window, i.e. 800k, and on this deployment nothing has ever # 1,000,000-token window, i.e. 800k, and on this deployment nothing has ever
# come within 1.5% of it — compaction had never once run; # come within 1.5% of it — compaction had never once run;
# #
# * `facet-guard` is mounted, which confines the session to its own folder. # * `facet-guard` is mounted, which confines the session to its own folder;
#
# * the persona row carries no suffix. The shipped one used to state the
# working directory through a prompt variable the harness no longer
# registers, and an unregistered variable fails the whole turn — see the
# note on that row.
# #
# Everything else is copied verbatim from the shipped `standard` patch, and that # Everything else is copied verbatim from the shipped `standard` patch, and that
# is deliberate: a preset declaration replaces the whole plugin list rather than # is deliberate: a preset declaration replaces the whole plugin list rather than
# merging into it, so a clone that drifts from the original silently loses # merging into it, so a clone that drifts from the original silently loses
# whatever it drifted past. When the harness next changes `standard`, re-copy # whatever it drifted past — and a clone that keeps a row the harness has since
# this file and re-apply the two changes — do not hand-patch around it. # removed fails to mount at all. That is how this preset broke on dsh
# 0.2.2-rc.1: the harness folded `list_agents` into
# `@deepseek-ai/dsh-tool-subagent-control` and stopped exporting its
# `./list-agents` subpath, so the copied row could never start and the whole
# preset reported as broken. When the harness next changes `standard`, re-copy
# this file and re-apply the three changes — do not hand-patch around it.
# `test/presets.test.js` compares this file against the installed `standard`
# and fails on any drift, so the reminder is enforced rather than remembered.
- insert: - insert:
- id: preset-facet - id: preset-facet
name: '@deepseek-ai/dsh-agent-preset' name: '@deepseek-ai/dsh-agent-preset'
@@ -28,12 +40,13 @@
- id: persona - id: persona
name: '@deepseek-ai/dsh-persona' name: '@deepseek-ai/dsh-persona'
config: config:
suffix: Your working directory is {{cwd}}.
prefix: You are a coding agent powered by the {{model}} model. prefix: You are a coding agent powered by the {{model}} model.
- id: agent-instructions - id: agent-instructions
name: '@deepseek-ai/dsh-agent-instructions' name: '@deepseek-ai/dsh-agent-instructions'
config: config:
maxBytes: 65536 maxBytes: 65536
- id: time-context
name: '@deepseek-ai/dsh-time-context'
# The facet itself: a rule in the system prompt, the binding in the # The facet itself: a rule in the system prompt, the binding in the
# runtime context, the `facet` tool, and the pre-execute guard that # runtime context, the `facet` tool, and the pre-execute guard that
# asks before a file call leaves the session's folder. Configured by # asks before a file call leaves the session's folder. Configured by
@@ -49,12 +62,17 @@
disabled: !!js process.platform !== 'win32' disabled: !!js process.platform !== 'win32'
- id: tool-fs - id: tool-fs
name: '@deepseek-ai/dsh-tool-fs' name: '@deepseek-ai/dsh-tool-fs'
config:
# Set false to drop the apply_patch tool beside edit.
applyPatch: false
- id: tool-fs-search - id: tool-fs-search
name: '@deepseek-ai/dsh-tool-fs-search' name: '@deepseek-ai/dsh-tool-fs-search'
config: config:
sampleOverCapGlobResults: false sampleOverCapGlobResults: false
- id: tool-jobs - id: tool-jobs
name: '@deepseek-ai/dsh-tool-jobs' name: '@deepseek-ai/dsh-tool-jobs'
- id: tool-schedule
name: '@deepseek-ai/dsh-tool-schedule'
- id: skill-filesystem - id: skill-filesystem
name: '@deepseek-ai/dsh-skill-filesystem' name: '@deepseek-ai/dsh-skill-filesystem'
- id: tool-skill - id: tool-skill
@@ -73,7 +91,7 @@
name: '@deepseek-ai/dsh-plan-mode' name: '@deepseek-ai/dsh-plan-mode'
config: config:
section: | section: |
You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode. You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery. Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
@@ -94,7 +112,7 @@
- id: compaction-basic - id: compaction-basic
name: '@deepseek-ai/dsh-compaction-basic' name: '@deepseek-ai/dsh-compaction-basic'
config: config:
# 0.80 of a 1M window is a 800k trigger, and the deepest session # 0.80 of a 1M window is an 800k trigger, and the deepest session
# ever recorded here peaked at 787,668 pressure tokens: the # ever recorded here peaked at 787,668 pressure tokens: the
# trigger was never reached, so every token below it was re-read # trigger was never reached, so every token below it was re-read
# on every subsequent step. 0.35 puts the ceiling at 350k. # on every subsequent step. 0.35 puts the ceiling at 350k.
@@ -122,49 +140,24 @@
config: config:
- id: tool-subagent-control - id: tool-subagent-control
name: '@deepseek-ai/dsh-tool-subagent-control' name: '@deepseek-ai/dsh-tool-subagent-control'
- id: tool-subagent-list-agents
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
- id: tool-subagent - id: tool-subagent
name: '@deepseek-ai/dsh-tool-subagent' name: '@deepseek-ai/dsh-tool-subagent'
config: config:
provider: spawn provider: spawn
toolName: subagent toolName: subagent
modelSelectionSettings: true modelSelection: true
backgroundMode: continuable modelDiscovery: true
- id: tool-subagent-fork - id: tool-subagent-fork
name: '@deepseek-ai/dsh-tool-subagent' name: '@deepseek-ai/dsh-tool-subagent'
config: config:
provider: fork provider: fork
toolName: subagent_fork toolName: subagent_fork
backgroundMode: continuable
- id: tool-subagent-codex
name: '@deepseek-ai/dsh-tool-subagent'
disabled: true
config:
provider: codex
toolName: subagent_codex
backgroundMode: one-shot
maxDepth: provider-managed
- id: tool-subagent-claude-code
name: '@deepseek-ai/dsh-tool-subagent'
disabled: true
config:
provider: claude-code
toolName: subagent_claude_code
backgroundMode: one-shot
maxDepth: provider-managed
- id: workflow-ptc - id: workflow-ptc
name: '@deepseek-ai/dsh-workflow-ptc' name: '@deepseek-ai/dsh-workflow-ptc'
config: config:
provider: spawn provider: spawn
- id: tool-workflow - id: tool-workflow
name: '@deepseek-ai/dsh-tool-workflow' name: '@deepseek-ai/dsh-tool-workflow'
- id: tool-ralph
name: '@deepseek-ai/dsh-tool-ralph'
disabled: true
config:
subagentProvider: spawn
maxRounds: 64
- id: tool-ask-user - id: tool-ask-user
name: '@deepseek-ai/dsh-tool-ask-user' name: '@deepseek-ai/dsh-tool-ask-user'
- id: tool-todo - id: tool-todo
@@ -180,4 +173,7 @@
name: '@deepseek-ai/dsh-tool-present' name: '@deepseek-ai/dsh-tool-present'
- id: tool-plugin-manager - id: tool-plugin-manager
name: '@deepseek-ai/dsh-plugin-manager/tools' name: '@deepseek-ai/dsh-plugin-manager/tools'
disabled: !!js "!ctx.get('profileContext')"
- id: tool-plugin-market
name: '@deepseek-ai/dsh-plugin-market/tools'
disabled: true disabled: true
+26 -34
View File
@@ -8,17 +8,25 @@
# #
# or add its path to `dsh.bundle.patch` in package.json. # or add its path to `dsh.bundle.patch` in package.json.
# #
# It overrides the shipped `preset-standard` row by id rather than inserting a
# second declaration. With two rows carrying the same preset id, which one mounts
# is decided by the loader's duplicate-id handling rather than by the patch — the
# insert form worked only as long as that ordering held. The override is explicit
# and must be applied after the web-app layer, which both ways above are.
#
# It is deliberately not applied for you, and the reason is a real hazard rather # It is deliberately not applied for you, and the reason is a real hazard rather
# than caution: a preset declaration replaces the whole plugin list, never merges # than caution: a preset declaration replaces the whole plugin list, never merges
# into it, so this file is a frozen copy of the shipped `standard` composition # into it, so this file is a frozen copy of the shipped `standard` composition
# plus one change. When the harness next updates `standard` — a new tool, a # plus one change. When the harness next updates `standard` — a new tool, a
# renamed row — this copy will not follow it, and the sessions on this preset # renamed row — this copy will not follow it, and the sessions on this preset
# will silently lose whatever was added. Use it if you are prepared to re-copy # will silently lose whatever was added, or fail to mount if the copy keeps a
# and re-apply when that happens; otherwise take the compaction settings into # row the harness removed. Use it if you are prepared to re-copy and re-apply
# whichever preset you actually run. # when that happens; otherwise take the compaction settings into whichever
# preset you actually run.
# #
# The only change from the shipped file is the `compaction-basic` row's config. # The one change from the shipped file is the `compaction-basic` row's config.
- insert: # `test/presets.test.js` compares this file against the installed `standard`
# and fails on any other difference.
- id: preset-standard - id: preset-standard
name: '@deepseek-ai/dsh-agent-preset' name: '@deepseek-ai/dsh-agent-preset'
config: config:
@@ -28,12 +36,13 @@
- id: persona - id: persona
name: '@deepseek-ai/dsh-persona' name: '@deepseek-ai/dsh-persona'
config: config:
suffix: Your working directory is {{cwd}}.
prefix: You are a coding agent powered by the {{model}} model. prefix: You are a coding agent powered by the {{model}} model.
- id: agent-instructions - id: agent-instructions
name: '@deepseek-ai/dsh-agent-instructions' name: '@deepseek-ai/dsh-agent-instructions'
config: config:
maxBytes: 65536 maxBytes: 65536
- id: time-context
name: '@deepseek-ai/dsh-time-context'
- id: tool-bash - id: tool-bash
name: '@deepseek-ai/dsh-tool-bash' name: '@deepseek-ai/dsh-tool-bash'
disabled: !!js process.platform === 'win32' disabled: !!js process.platform === 'win32'
@@ -42,12 +51,17 @@
disabled: !!js process.platform !== 'win32' disabled: !!js process.platform !== 'win32'
- id: tool-fs - id: tool-fs
name: '@deepseek-ai/dsh-tool-fs' name: '@deepseek-ai/dsh-tool-fs'
config:
# Set false to drop the apply_patch tool beside edit.
applyPatch: false
- id: tool-fs-search - id: tool-fs-search
name: '@deepseek-ai/dsh-tool-fs-search' name: '@deepseek-ai/dsh-tool-fs-search'
config: config:
sampleOverCapGlobResults: false sampleOverCapGlobResults: false
- id: tool-jobs - id: tool-jobs
name: '@deepseek-ai/dsh-tool-jobs' name: '@deepseek-ai/dsh-tool-jobs'
- id: tool-schedule
name: '@deepseek-ai/dsh-tool-schedule'
- id: skill-filesystem - id: skill-filesystem
name: '@deepseek-ai/dsh-skill-filesystem' name: '@deepseek-ai/dsh-skill-filesystem'
- id: tool-skill - id: tool-skill
@@ -66,7 +80,7 @@
name: '@deepseek-ai/dsh-plan-mode' name: '@deepseek-ai/dsh-plan-mode'
config: config:
section: | section: |
You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode. You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery. Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
@@ -107,49 +121,24 @@
config: config:
- id: tool-subagent-control - id: tool-subagent-control
name: '@deepseek-ai/dsh-tool-subagent-control' name: '@deepseek-ai/dsh-tool-subagent-control'
- id: tool-subagent-list-agents
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
- id: tool-subagent - id: tool-subagent
name: '@deepseek-ai/dsh-tool-subagent' name: '@deepseek-ai/dsh-tool-subagent'
config: config:
provider: spawn provider: spawn
toolName: subagent toolName: subagent
modelSelectionSettings: true modelSelection: true
backgroundMode: continuable modelDiscovery: true
- id: tool-subagent-fork - id: tool-subagent-fork
name: '@deepseek-ai/dsh-tool-subagent' name: '@deepseek-ai/dsh-tool-subagent'
config: config:
provider: fork provider: fork
toolName: subagent_fork toolName: subagent_fork
backgroundMode: continuable
- id: tool-subagent-codex
name: '@deepseek-ai/dsh-tool-subagent'
disabled: true
config:
provider: codex
toolName: subagent_codex
backgroundMode: one-shot
maxDepth: provider-managed
- id: tool-subagent-claude-code
name: '@deepseek-ai/dsh-tool-subagent'
disabled: true
config:
provider: claude-code
toolName: subagent_claude_code
backgroundMode: one-shot
maxDepth: provider-managed
- id: workflow-ptc - id: workflow-ptc
name: '@deepseek-ai/dsh-workflow-ptc' name: '@deepseek-ai/dsh-workflow-ptc'
config: config:
provider: spawn provider: spawn
- id: tool-workflow - id: tool-workflow
name: '@deepseek-ai/dsh-tool-workflow' name: '@deepseek-ai/dsh-tool-workflow'
- id: tool-ralph
name: '@deepseek-ai/dsh-tool-ralph'
disabled: true
config:
subagentProvider: spawn
maxRounds: 64
- id: tool-ask-user - id: tool-ask-user
name: '@deepseek-ai/dsh-tool-ask-user' name: '@deepseek-ai/dsh-tool-ask-user'
- id: tool-todo - id: tool-todo
@@ -165,4 +154,7 @@
name: '@deepseek-ai/dsh-tool-present' name: '@deepseek-ai/dsh-tool-present'
- id: tool-plugin-manager - id: tool-plugin-manager
name: '@deepseek-ai/dsh-plugin-manager/tools' name: '@deepseek-ai/dsh-plugin-manager/tools'
disabled: !!js "!ctx.get('profileContext')"
- id: tool-plugin-market
name: '@deepseek-ai/dsh-plugin-market/tools'
disabled: true disabled: true
+13 -21
View File
@@ -5,10 +5,12 @@
* *
* ## Why this exists * ## Why this exists
* *
* The plugin imports `@deepseek-ai/dsh-tools` and `@deepseek-ai/schemastery`. * The plugin imports `@deepseek-ai/dsh-tools` and `@deepseek-ai/schemastery`,
* Once installed into a profile those resolve from the profile's own * and `test/presets.test.js` reads the shipped `standard` preset through
* `node_modules`, which is where the harness lives — but a bare checkout has no * `js-yaml` to compare it with this bundle's frozen copies. Once installed into
* such tree, so the tests cannot even load the module under test. * a profile those resolve from the profile's own `node_modules`, which is where
* the harness lives — but a bare checkout has no such tree, so the tests cannot
* even load the module under test.
* *
* The alternative is declaring them as dependencies, and for `@deepseek-ai/cordis` * The alternative is declaring them as dependencies, and for `@deepseek-ai/cordis`
* that would be a genuine bug rather than untidiness: a second copy of Cordis * that would be a genuine bug rather than untidiness: a second copy of Cordis
@@ -23,25 +25,14 @@ import { existsSync, mkdirSync, readdirSync, rmSync, symlinkSync } from 'node:fs
import { dirname, join, resolve } from 'node:path' import { dirname, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url' import { fileURLToPath } from 'node:url'
import { findHarnessScope } from './harness-scope.mjs'
/** Packages this checkout imports at runtime, and which the harness must supply. */ /** Packages this checkout imports at runtime, and which the harness must supply. */
const NEEDED = ['cordis', 'schemastery', 'dsh-tools'] const NEEDED = ['@deepseek-ai/cordis', '@deepseek-ai/schemastery', '@deepseek-ai/dsh-tools', 'js-yaml']
const here = dirname(fileURLToPath(import.meta.url)) const here = dirname(fileURLToPath(import.meta.url))
const packageRoot = resolve(here, '..') const packageRoot = resolve(here, '..')
/** Where a dsh installation keeps the scope, newest layout first. */
function findHarnessScope() {
const candidates = [
process.env.DSH_HARNESS_NODE_MODULES,
resolve(process.env.DSH_HOME ?? join(process.env.HOME ?? '', '.dsh'), 'profiles', 'node_modules'),
'/usr/local/lib/node_modules/@deepseek-ai/dsh/node_modules',
]
for (const candidate of candidates) {
if (typeof candidate === 'string' && existsSync(join(candidate, '@deepseek-ai', 'cordis'))) return candidate
}
return undefined
}
const scope = findHarnessScope() const scope = findHarnessScope()
if (scope === undefined) { if (scope === undefined) {
console.error('dev-links: no dsh installation found. Set DSH_HARNESS_NODE_MODULES to its node_modules directory.') console.error('dev-links: no dsh installation found. Set DSH_HARNESS_NODE_MODULES to its node_modules directory.')
@@ -49,16 +40,17 @@ if (scope === undefined) {
} }
const target = join(packageRoot, 'node_modules') const target = join(packageRoot, 'node_modules')
mkdirSync(join(target, '@deepseek-ai'), { recursive: true }) mkdirSync(target, { recursive: true })
let linked = 0 let linked = 0
for (const name of NEEDED) { for (const name of NEEDED) {
const source = join(scope, '@deepseek-ai', name) const source = join(scope, name)
if (!existsSync(source)) { if (!existsSync(source)) {
console.error(`dev-links: ${name} is not in ${scope}; skipping`) console.error(`dev-links: ${name} is not in ${scope}; skipping`)
continue continue
} }
const link = join(target, '@deepseek-ai', name) const link = join(target, name)
mkdirSync(dirname(link), { recursive: true })
if (existsSync(link)) rmSync(link, { recursive: true, force: true }) if (existsSync(link)) rmSync(link, { recursive: true, force: true })
symlinkSync(source, link, 'dir') symlinkSync(source, link, 'dir')
linked += 1 linked += 1
+46
View File
@@ -0,0 +1,46 @@
/**
* Locate a dsh installation's dependency scope from a checkout.
*
* The plugin links harness packages into a bare checkout (see `dev-links.mjs`)
* and `test/presets.test.js` reads the shipped `standard` preset to compare it
* with this bundle's frozen copies. Both need the same answer to "where is the
* harness?", so the search lives here rather than twice.
*
* There can be more than one answer. A harness home may carry the legacy
* `profiles/node_modules` mirror that an older link backend projected, and that
* mirror is a snapshot: packages added to the installation later are missing
* from it. Callers that resolve more than one package should therefore try
* every scope, not only {@link findHarnessScope}'s first answer.
*/
import { existsSync } from 'node:fs'
import { join, resolve } from 'node:path'
/**
* Every dependency scope a dsh installation may occupy, newest layout first.
*
* @returns the directories that hold `@deepseek-ai/cordis`, deduplicated, in
* preference order.
*/
export function harnessScopes() {
const candidates = [
process.env.DSH_HARNESS_NODE_MODULES,
resolve(process.env.DSH_HOME ?? join(process.env.HOME ?? '', '.dsh'), 'profiles', 'node_modules'),
'/usr/local/lib/node_modules/@deepseek-ai/dsh/node_modules',
]
const scopes = []
for (const candidate of candidates) {
if (typeof candidate !== 'string' || !existsSync(join(candidate, '@deepseek-ai', 'cordis'))) continue
if (!scopes.includes(candidate)) scopes.push(candidate)
}
return scopes
}
/**
* The preferred dependency scope of a dsh installation.
*
* @returns the first directory that holds `@deepseek-ai/cordis`, or undefined.
*/
export function findHarnessScope() {
return harnessScopes()[0]
}
+109 -3
View File
@@ -66,14 +66,25 @@ const fsLikeLocal = {
* deployment that composed no approval service at all — a case the tool pipeline * deployment that composed no approval service at all — a case the tool pipeline
* denies outright, so the guard must treat it as no channel. * denies outright, so the guard must treat it as no channel.
*/ */
function harness({ mode = 'ask', extraRoots = [], tool = true, config, approval } = {}) { function harness({
mode = 'ask',
extraRoots = [],
tool = true,
config,
approval,
workingDirectory,
toolSchemas,
} = {}) {
const policy = createFacetPolicy(config ?? { mode, extraRoots }) const policy = createFacetPolicy(config ?? { mode, extraRoots })
const captured = { section: undefined, context: undefined, tool: undefined, preExecute: undefined } const captured = { section: undefined, context: undefined, tool: undefined, preExecute: undefined }
const ctx = { const ctx = {
facetPolicy: policy, facetPolicy: policy,
fs: fsLikeLocal, fs: fsLikeLocal,
get: (name) => get: (name) => {
name === 'approval' && approval !== undefined ? { effectivePolicy: () => approval } : undefined, if (name === 'approval' && approval !== undefined) return { effectivePolicy: () => approval }
if (name === 'workingDirectory' && workingDirectory !== undefined) return workingDirectory
return undefined
},
systemPrompt: { systemPrompt: {
section: (value) => { section: (value) => {
captured.section = value captured.section = value
@@ -86,6 +97,13 @@ function harness({ mode = 'ask', extraRoots = [], tool = true, config, approval
register: (value) => { register: (value) => {
captured.tool = value captured.tool = value
}, },
// The registry lookup the guard uses to learn a shadowed tool's argument
// names; `toolSchemas` is a name-to-parameter-names map.
get: (name) => {
const names = toolSchemas?.[name]
if (names === undefined) return undefined
return { parameters: { properties: Object.fromEntries(names.map((parameter) => [parameter, {}])) } }
},
}, },
on: (event, listener) => { on: (event, listener) => {
if (event === 'tools/pre-execute') captured.preExecute = listener if (event === 'tools/pre-execute') captured.preExecute = listener
@@ -241,6 +259,94 @@ test('an agent with no working directory is not scoped', async () => {
assert.deepEqual(await dispatch(captured, { name: 'read', args: { file_path: '/etc/hosts' } }), { kind: 'allow' }) assert.deepEqual(await dispatch(captured, { name: 'read', args: { file_path: '/etc/hosts' } }), { kind: 'allow' })
}) })
// ── the working directory is part of the scope ──────────────────────────────
//
// The file tools resolve relative arguments against the session's *current*
// directory, not the header it started with. A guard that asked the header would
// answer for a path the tool never touches, and one that ignored
// `working_directory` would let a `cd` do the stepping out.
test('a working directory outside the facet cannot be entered', async () => {
const { captured } = harness({ mode: 'deny' })
const decision = await dispatch(captured, { name: 'working_directory', args: { cd: '../../shared' }, agent: agent() })
assert.equal(decision.kind, 'deny')
assert.match(decision.reason, /src\/shared/)
// Inside the facet is ordinary work, and reading the directory changes nothing.
assert.deepEqual(
await dispatch(captured, { name: 'working_directory', args: { cd: 'inner' }, agent: agent() }),
{ kind: 'allow' },
)
assert.deepEqual(await dispatch(captured, { name: 'working_directory', args: {}, agent: agent() }), {
kind: 'allow',
})
})
test('a relative path is judged against the directory the tool will use', async () => {
// The session header says `room`; the tool will resolve `types.ts` under
// `shared`, which is outside. Judging the header would call this inside.
const { captured } = harness({ mode: 'deny', workingDirectory: { get: () => join(root, 'src', 'shared') } })
const decision = await dispatch(captured, { name: 'read', args: { file_path: 'types.ts' }, agent: agent() })
assert.equal(decision.kind, 'deny')
// The reason is shown relative to the directory the tool will use.
assert.match(decision.reason, /types\.ts/)
assert.match(decision.reason, /src\/controllers\/room/, 'the reason names the facet')
})
test('a search with no path follows the current directory into the facet', async () => {
// The session is the facet's parent and the user narrowed to `inner`; the
// current directory is `inner`, so a bare grep searches inside the facet even
// though the session directory is outside it.
const { captured } = harness({
mode: 'deny',
config: { scopes: { 'session-1': { focus: 'inner' } } },
workingDirectory: { get: () => join(facet, 'inner') },
})
assert.deepEqual(await dispatch(captured, { name: 'grep', args: { pattern: 'x' }, agent: agent() }), {
kind: 'allow',
})
})
// ── shadowed tools ───────────────────────────────────────────────────────────
//
// A deployment plugin can replace a built-in tool with one that names its path
// argument differently — `dsh-better-edit` shadows `read` (path) and `edit`
// (file). The guard reads the declaration, so the shadow stays guarded.
test('a tool shadowed with a different argument name is still judged', async () => {
const { captured } = harness({ mode: 'deny', toolSchemas: { read: ['path', 'offset'], edit: ['file', 'edits'] } })
const read = await dispatch(captured, { name: 'read', args: { path: '../../shared/types.ts' }, agent: agent() })
assert.equal(read.kind, 'deny')
assert.match(read.reason, /src\/shared\/types\.ts/)
const edit = await dispatch(captured, {
name: 'edit',
args: { file: '../../shared/types.ts', edits: [] },
agent: agent(),
})
assert.equal(edit.kind, 'deny')
})
test('a delegated session cannot be started outside the facet', async () => {
const { captured } = harness({ mode: 'deny', toolSchemas: { subagent: ['cwd', 'description', 'prompt'] } })
assert.equal(
(
await dispatch(captured, {
name: 'subagent',
args: { cwd: '../../shared', description: 'x', prompt: 'y' },
agent: agent(),
})
).kind,
'deny',
)
// Omitted means the child inherits this directory, which is inside.
assert.deepEqual(
await dispatch(captured, { name: 'subagent', args: { description: 'x', prompt: 'y' }, agent: agent() }),
{ kind: 'allow' },
)
})
// ── delegated sessions ─────────────────────────────────────────────────────── // ── delegated sessions ───────────────────────────────────────────────────────
// //
// A session spawned or forked from a scoped one has no declaration of its own, // A session spawned or forked from a scoped one has no declaration of its own,
+17
View File
@@ -222,6 +222,23 @@ test('a child is never wider than its parent is now, narrowing included', () =>
assert.equal(policy.scopeFor(spawned('c1', 's1')).root, '/w/src/room') assert.equal(policy.scopeFor(spawned('c1', 's1')).root, '/w/src/room')
}) })
test('a child started outside its parent facet is clamped to the parent root', () => {
const policy = createFacetPolicy({ mode: 'deny', scopes: { s1: { focus: 'src/room' } } })
assert.equal(policy.scopeFor(agentAt('/w', 's1')).root, '/w/src/room')
// The subagent tool takes a starting directory, and an agent can name one
// outside the facet. The child's scope must not widen to it: the invariant is
// one-directional, so a disjoint directory is clamped rather than trusted.
const escaped = spawned('c1', 's1', '/etc')
assert.equal(policy.scopeFor(escaped).root, '/w/src/room')
// Its own directory still governs how its relative paths resolve; that is the
// guard's question, decided against the inherited root.
assert.equal(policy.scopeFor(escaped).cwd, '/etc')
// A child started inside the parent's root keeps its own, narrower directory.
assert.equal(policy.scopeFor(spawned('c2', 's1', '/w/src/room/deep')).root, '/w/src/room/deep')
})
test('a declaration for the child itself stands over what it would inherit', () => { test('a declaration for the child itself stands over what it would inherit', () => {
const policy = createFacetPolicy({ mode: 'deny', scopes: { s1: { focus: 'src/room' }, c1: { focus: '.' } } }) const policy = createFacetPolicy({ mode: 'deny', scopes: { s1: { focus: 'src/room' }, c1: { focus: '.' } } })
policy.scopeFor(agentAt('/w', 's1')) policy.scopeFor(agentAt('/w', 's1'))
+260
View File
@@ -0,0 +1,260 @@
import assert from 'node:assert/strict'
import { existsSync, readFileSync, readdirSync } from 'node:fs'
import { createRequire } from 'node:module'
import { dirname, join } from 'node:path'
import { test } from 'node:test'
import { fileURLToPath, pathToFileURL } from 'node:url'
import yaml from 'js-yaml'
import { facetContextText, facetRuleText } from '../lib/scope.js'
import { harnessScopes } from '../scripts/harness-scope.mjs'
const PRESETS = join(dirname(fileURLToPath(import.meta.url)), '..', 'presets')
/**
* The prompt variables the harness registers for a section.
*
* `dsh-agent-loop` puts each of these into the prompt registry, and an assembly
* substitutes only what is registered. An unknown reference is not rendered as
* text — interpolation throws, and the throw takes the entire turn with it, so
* the user sees "This turn failed" and nothing else. A harness release that
* stopped registering `cwd` is exactly how this bundle's preset stopped
* composing sessions: the persona suffix it copied from the deployment said
* "Your working directory is …" with that variable in it.
*/
const REGISTERED = ['provider', 'model']
/** Every `{{name}}` reference in one text, as the name alone. */
function referencesIn(text) {
return [...text.matchAll(/\{\{([^{}]*)\}\}/g)].map((match) => match[1])
}
test('no preset references a prompt variable the harness does not register', () => {
const files = readdirSync(PRESETS).filter((name) => name.endsWith('.yml'))
assert.ok(files.length > 0, 'the bundle ships at least one preset')
const found = []
for (const file of files) {
for (const name of referencesIn(readFileSync(join(PRESETS, file), 'utf8'))) found.push([file, name])
}
// The model reference is the one that has to keep working, so the guard cannot
// be satisfied by a preset that references nothing at all.
assert.ok(
found.some(([, name]) => name === 'model'),
'a preset still names the model',
)
for (const [file, name] of found) {
assert.ok(
REGISTERED.includes(name),
`${file} references {{${name}}}; the harness registers only ${REGISTERED.join(', ')}, and an unregistered reference fails the whole turn`,
)
}
})
test('the text this bundle contributes to the prompt holds no variable references', () => {
// The rule and the binding are rebuilt from real values on every request, so a
// placeholder in either would be a reference the harness never resolves — the
// same failure, this time from the bundle's own hand.
const rule = facetRuleText()
const binding = facetContextText({ cwd: '/w', root: '/w/src', extras: ['/w/shared'], mode: 'ask' })
assert.ok(rule.length > 0 && binding.length > 0, 'both halves contribute text')
assert.deepEqual(referencesIn(rule), [])
assert.deepEqual(referencesIn(binding), [])
})
/*
* Drift against the shipped `standard` composition.
*
* A preset declaration replaces the whole plugin list rather than merging into
* it, so both files under `presets/` are frozen copies of the harness's
* `standard` patch. That copy is what breaks when the harness changes: on dsh
* 0.2.2-rc.1 the harness folded `list_agents` into
* `@deepseek-ai/dsh-tool-subagent-control` and dropped its `./list-agents`
* subpath, and the copied row could never start — which breaks the *whole*
* preset, because one row that fails to mount fails the declaration. These
* tests turn "remember to re-copy it" into a build failure.
*
* They need the installed harness, so they skip on a checkout without one.
*/
const PACKAGE_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
const FACET_PRESET = join(PRESETS, 'facet.patch.yml')
const COMPACTION_PRESET = join(PRESETS, 'standard-compaction.patch.yml')
const HARNESS_SCOPES = harnessScopes()
const STANDARD_PRESET = HARNESS_SCOPES
.map((scope) => join(scope, '@deepseek-ai', 'dsh-web-app', 'presets', 'standard.patch.yml'))
.find((file) => existsSync(file))
const APP_BOOT = HARNESS_SCOPES
.map((scope) => join(scope, '@deepseek-ai', 'dsh-app-boot', 'lib', 'index.js'))
.find((file) => existsSync(file))
const SKIP_DRIFT =
HARNESS_SCOPES.length === 0
? 'no dsh installation found; set DSH_HARNESS_NODE_MODULES to compare against the shipped standard preset'
: STANDARD_PRESET === undefined
? 'the shipped standard preset was not found in any harness scope'
: false
/** The `!!js` tag carries a source expression; both compared sides keep it as text. */
const PRESET_SCHEMA = yaml.DEFAULT_SCHEMA.extend([
new yaml.Type('tag:yaml.org,2002:js', { kind: 'scalar', construct: (value) => value }),
])
/** The plugin rows of a single-preset patch file, as written. */
function presetPlugins(file) {
const [patch] = yaml.load(readFileSync(file, 'utf8'), { schema: PRESET_SCHEMA })
// The facet preset is an insert; the optional overlay overrides the shipped
// row by id and carries the full config instead.
const declaration = patch.insert === undefined ? patch : patch.insert[0]
return declaration.config.plugins
}
/** Drop absent keys, so a missing field and an undefined field compare the same. */
function normalizedRows(rows) {
return rows.map((row) => ({
id: row.id,
name: row.name,
...(row.disabled === undefined ? {} : { disabled: row.disabled }),
...(row.group === true ? { group: true } : {}),
...(row.isolate === undefined ? {} : { isolate: row.isolate }),
...(row.config === undefined ? {} : { config: Array.isArray(row.config) ? normalizedRows(row.config) : row.config }),
}))
}
/** One row by id, at any depth. */
function rowById(rows, id) {
for (const row of rows) {
if (row.id === id) return row
if (Array.isArray(row.config)) {
const found = rowById(row.config, id)
if (found !== undefined) return found
}
}
return undefined
}
/** A copy with the bundle's compaction budget removed, so everything else can be compared. */
function withoutCompactionBudget(rows) {
const copy = structuredClone(rows)
const strip = (list) => {
for (const row of list) {
if (row.id === 'compaction-basic') delete row.config
if (Array.isArray(row.config)) strip(row.config)
}
}
strip(copy)
return copy
}
/** The only settings either file adds to a `standard` row. */
const COMPACTION_BUDGET = { thresholdRatio: 0.35, retainTokens: 80000, maxTokens: 16384 }
test('the facet preset is the shipped standard composition plus its documented changes', { skip: SKIP_DRIFT }, () => {
const standard = normalizedRows(presetPlugins(STANDARD_PRESET))
const facet = normalizedRows(presetPlugins(FACET_PRESET))
const guard = facet.filter((row) => row.id === 'facet-guard')
assert.deepEqual(guard, [{ id: 'facet-guard', name: 'dsh-facet/guard' }], 'the facet preset mounts facet-guard exactly once')
const withoutGuard = facet.filter((row) => row.id !== 'facet-guard')
assert.deepEqual(
withoutCompactionBudget(withoutGuard),
withoutCompactionBudget(standard),
'presets/facet.patch.yml has drifted from the shipped standard composition; re-copy it from the harness and re-apply only the guard and the compaction budget',
)
assert.deepEqual(
rowById(withoutGuard, 'compaction-basic')?.config,
COMPACTION_BUDGET,
'the facet preset keeps its compaction budget',
)
})
test('the standard-compaction overlay is the shipped standard composition plus the compaction budget', { skip: SKIP_DRIFT }, () => {
const standard = normalizedRows(presetPlugins(STANDARD_PRESET))
const overlay = normalizedRows(presetPlugins(COMPACTION_PRESET))
assert.deepEqual(
rowById(overlay, 'compaction-basic')?.config,
COMPACTION_BUDGET,
'the optional overlay configures the compaction budget',
)
assert.deepEqual(
withoutCompactionBudget(overlay),
withoutCompactionBudget(standard),
'presets/standard-compaction.patch.yml has drifted from the shipped standard composition; re-copy it from the harness and re-apply only the compaction budget',
)
})
test(
'the standard-compaction overlay replaces the shipped preset instead of adding a second declaration',
{ skip: SKIP_DRIFT },
async (t) => {
if (APP_BOOT === undefined) return t.skip('the harness app-boot package was not found in any scope')
// Compose the way the launcher does: the shipped declaration first, then the
// overlay. A second declaration carrying the same preset id would register
// in the wrong order and lose — which is how this overlay used to do nothing.
const { composeEntries } = await import(pathToFileURL(APP_BOOT).href)
const standardPatch = yaml.load(readFileSync(STANDARD_PRESET, 'utf8'), { schema: PRESET_SCHEMA })
const overlayPatch = yaml.load(readFileSync(COMPACTION_PRESET, 'utf8'), { schema: PRESET_SCHEMA })
const warnings = []
const entries = composeEntries([standardPatch, overlayPatch], (message) => warnings.push(message))
assert.deepEqual(warnings, [], 'the overlay applies without a skipped patch')
const declarations = entries.filter((entry) => entry.id === 'preset-standard')
assert.equal(
declarations.length,
1,
'the overlay overrides the row; a second declaration would be ignored by the registry',
)
assert.deepEqual(
rowById(declarations[0].config.plugins, 'compaction-basic')?.config,
COMPACTION_BUDGET,
'the applied overlay carries the compaction budget',
)
},
)
/** Every row's id and module specifier, groups included. */
function namedRows(rows) {
return rows.flatMap((row) => [
{ id: row.id, name: row.name },
...(Array.isArray(row.config) ? namedRows(row.config) : []),
])
}
test('every plugin a shipped preset names resolves against the installed harness', { skip: SKIP_DRIFT }, () => {
// Anchoring inside a scope makes Node look in that scope's own node_modules:
// its parent directory carries the scope as a `node_modules` entry, which is
// exactly the lookup the profile uses. Several scopes are tried because a
// legacy `profiles/node_modules` mirror is only a snapshot of the installation.
const harnessResolvers = HARNESS_SCOPES.map((scope) => createRequire(join(scope, 'noop.mjs')))
const fromPlugin = createRequire(join(PACKAGE_ROOT, 'package.json'))
const unresolved = []
for (const file of [FACET_PRESET, COMPACTION_PRESET]) {
for (const { id, name } of namedRows(presetPlugins(file))) {
// `cordis:group` is a loader builtin rather than an installed package.
if (name === 'cordis:group') continue
const resolvers = name === 'dsh-facet/guard' ? [fromPlugin] : harnessResolvers
let failure
const resolved = resolvers.some((resolver) => {
try {
resolver.resolve(name)
return true
} catch (error) {
failure = error
return false
}
})
if (!resolved) unresolved.push(`${file.split('/').pop()}: ${id} (${name}): ${failure?.code ?? failure?.message}`)
}
}
assert.deepEqual(
unresolved,
[],
'a preset names a plugin or subpath the harness no longer provides; re-copy the preset from the shipped standard',
)
})
+27
View File
@@ -40,6 +40,31 @@ test('pathArgumentsFor has no opinion where it cannot have one', () => {
assert.deepEqual(pathArgumentsFor('grep', { path: { nested: '/etc' } }), []) assert.deepEqual(pathArgumentsFor('grep', { path: { nested: '/etc' } }), [])
}) })
test('a shadowed tool is judged by the arguments its own schema declares', () => {
// `dsh-better-edit` replaces read/edit on the agent's layer with different
// argument names; trusting the built-in's `file_path` left the busiest read
// tool unguarded.
assert.deepEqual(pathArgumentsFor('read', { path: 'src/a.ts', limit: 10 }, ['path', 'limit']), ['src/a.ts'])
assert.deepEqual(pathArgumentsFor('edit', { file: 'src/a.ts', edits: [] }, ['file', 'edits']), ['src/a.ts'])
// A declared path-shaped name the table does not list is still found.
assert.deepEqual(pathArgumentsFor('write', { path: 'src/a.ts', content: 'x' }, ['path', 'content']), ['src/a.ts'])
// The table is the fallback when the schema cannot be read.
assert.deepEqual(pathArgumentsFor('read', { path: 'src/a.ts' }), ['src/a.ts'])
})
test('the tools that move the scope are judged like any other path', () => {
assert.deepEqual(pathArgumentsFor('working_directory', { cd: '../elsewhere' }, ['cd']), ['../elsewhere'])
assert.deepEqual(
pathArgumentsFor('subagent', { cwd: '../elsewhere', prompt: 'x' }, ['cwd', 'prompt']),
['../elsewhere'],
)
assert.deepEqual(pathArgumentsFor('subagent_fork', { cwd: 'sub', prompt: 'x' }, ['cwd', 'prompt']), ['sub'])
// Reading the directory names nothing, and moves nothing.
assert.deepEqual(pathArgumentsFor('working_directory', {}, ['cd']), [])
// The undo tool writes a file back, so it is a path like any other.
assert.deepEqual(pathArgumentsFor('undo_last_edit', { path: 'src/a.ts' }), ['src/a.ts'])
})
test('isWideningCall is true only for the one act that needs the user', () => { test('isWideningCall is true only for the one act that needs the user', () => {
assert.equal(isWideningCall('facet', { action: 'add', paths: ['x'] }), true) assert.equal(isWideningCall('facet', { action: 'add', paths: ['x'] }), true)
// Narrowing and reading cannot show the agent anything new. // Narrowing and reading cannot show the agent anything new.
@@ -74,6 +99,7 @@ test('facetContextText carries the binding that does change', () => {
assert.equal( assert.equal(
ask, ask,
'facet: /w/src/room\n' + 'facet: /w/src/room\n' +
'session folder: /w — relative paths in tool calls resolve here\n' +
'outside the facet: put to the user as a question — say in one line what you need and why, then record it with `facet action=add` so the rest of the session does not have to ask again', 'outside the facet: put to the user as a question — say in one line what you need and why, then record it with `facet action=add` so the rest of the session does not have to ask again',
) )
@@ -81,6 +107,7 @@ test('facetContextText carries the binding that does change', () => {
assert.equal( assert.equal(
deny, deny,
'facet: /w/src/room\n' + 'facet: /w/src/room\n' +
'session folder: /w — relative paths in tool calls resolve here\n' +
'granted outside it: src/shared\n' + 'granted outside it: src/shared\n' +
'outside the facet: refused — ask the user to widen the facet from its context panel, or with `facet action=add` where that can be granted', 'outside the facet: refused — ask the user to widen the facet from its context panel, or with `facet action=add` where that can be granted',
) )