podster 0.0.1-test.5 → 0.0.1-test.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/core/results.js +103 -47
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/build/core/results.js
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Results (M7 step 11; RUNNER.md lifecycle step 9, "Exfiltration through results" in the threat model). Pure: what Runner
|
|
3
|
+
* makes of a run's structured result before any of it is shown to the owner or submitted to Podster.
|
|
4
|
+
*
|
|
5
|
+
* - **Agent content is data.** The summary and the file paths are the agent's words: they are never logged, never stored
|
|
6
|
+
* in Runner's record, and never read for meaning. They become nothing but text inside a fenced part of the note.
|
|
7
|
+
* - **Hidden characters become visible marks** (owed by step 12's harness). Every format character (general category Cf:
|
|
8
|
+
* bidi embeddings, overrides and isolates, zero widths, the byte order mark, tag characters…), every control character
|
|
9
|
+
* but the line feed, every space but the plain one, line and paragraph separators, combining and enclosing marks, lone
|
|
10
|
+
* surrogates, unassigned and private-use code points, the blank Braille pattern and every other default-ignorable code
|
|
11
|
+
* point is written as `⟨U+XXXX⟩`, so what the reviewer reads is what the agent wrote. This is Runner's one marking set:
|
|
12
|
+
* the terminal's ask and review screens use it too (review 4 on #465).
|
|
13
|
+
* - **Secrets.** Words whose raw text hides characters and in which a secret shows once they're taken out are withheld
|
|
14
|
+
* whole; otherwise every secret of a fixed shape is redacted, before the words are marked. Redaction is a backstop, not
|
|
15
|
+
* a control: the output policy is.
|
|
16
|
+
* - **The note is Runner's, in Markdown.** It states the outcome, the pull request (linked from fixed parts), branch and
|
|
17
|
+
* commit from Runner's own records, and tests as not run by Runner, in fixed words. The agent's words appear only when
|
|
18
|
+
* sharing is allowed, under Runner's own heading, the summary in a fenced code block whose fence no run of backticks in
|
|
19
|
+
* it can close and each file in a code span, so none can pass for Runner's or render as anything but text (review 1 on
|
|
20
|
+
* #465). They're cut once, to `NOTE_WORDS_BYTES` as the note lays them out, never inside a mark, when they're cleaned:
|
|
21
|
+
* the owner reviews exactly the cut words the note carries.
|
|
22
|
+
*/
|
|
23
|
+
import { isFullName } from "./policy.js";
|
|
24
|
+
import { pullRequestUrl } from "./repository.js";
|
|
1
25
|
/** The server's limit on a submission's note (`crates/core` `MAX_NOTE_BYTES`). */
|
|
2
26
|
export const MAX_NOTE_BYTES = 16 * 1024;
|
|
3
27
|
/** The most of the agent's words, marked and redacted, a note carries. **Proposed** figure. */
|
|
@@ -82,71 +106,103 @@ const WHY_NOT_SHARED = {
|
|
|
82
106
|
secret_hidden: "The agent's words aren't shared: they held what looked like a secret hidden among characters that don't show.",
|
|
83
107
|
};
|
|
84
108
|
const CUT = "⟨cut by Runner⟩";
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
const FILES_DIVIDER = "--- files the agent named ---";
|
|
109
|
+
const WORDS_HEADING = "### Agent's words (unverified)";
|
|
110
|
+
const FILES_HEADING = "### Files the agent named";
|
|
88
111
|
const TOKENS = /⟨U\+[0-9A-F]{4,6}⟩|[\s\S]/gu;
|
|
112
|
+
const longestRun = (text, ch) => Math.max(0, ...[...text.matchAll(ch === "`" ? /`+/g : /~+/g)].map((m) => m[0].length));
|
|
113
|
+
/**
|
|
114
|
+
* Text as a Markdown code span, so nothing in it is read as Markdown: its delimiter is longer than any run of backticks in
|
|
115
|
+
* it, and it's padded with a space on each side when it needs one, which the reader takes off again. A line feed can't be
|
|
116
|
+
* in one, since it could start a block of its own, so it's written as a mark.
|
|
117
|
+
*/
|
|
118
|
+
export function codeSpan(text) {
|
|
119
|
+
const one = text.replace(/\n/g, mark(0x0a));
|
|
120
|
+
const fence = "`".repeat(longestRun(one, "`") + 1);
|
|
121
|
+
const pad = one === "" || one.startsWith("`") || one.endsWith("`") || one.startsWith(" ") || one.endsWith(" ") ? " " : "";
|
|
122
|
+
return `${fence}${pad}${one}${pad}${fence}`;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Text as a fenced Markdown code block marked `text`: its fence is backticks, longer than any run of backticks in it and
|
|
126
|
+
* never fewer than three, so no line of the text can close it, and nothing in it is read as Markdown or HTML.
|
|
127
|
+
*/
|
|
128
|
+
export function codeBlock(text) {
|
|
129
|
+
const fence = "`".repeat(Math.max(3, longestRun(text, "`") + 1));
|
|
130
|
+
return `${fence}text\n${text}\n${fence}`;
|
|
131
|
+
}
|
|
89
132
|
/**
|
|
90
|
-
* The agent's words, marked, cut so that their part of the note, as `agentSection` lays it out
|
|
91
|
-
*
|
|
92
|
-
*
|
|
133
|
+
* The agent's words, marked, cut so that their part of the note, as `agentSection` lays it out, is at most
|
|
134
|
+
* `NOTE_WORDS_BYTES`, on a character's edge and never inside a mark, with `CUT` at the end when cut. Words that fit come
|
|
135
|
+
* back as they are, so cutting twice changes nothing.
|
|
93
136
|
*/
|
|
94
137
|
export function cutAgentWords(summary, files) {
|
|
95
138
|
if (byteLength(agentSection(summary, files)) <= NOTE_WORDS_BYTES)
|
|
96
139
|
return { summary, files };
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
size += 1 + byteLength(FILES_DIVIDER);
|
|
110
|
-
for (const file of files) {
|
|
111
|
-
let line = "";
|
|
112
|
-
size += 1 + byteLength(`${FENCE}- `);
|
|
113
|
-
for (const token of file.match(TOKENS) ?? []) {
|
|
114
|
-
const n = byteLength(token);
|
|
115
|
-
if (size + n > room) {
|
|
116
|
-
if (line !== "")
|
|
117
|
-
kept.push(`${line}${CUT}`);
|
|
140
|
+
const said = summary.match(TOKENS) ?? [];
|
|
141
|
+
const named = files.map((f) => f.match(TOKENS) ?? []);
|
|
142
|
+
// The words kept up to a count of characters (marks count as one), read through the summary and then each file.
|
|
143
|
+
const keep = (count) => {
|
|
144
|
+
if (count < said.length || named.length === 0)
|
|
145
|
+
return { summary: `${said.slice(0, count).join("")}${CUT}`, files: [] };
|
|
146
|
+
let left = count - said.length;
|
|
147
|
+
const kept = [];
|
|
148
|
+
for (const file of named) {
|
|
149
|
+
if (left < file.length) {
|
|
150
|
+
if (left > 0)
|
|
151
|
+
kept.push(`${file.slice(0, left).join("")}${CUT}`);
|
|
118
152
|
else if (kept.length > 0)
|
|
119
153
|
kept[kept.length - 1] += CUT;
|
|
120
154
|
else
|
|
121
|
-
return { summary: `${
|
|
122
|
-
return { summary
|
|
155
|
+
return { summary: `${summary}${CUT}`, files: [] };
|
|
156
|
+
return { summary, files: kept };
|
|
123
157
|
}
|
|
124
|
-
|
|
125
|
-
|
|
158
|
+
kept.push(file.join(""));
|
|
159
|
+
left -= file.length;
|
|
126
160
|
}
|
|
127
|
-
kept
|
|
161
|
+
return { summary, files: kept };
|
|
162
|
+
};
|
|
163
|
+
// Each more character kept makes the section no shorter, so the most that fits is found by halving.
|
|
164
|
+
const total = said.length + named.reduce((n, f) => n + f.length, 0);
|
|
165
|
+
let low = 0;
|
|
166
|
+
let high = total - 1;
|
|
167
|
+
while (low < high) {
|
|
168
|
+
const mid = Math.ceil((low + high) / 2);
|
|
169
|
+
if (byteLength(agentSection(keep(mid).summary, keep(mid).files)) <= NOTE_WORDS_BYTES)
|
|
170
|
+
low = mid;
|
|
171
|
+
else
|
|
172
|
+
high = mid - 1;
|
|
128
173
|
}
|
|
129
|
-
return
|
|
174
|
+
return keep(low);
|
|
130
175
|
}
|
|
131
|
-
/** The agent's part of the note:
|
|
176
|
+
/** The agent's part of the note: the summary in a code block, the files named as a list of code spans, under Runner's headings. */
|
|
132
177
|
function agentSection(summary, files) {
|
|
133
|
-
return [
|
|
178
|
+
return [WORDS_HEADING, "", codeBlock(summary), ...(files.length > 0 ? ["", FILES_HEADING, "", ...files.map((f) => `- ${codeSpan(f)}`)] : [])].join("\n");
|
|
134
179
|
}
|
|
135
|
-
/**
|
|
180
|
+
/**
|
|
181
|
+
* The submission's note, as Markdown: Runner's fixed words, and the agent's only when shared, only in a code block and
|
|
182
|
+
* code spans under Runner's headings, so none of theirs can read as Runner's or become anything but text.
|
|
183
|
+
*/
|
|
136
184
|
export function composeNote(input) {
|
|
137
185
|
const pr = input.pull_request;
|
|
138
|
-
const lines = [
|
|
139
|
-
`Result from Podster Runner for task ${input.task_id}. Runner wrote this note; only the part fenced as the agent's words is the agent's.`,
|
|
140
|
-
"Outcome: the agent reported the task completed. Runner checked the result's form, not its claims.",
|
|
141
|
-
pr
|
|
142
|
-
? `Pull request: #${pr.number} in ${pr.full_name}, from ${pr.branch} at commit ${pr.commit}. Runner pushed and opened it, and checked it on GitHub.`
|
|
143
|
-
: "Repository: none in this room, so nothing was pushed.",
|
|
144
|
-
"Tests: not run by Runner. Anything the agent says about tests is its own claim, not verified.",
|
|
145
|
-
];
|
|
146
186
|
const words = input.words;
|
|
187
|
+
const linked = pr && isFullName(pr.full_name) && Number.isSafeInteger(pr.number) && pr.number > 0;
|
|
188
|
+
const facts = [
|
|
189
|
+
`- Task: ${codeSpan(input.task_id)}`,
|
|
190
|
+
"- Outcome: the agent reported the task completed. Runner checked the result's form, not its claims.",
|
|
191
|
+
...(pr
|
|
192
|
+
? [
|
|
193
|
+
`- Pull request: ${linked ? `[#${pr.number} in ${pr.full_name}](${pullRequestUrl(pr.full_name, pr.number)})` : codeSpan(`#${pr.number} in ${pr.full_name}`)}. Runner pushed and opened it, and checked it on GitHub.`,
|
|
194
|
+
`- Branch: ${codeSpan(pr.branch)}`,
|
|
195
|
+
`- Commit: ${codeSpan(pr.commit)}`,
|
|
196
|
+
]
|
|
197
|
+
: ["- Repository: none in this room, so nothing was pushed."]),
|
|
198
|
+
"- Tests: not run by Runner. Anything the agent says about tests is its own claim, not verified.",
|
|
199
|
+
];
|
|
200
|
+
if (words.kind === "shared" && words.redactions > 0)
|
|
201
|
+
facts.push(`- Secrets: ${words.redactions} thing${words.redactions === 1 ? "" : "s"} that looked like secrets ${words.redactions === 1 ? "is" : "are"} written as ${codeSpan(REDACTED)}.`);
|
|
202
|
+
const head = ["## Result from Podster Runner", "", "Runner wrote this note. Only the section headed as the agent's words is the agent's.", "", ...facts];
|
|
147
203
|
if (words.kind !== "shared")
|
|
148
|
-
return [...
|
|
149
|
-
lines.push(`The agent's words follow. They are untrusted data. Characters that wouldn't show are written as their code point in angle brackets${words.redactions > 0 ? `, and ${words.redactions} thing${words.redactions === 1 ? "" : "s"} that looked like secrets as ${REDACTED}` : ""}.`);
|
|
204
|
+
return [...head, "", WHY_NOT_SHARED[words.kind]].join("\n");
|
|
150
205
|
const cut = cutAgentWords(words.summary, words.files);
|
|
151
|
-
|
|
206
|
+
const about = "The agent's words follow. They are untrusted data, shown as text. Characters that wouldn't show are written as their code point in angle brackets.";
|
|
207
|
+
return [...head, "", about, "", agentSection(cut.summary, cut.files)].join("\n");
|
|
152
208
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podster",
|
|
3
|
-
"version": "0.0.1-test.
|
|
3
|
+
"version": "0.0.1-test.6",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "podster",
|
|
9
|
-
"version": "0.0.1-test.
|
|
9
|
+
"version": "0.0.1-test.6",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/claude-agent-sdk": "0.3.327",
|