obs(07): native-plugin fail-closed, value/trace privacy test and final gate evidence
This commit is contained in:
1 parent
2d51f08340
commit
1d3dca7c18
9 files changed
+189
-5
No files matched your search
+1
-1
@@ -83,7 +83,7 @@ portable/tested locally but the native platform lane has not run here;
|
||||
| Capability handler registry (`fs.read` handler, audit, unavailable) | PASS | UNVERIFIED | UNVERIFIED |
|
||||
| External conformance repository (`marqdo-extension-conformance`, frozen CLI) | PASS (`--release` binary sha256 `28e3776d…`, fixture repo `e4b7352c…`; see `docs/evidence/extension/6a7bb983.../manifest.json`) | UNVERIFIED | UNVERIFIED |
|
||||
| Analysis v2 / Trace v2 + Python consumers | PASS | UNVERIFIED | UNVERIFIED |
|
||||
| Execution Events v1 (`--event-stream jsonl`, P0/P1) | PASS locally (12 CLI contract tests + 8 host + 4 runtime; independent Python schema consumer); post-beta, not in the tagged archive | UNVERIFIED | UNVERIFIED |
|
||||
| Execution Events v1 (`--event-stream jsonl`, P0/P1) | PASS locally (14 CLI contract tests + 8 host + 4 runtime; independent Python schema consumer); post-beta, not in the tagged archive | UNVERIFIED | UNVERIFIED |
|
||||
| Tool Protocol v1 + 3 independent consumers | PASS | UNVERIFIED | UNVERIFIED |
|
||||
| Native ABI (`plugin inspect`, trusted call) | PASS (C fixture) | UNVERIFIED (host-native fixture) | **UNSUPPORTED** |
|
||||
| Worker ABI + `fs.read` bridge | PASS (Unix) | UNVERIFIED | **UNSUPPORTED** (Unix-gated) |
|
||||
|
||||
@@ -333,6 +333,26 @@ pub fn execute(
|
||||
return fail_prepare(stream, json, command_name, "authorization", &error);
|
||||
}
|
||||
}
|
||||
// A native plugin shares this process and can write fd 1 directly, so it
|
||||
// can pollute the JSONL channel. Fail closed rather than presenting
|
||||
// untrusted raw bytes as program stdout (RFC-OBS-0001 §4.4/§9.2, T26).
|
||||
if stream.is_some()
|
||||
&& static_plugins
|
||||
.plugins
|
||||
.iter()
|
||||
.any(|plugin| plugin.kind == marqdo_plugin_abi::PluginKind::Native)
|
||||
{
|
||||
return fail(
|
||||
stream,
|
||||
json,
|
||||
command_name,
|
||||
"authorization",
|
||||
"ext.event_stream_unsupported_native_plugin",
|
||||
"--event-stream jsonl cannot guarantee a clean channel with an in-process native \
|
||||
plugin; use a worker plugin or disable event mode",
|
||||
2,
|
||||
);
|
||||
}
|
||||
// T7: start only selected, granted and verified extensions.
|
||||
for plugin in &static_plugins.plugins {
|
||||
if let Err(message) = load_plugin_into_host(
|
||||
|
||||
@@ -266,6 +266,87 @@ fn structure_fixture_attributes_repeated_recursive_frames() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_plugin_is_fail_closed_in_event_mode() {
|
||||
use sha2::Digest;
|
||||
let dir = TempDir::new("native-plugin");
|
||||
dir.write("index.mq.md", "## @exec main\n\n`return 1`\n");
|
||||
let plugin_dir = dir.path().join("plugin");
|
||||
fs::create_dir_all(&plugin_dir).unwrap();
|
||||
let artifact = plugin_dir.join("solver.so");
|
||||
fs::write(&artifact, b"not-a-real-library").unwrap();
|
||||
let digest = hex::encode(sha2::Sha256::digest(fs::read(&artifact).unwrap()));
|
||||
let manifest = format!(
|
||||
"plugin:\n name: demo.solver\n version: 0.1.0\n abi: \"^1.0\"\n kind: native\n exports:\n - name: solver.add\n signature: \"($a: Int, $b: Int) -> Int\"\n requires:\n - math.compute\n artifacts:\n - target: {}\n file: solver.so\n sha256: \"{}\"\n",
|
||||
marqdo_plugin_abi::HostTarget::current().triple(),
|
||||
digest
|
||||
);
|
||||
fs::write(plugin_dir.join("plugin.yaml"), manifest).unwrap();
|
||||
let output = cli(
|
||||
dir.path(),
|
||||
&[
|
||||
"run",
|
||||
"index.mq.md",
|
||||
"--event-stream",
|
||||
"jsonl",
|
||||
"--plugin",
|
||||
plugin_dir.join("plugin.yaml").to_str().unwrap(),
|
||||
"--allow-plugin",
|
||||
"demo.solver",
|
||||
],
|
||||
);
|
||||
assert_eq!(output.status.code(), Some(2));
|
||||
let events = parse_events(&output.stdout);
|
||||
assert_envelope(&events);
|
||||
let terminal = events.last().unwrap();
|
||||
assert_eq!(terminal["kind"], "run.rejected");
|
||||
assert_eq!(
|
||||
terminal["payload"]["error"]["code"],
|
||||
"ext.event_stream_unsupported_native_plugin"
|
||||
);
|
||||
assert!(
|
||||
events_of(&events, "run.started").is_empty(),
|
||||
"the native plugin is rejected before execution"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn observed_values_never_enter_trace_v2() {
|
||||
let dir = TempDir::new("trace-redaction");
|
||||
dir.write(
|
||||
"index.mq.md",
|
||||
"## @exec main\n\n`secret_token = \"DO_NOT_LEAK_SENTINEL_1\"`\n\n`visible_count = 42`\n\n`return visible_count`\n",
|
||||
);
|
||||
let trace_path = dir.path().join("trace.json");
|
||||
let output = cli(
|
||||
dir.path(),
|
||||
&[
|
||||
"run",
|
||||
"index.mq.md",
|
||||
"--event-stream",
|
||||
"jsonl",
|
||||
"--observe-variable",
|
||||
"secret_token",
|
||||
"--observe-text-values",
|
||||
"--trace-file",
|
||||
trace_path.to_str().unwrap(),
|
||||
],
|
||||
);
|
||||
assert_eq!(output.status.code(), Some(0));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&output.stdout).contains("DO_NOT_LEAK_SENTINEL_1"),
|
||||
"the explicit event consent publishes the selected value in the stream"
|
||||
);
|
||||
let trace = fs::read(&trace_path).unwrap();
|
||||
assert!(
|
||||
!String::from_utf8_lossy(&trace).contains("DO_NOT_LEAK_SENTINEL_1"),
|
||||
"Trace v2 must not gain observed values"
|
||||
);
|
||||
let trace: Value = serde_json::from_slice(&trace).unwrap();
|
||||
assert_eq!(trace["schema"], "marqdo.trace");
|
||||
assert_eq!(trace["schema_version"], 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn basic_stream_is_pure_jsonl_and_reconstructs_program_output() {
|
||||
let dir = TempDir::new("basic");
|
||||
|
||||
@@ -341,7 +341,9 @@ impl<'a> Interpreter<'a> {
|
||||
}
|
||||
}
|
||||
};
|
||||
provenance.insert(param.name.clone(), (source, param.span));
|
||||
if self.observe {
|
||||
provenance.insert(param.name.clone(), (source, param.span));
|
||||
}
|
||||
locals.insert(param.name.clone(), value);
|
||||
}
|
||||
Ok(BoundArgs { locals, provenance })
|
||||
|
||||
+4
-2
@@ -100,6 +100,8 @@ This section records work **after** the `v3.0.0-beta.1` tag. It is not part of
|
||||
the tagged beta archive and no new release tag has been created. The design
|
||||
input is RFC-OBS-0001 (issue `#1`), the frozen decision is ADR-0059 and the
|
||||
normative contract is [`spec/execution-events-v1.md`](../spec/execution-events-v1.md).
|
||||
Executed evidence for this section is
|
||||
[`evidence/2026-11-22-execution-events-v1.md`](evidence/2026-11-22-execution-events-v1.md).
|
||||
|
||||
- **Implemented (P0/P1):** `run/call --event-stream jsonl` writes a pure NDJSON
|
||||
`marqdo.execution-events` v1 stream; lifecycle/terminal events; byte-exact
|
||||
@@ -122,8 +124,8 @@ Executed local gate on this tree (Linux x86_64, Rust 1.100.0):
|
||||
```text
|
||||
cargo fmt --all -- --check PASS
|
||||
cargo clippy --workspace --all-targets -- -D warnings PASS
|
||||
cargo test --workspace --locked PASS: 628 passed, 0 failed, 2 ignored
|
||||
cargo test -p marqdo-cli --test execution_events PASS: 12 passed
|
||||
cargo test --workspace --locked PASS: 630 passed, 0 failed, 2 ignored
|
||||
cargo test -p marqdo-cli --test execution_events PASS: 14 passed
|
||||
cargo test -p marqdo-host --test observation PASS: 8 passed
|
||||
cargo test -p marqdo-runtime --test observation PASS: 4 passed
|
||||
python3 tests/consumers/execution_events_consumer.py PASS on a live real-binary stream (schema, seq, terminal, byte_count)
|
||||
|
||||
@@ -44,7 +44,7 @@ platform".
|
||||
| Dimension | Current state | Source |
|
||||
|---|---|---|
|
||||
| Implemented | Rust workspace `3.0.0-beta.1`: RFC-LANG-0002 Markdown/frontend/IR, v2 statement parser, tree-walk runtime, `Memory`, capability host, Tool/Analysis/Trace, Plugin ABI, Foreign kernels, migrated bundled stdlib, CLI composition root; post-baseline Execution Events v1 observation (ADR-0059) | `Cargo.toml`, `crates/`, `stdlib/` |
|
||||
| Tested locally | `cargo test --workspace --locked`: **628 passed, 0 failed, 2 ignored** on the post-baseline observability tree (Linux x86_64); `cargo fmt --check` and `clippy -D warnings` clean. Historical baseline: 599 passed before Execution Events v1, 507 at `9c1723d`. | `docs/STATUS.md` §0.5, `docs/evidence/2026-11-22-ext-implementation.md` |
|
||||
| Tested locally | `cargo test --workspace --locked`: **630 passed, 0 failed, 2 ignored** on the post-baseline observability tree (Linux x86_64); `cargo fmt --check` and `clippy -D warnings` clean. Historical baseline: 599 passed before Execution Events v1, 507 at `9c1723d`. | `docs/STATUS.md` §0.5, `docs/evidence/2026-11-22-ext-implementation.md` |
|
||||
| Bundled stdlib released | In-repo bundle `marqdo-stdlib@0.1.0`, SHA-256 digest verified before loading; it is **not** an external registry package | `stdlib/stdlib.json`, `stdlib/README.md` |
|
||||
| Multi-platform verified | Linux local gate is the only executed lane here; Windows/macOS native lanes are **UNVERIFIED**, and the GitHub security lane remains a **VM-only** gate | `docs/STATUS.md` §1, §4 |
|
||||
|
||||
|
||||
@@ -93,6 +93,9 @@ an untrusted Git URL does not make the code trustworthy.
|
||||
silent fallback to `project`.
|
||||
* The live lane is tested on Linux x86_64; macOS/Windows are unverified for
|
||||
this option like the rest of the beta CLI.
|
||||
* In-process native plugins are rejected in event mode
|
||||
(`ext.event_stream_unsupported_native_plugin`) because they share the process
|
||||
and can write the protocol fd directly; worker plugins remain usable.
|
||||
* Observation lowers confidentiality when values are explicitly enabled. Text
|
||||
needs a second opt-in; View/agents must not enable these flags by default.
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# Execution Events v1 — local implementation evidence
|
||||
|
||||
- **Date:** 2026-11-22
|
||||
- **Scope:** RFC-OBS-0001 P0 (OBS-00..03) and P1 (OBS-04..05); OBS-06/P2
|
||||
memory metadata deliberately deferred.
|
||||
- **Source SHA:** `2d51f0834090aa8a78f081dc176a0463bf53d51c` (post-beta tree;
|
||||
the tagged beta is `2c7c4f31e7a388d3fcfa717a77067e696ed13854` and does **not**
|
||||
contain this feature).
|
||||
- **Normative contract:** [`spec/execution-events-v1.md`](../../spec/execution-events-v1.md),
|
||||
schema `spec/schemas/execution-events-v1.schema.json`, decision
|
||||
[ADR-0059](../adr/0059-runtime-observability-and-execution-events.md).
|
||||
|
||||
This file records commands actually executed on Linux x86_64 with Rust
|
||||
1.100.0. It is local evidence, not a same-SHA CI or published-release claim.
|
||||
|
||||
## Static and test gate
|
||||
|
||||
```text
|
||||
cargo fmt --all -- --check PASS
|
||||
cargo clippy --workspace --all-targets -- -D warnings PASS
|
||||
cargo test --workspace --locked PASS: 630 passed, 0 failed, 2 ignored
|
||||
cargo test -p marqdo-cli --test execution_events PASS: 14 passed
|
||||
cargo test -p marqdo-host --test observation PASS: 8 passed
|
||||
cargo test -p marqdo-runtime --test observation PASS: 4 passed
|
||||
cargo test -p marqdo-cli --test docs_consistency PASS
|
||||
cargo test -p marqdo-cli --test architecture_boundaries PASS
|
||||
```
|
||||
|
||||
The `execution_events` suite covers: pure JSONL envelope, contiguous `seq`,
|
||||
terminal ordering, byte-exact base64 reconstruction (including invalid UTF-8
|
||||
and multi-byte text), live `READY` delivery while the child is still running,
|
||||
prepare/runtime terminals, exact value selection and text redaction, Trace v2
|
||||
coexistence/shared run id, structural-budget truncation, output-budget
|
||||
fail-closed, the checked-in JSON Schema fixtures, the structure fixture, and
|
||||
broken-pipe failure (`observe.transport_failed`, non-zero exit), native-plugin
|
||||
fail-closed, and observed values never entering Trace v2.
|
||||
|
||||
## Frozen-binary black-box consumer
|
||||
|
||||
A local release archive was built from the source SHA and the independent
|
||||
Python consumer was run against the extracted binary's live stream:
|
||||
|
||||
```text
|
||||
archive: dist/marqdo-3.0.0-beta.1-x86_64-unknown-linux-gnu.tar.gz
|
||||
archive sha256: e000fc4afd7d68c3aaed3a28393f1f2301ee61e692c7d471b6f0b9cde1ff5994
|
||||
extracted marqdo sha256 before: c45ba7fd81c171dd349ba2250b5af0434152cd9ffa39f37dfec31a435b2b730e
|
||||
extracted marqdo sha256 after: c45ba7fd81c171dd349ba2250b5af0434152cd9ffa39f37dfec31a435b2b730e (unchanged)
|
||||
run: marqdo run tests/consumers/fixtures/execution-events/basic.mq.md --event-stream jsonl
|
||||
run exit: 0
|
||||
consumer: execution events consumer: ok: 297 events, terminal=run.completed, stdout+stderr bytes=11
|
||||
```
|
||||
|
||||
The stream began with `stream.opened` (`seq 0`), contained exactly one
|
||||
`run.started`, emitted the two committed stdout chunks before the terminal
|
||||
event, and ended with `run.completed` (`{"type":"int","decimal":"10"}`).
|
||||
Concatenated chunk bytes were `START\nDONE\n`, equal to a normal run.
|
||||
|
||||
`tools/release/smoke.py --archive ... --skip-strict` on the same archive:
|
||||
`smoke: PASS` (includes the new live-stream consumer step and `run --help`
|
||||
protocol option check). The disposable-VM strict lane was not run because this
|
||||
environment is not a disposable VM; in any case `--mode strict` explicitly
|
||||
refuses `--event-stream` (structured `run.rejected`, no downgrade).
|
||||
|
||||
## Non-claims
|
||||
|
||||
- Not included in the `v3.0.0-beta.1` archive and no new release tag was
|
||||
created.
|
||||
- No macOS/Windows native verification for this option.
|
||||
- No memory metadata/value of containers/handles, no debugger, stepping,
|
||||
breakpoints, time travel, raw memory read or bidirectional debug protocol.
|
||||
- No performance gate; observation is off by default and the disabled path does
|
||||
not build observation events, but this file makes no percentage claim.
|
||||
@@ -296,6 +296,10 @@ authorization are unchanged.
|
||||
* A third-party extension's raw OS stdout/stderr must not pollute the JSONL
|
||||
channel. Such output remains external process data: it is either captured by
|
||||
the controlled host transport or the combination is unsupported/fail-closed.
|
||||
In particular, an in-process **native plugin** can write fd 1 directly, so an
|
||||
event-mode run that selects one is rejected with
|
||||
`ext.event_stream_unsupported_native_plugin` before loading; use a worker
|
||||
plugin or disable event mode.
|
||||
* Tests use synthetic sentinel values and assert that unselected values never
|
||||
appear in the stream, Trace or `--json`.
|
||||
|
||||
|
||||
Reference in new issue
Block a user