Skip to content

Commit 49c6e6b

Browse files
committed
fix(mantis): shadow proxy records from the candidate container
The SUT container bind-mounts the whole runtime read-write as the mantis-sut UID, which included proxy-control/ — the trusted Bot API fault rules and recorded request facts the proxy container writes. Untrusted candidate code could rewrite its own evidence before finish published it. An inaccessible tmpfs now shadows proxy-control inside the SUT container (cap-drop ALL prevents unmounting), and the prompt no longer presents SUT-co-located provider request logs as standalone comparison evidence.
1 parent 7254b65 commit 49c6e6b

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

‎.github/codex/prompts/mantis-recipes/busy-queue-scripted-provider.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ $lane requests --lane baseline
2727
$lane finish --lane baseline
2828
```
2929

30-
Repeat for `candidate`. Proof facts: provider request log `scriptEntry` values
31-
show entries 0 then 1; request bodies preserve turn order; session events show
32-
the slow first and distinct second outcomes without a control-file race.
30+
Repeat for `candidate`. Proof facts: session events and recorded Bot API
31+
messages show the slow first and distinct second outcomes without a
32+
control-file race. The provider request log (`scriptEntry` 0 then 1, turn
33+
order in bodies) is diagnostic context, not the comparison evidence.

‎.github/codex/prompts/mantis-telegram-desktop-proof.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,10 @@ Use the same scenario inputs in both lanes; only the SUT revision changes. A
115115
baseline lane that reproduces the defect is a successful capture. A PR-level
116116
pass claim requires an observed, material baseline/candidate difference caused
117117
by the changed behavior. That difference may be trusted Bot API payload/status
118-
facts or provider request count/order even when pixels are identical; screenshots
119-
remain comparison context. Identical pixels alone do not force `block` when those
120-
recorded facts differ materially. If neither pixels nor trusted facts prove a
118+
facts even when pixels are identical; screenshots remain comparison context.
119+
Provider request logs are diagnostic and pacing signals, not standalone
120+
comparison evidence. Identical pixels alone do not force `block` when the
121+
trusted recorded facts differ materially. If neither pixels nor trusted facts prove a
121122
difference, use `block`. When the expected result is silence, focus the
122123
session-owned user message that triggered the silent outcome.
123124
Decide before finalizing each lane. If its setup did not exercise the intended

‎scripts/mantis/mantis-sut-container.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,11 +904,16 @@ case "$command" in
904904
"$image" node /opt/mantis/telegram-bot-api-proxy.mjs >/dev/null
905905
"$docker_bin" network connect --alias telegram-api-proxy "$network_name" "$proxy_container_name"
906906
require_runtime_claim_active "$container_name"
907+
# proxy-control holds the proxy's fault rules and recorded Bot API facts.
908+
# The SUT runs untrusted candidate code as the same mantis-sut UID, so an
909+
# inaccessible tmpfs must shadow the directory inside the runtime mount;
910+
# without it the lane under test could rewrite its own trusted evidence.
907911
"$docker_bin" run --rm --init --name "$container_name" --network "$network_name" \
908912
"${container_security_args[@]}" "${runtime_resource_args[@]}" \
909913
--mount "type=bind,src=$repo_root,dst=$repo_root,readonly" \
910914
--mount "type=bind,src=$mock_server_script,dst=/opt/mantis/mock-openai-server.mjs,readonly" \
911915
--mount "type=bind,src=$safe_runtime,dst=$runtime_source" \
916+
--mount "type=tmpfs,dst=$runtime_source/proxy-control,tmpfs-size=65536,tmpfs-mode=0000" \
912917
--workdir "$repo_root" \
913918
--user "$(id -u mantis-sut):$(id -g mantis-sut)" \
914919
"${docker_env[@]}" \

‎test/scripts/mantis-telegram-desktop-proof-workflow.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,15 @@ describe("Mantis Telegram Desktop proof workflow", () => {
11281128
expect(wrapper).toContain(
11291129
"--env TELEGRAM_PROXY_RECORD_FILE=/opt/mantis/proxy-control/requests.ndjson",
11301130
);
1131+
// Candidate code shares the mantis-sut UID with the proxy record sink, so
1132+
// the SUT container must shadow proxy-control; otherwise the lane under
1133+
// test could rewrite its own trusted Bot API evidence before publication.
1134+
const proxyControlShadow =
1135+
'--mount "type=tmpfs,dst=$runtime_source/proxy-control,tmpfs-size=65536,tmpfs-mode=0000"';
1136+
expect(wrapper).toContain(proxyControlShadow);
1137+
expect(wrapper.indexOf(proxyControlShadow)).toBeGreaterThan(
1138+
wrapper.indexOf('--mount "type=bind,src=$safe_runtime,dst=$runtime_source"'),
1139+
);
11311140
expect(wrapper).toContain('export TELEGRAM_BOT_TOKEN="$telegram_alias_token"');
11321141
expect(wrapper).not.toContain('export TELEGRAM_BOT_TOKEN="$telegram_bot_token"');
11331142
expect(wrapper).toContain('remove_container_or_fail "${1}-telegram-proxy"');

0 commit comments

Comments
 (0)