fix(pi): pi-unpin S3 re-check: the control counts a kind only through a source the sealed runs can show, so a SYSTEM.md no longer stands in for the project APPEND_SYSTEM.md or an AGENTS.md (#1873)
This commit is contained in:
1 parent
df26085303
commit
2613fb1c4c
4 files changed
+27
-9
No files matched your search
@@ -33,7 +33,8 @@ empty environment and a scratch home, and calls no model. It needs
|
||||
`--help` to list, in its option column, every flag the adapter passes
|
||||
(with rpc mode and each thinking level), and a missing `-e` file to stop
|
||||
the start in rpc and in `-p`. The planted ambient sources must stay
|
||||
unloaded with the seal flags on, in rpc and in `-p`: extensions, MCP
|
||||
unloaded with the seal flags on (skills and prompt templates are read
|
||||
from `get_commands`, so in rpc only; the rest in rpc and in `-p`): extensions, MCP
|
||||
servers, skills and prompt templates (found in their directories, listed
|
||||
in a `settings.json`, or in a local package a `settings.json` lists),
|
||||
context files (`AGENTS.md`, `CLAUDE.md`, `SYSTEM.md`) and a trusted
|
||||
@@ -43,7 +44,10 @@ extension writes the system prompt it sees at `session_start`; the
|
||||
sealed runs must show the `--system-prompt` file and none of the planted
|
||||
files. A control run without the seal flags must show each kind of
|
||||
source (an MCP server only when `--help` lists `--no-mcp`) and answer
|
||||
`get_state` and `get_commands`, or the check can't tell and refuses. Pi
|
||||
`get_state` and `get_commands`, or the check can't tell and refuses. A
|
||||
`SYSTEM.md` doesn't count for its kind there, since the sealed runs'
|
||||
`--system-prompt` replaces it: the control must show an `AGENTS.md` or
|
||||
`CLAUDE.md` and the project's `.pi/APPEND_SYSTEM.md`. Pi
|
||||
0.85.1 appends the agent directory's `APPEND_SYSTEM.md` whatever the
|
||||
flags, so the check doesn't plant one. Any failure refuses the launch with
|
||||
`harness-feature-missing` and one line that names the binary by its label,
|
||||
|
||||
@@ -9,14 +9,18 @@
|
||||
// control rpc, planted ambient sources, a saved trust for the project, no seal flags and
|
||||
// one -e extension that writes the system prompt it sees at session_start. The
|
||||
// binary answers get_state and get_commands, and shows each kind of planted source:
|
||||
// an extension, a skill, a prompt template, a context file, a trusted project file
|
||||
// (the trust --no-approve must undo), and an MCP server when --help lists --no-mcp.
|
||||
// A kind it doesn't show could not be told apart from a sealed one.
|
||||
// an extension, a skill, a prompt template, a context file (AGENTS.md or CLAUDE.md),
|
||||
// a trusted project file (the project's .pi/APPEND_SYSTEM.md, which only the trust
|
||||
// --no-approve must undo lets in), and an MCP server when --help lists --no-mcp. A
|
||||
// SYSTEM.md doesn't count, since the sealed runs' --system-prompt replaces it. A kind
|
||||
// it doesn't show could not be told apart from a sealed one.
|
||||
// sealed rpc the adapter's seal flags (and --no-mcp when --help lists it), the -e extension and
|
||||
// --system-prompt. The binary answers both, loads that extension (a session's gate
|
||||
// comes in that way), uses the --system-prompt file, and shows no planted source.
|
||||
// sealed -p the same in -p, the mode the adapter runs. Its -e extension must reach
|
||||
// session_start, and no planted source may show.
|
||||
// session_start, and no planted extension, MCP server, context file or trusted
|
||||
// project file may show. -p answers no get_commands, so skills and prompt templates
|
||||
// are checked in rpc only.
|
||||
// missing -e a missing -e file, in rpc and in -p, stops the start: exit non-zero, no answer,
|
||||
// and no session_start for the -e extension given after it
|
||||
//
|
||||
@@ -102,7 +106,9 @@ function check(found, { levels, bwrap, node, scratch, who, digest }) {
|
||||
if (!controlAnswer.state) return refuse("can't be checked: it didn't answer get_state");
|
||||
if (!controlAnswer.commands) return refuse("can't be checked: it didn't answer get_commands");
|
||||
if (!marked(scratch, EXPLICIT) || prompted(scratch) === null) return refuse("can't be checked: its -e extension didn't see the system prompt without the seal flags");
|
||||
const shown = new Set(seen(scratch, controlAnswer).map((s) => s.kind));
|
||||
// A kind counts only through a source the sealed runs could show: they pass --system-prompt,
|
||||
// which replaces a SYSTEM.md, so a SYSTEM.md seen here proves nothing about the seal.
|
||||
const shown = new Set(seen(scratch, controlAnswer).filter((s) => !REPLACED.has(s.source)).map((s) => s.kind));
|
||||
const unshown = KINDS.filter((k) => (k !== "MCP server" || noMcp) && !shown.has(k));
|
||||
if (unshown.length) return refuse(`can't be checked: it didn't load a planted ${unshown.join(", ")} without the seal flags`);
|
||||
|
||||
@@ -220,6 +226,9 @@ const TEXTS = [
|
||||
["project/CLAUDE.md", "FITPROJECTCLAUDE", "project CLAUDE.md", "context file"],
|
||||
["CLAUDE.md", "FITPARENTCLAUDE", "parent CLAUDE.md", "context file"],
|
||||
];
|
||||
// Sources the sealed runs' --system-prompt replaces. They stay planted, so a leak still refuses,
|
||||
// but the control doesn't count them toward their kind.
|
||||
const REPLACED = new Set(["user SYSTEM.md", "project SYSTEM.md"]);
|
||||
// The --system-prompt file's word, which the sealed runs must show.
|
||||
const GIVEN = "FITGIVENPROMPT";
|
||||
// The -e extension the control and sealed runs pass, which must load.
|
||||
|
||||
@@ -114,6 +114,10 @@ test("pi-unpin S3 review: a get_commands answer that fails or changes shape is r
|
||||
|
||||
// Review finding 2: the sealed runs read the system prompt through the -e extension, so a pi that
|
||||
// drops the --system-prompt file, or never runs session_start in -p, can't pass.
|
||||
test("pi-unpin S3 re-check: a project SYSTEM.md doesn't stand in for the APPEND_SYSTEM.md the control must show, so a trust leak the sealed runs can't see is can't tell", SKIP, t => {
|
||||
assert.equal(fit(standIn(t, { ignoreAppend: true, sealLeak: ["approve"] }).env).message, "pi 2.0.0 (MOSAIC_PI_BIN) can't be checked: it didn't load a planted trusted project file without the seal flags");
|
||||
});
|
||||
|
||||
test("pi-unpin S3 review: a stand-in that drops the --system-prompt file, or runs no session_start in -p, is refused", SKIP, t => {
|
||||
assert.equal(fit(standIn(t, { ignoreSystemPrompt: true }).env).message, "pi 2.0.0 (MOSAIC_PI_BIN) didn't use the --system-prompt file with the seal flags on");
|
||||
assert.equal(fit(standIn(t, { printNoStart: true }).env).message, "pi 2.0.0 (MOSAIC_PI_BIN) can't be checked: a -p start with the seal flags didn't run its -e extension");
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
// session_start.
|
||||
// `ignoreAll` loads no planted source. `sealLeak` lists kinds (extensions, mcp,
|
||||
// skills, prompts, context, approve) loaded even when their seal flag is on.
|
||||
// `ignoreSystemPrompt` drops the --system-prompt file. `commands` "fail" answers
|
||||
// `ignoreSystemPrompt` drops the --system-prompt file. `ignoreAppend` drops every
|
||||
// APPEND_SYSTEM.md. `commands` "fail" answers
|
||||
// get_commands with success false; "list" answers with a bare list.
|
||||
// otherwise a session with no $ARGV_OUT: prints `sessionOut` and exits 0.
|
||||
//
|
||||
@@ -111,7 +112,7 @@ if (rpc || print) {
|
||||
// context files, from the agent directory and from / down to the working directory.
|
||||
const given = K.ignoreSystemPrompt ? null : val("--system-prompt");
|
||||
const own = (name) => (trusted && read(path.join(cwd, ".pi", name))) || (!K.ignoreAll && read(path.join(agent, name))) || "";
|
||||
const parts = [given ? (read(given) || "") : own("SYSTEM.md"), own("APPEND_SYSTEM.md")];
|
||||
const parts = [given ? (read(given) || "") : own("SYSTEM.md"), K.ignoreAppend ? "" : own("APPEND_SYSTEM.md")];
|
||||
if (!K.ignoreAll && (!has("--no-context-files") || leak.has("context"))) {
|
||||
const dirs = [];
|
||||
for (let d = cwd; ; d = path.dirname(d)) { dirs.unshift(d); if (path.dirname(d) === d) break; }
|
||||
|
||||
Reference in new issue
Block a user