Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ filesystem quota. Package-network profiles are recorded as configuration only;
no run uses them. The trusted `packages fetch` command downloads from declared
origins into a per-workspace cache. A selected root is exposed read-only on
Linux and Windows; Windows needs a read-execute container grant, and Linux
falls back to application storage. Provider profiles and trusted single-use
approval records are configuration and authorization records only; no adapter
or model tool uses them. Trusted CLI
falls back to application storage. Provider profiles record connection shapes
without credentials or adapters; no adapter or login uses them. Trusted
single-use approval records authorize one exact model-tool call: only a later
identical call may consume an approved record and invoke the trusted runner,
and `workspace_run_command` is their only consumer. Trusted CLI
commands record, apply, and revoke Windows container ACL grants. Follow the
[execution contract](docs/execution.md).
The bundled web interface and most planned features are not implemented.
Expand Down
43 changes: 42 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Changes are recorded here before a release version is assigned.
preferences are enabled. Every call rechecks them; the trusted run checks
them again.
- **Arguments:** a recorded toolchain profile, program, at most 64
arguments, and an optional workspace-relative `cwd`. There is no shell.
arguments, and an optional workspace-relative `cwd`. The tool has no shell
mode and never re-parses a command line; the model may name an interpreter
the approved profile exposes.
- **Approval:** the first call records a pending approval and returns
`approval_required`; it starts nothing. After `approvals approve <id>`, a
second identical call consumes the approval and calls the trusted runner.
Expand Down Expand Up @@ -336,6 +338,45 @@ Changes are recorded here before a release version is assigned.

### Fixed

- PR #30 review follow-up:
- Expired, undecided approvals no longer occupy the 64 pending slots during
requests or replay. Only records unexpired at the request's event time
count.
- A legacy toolchain profile that declares `OMGCODE_PACKAGE_CACHE` still
replays. New declarations are refused; the runner skips a legacy value so
its own cache path wins.
- Windows package fetch now requires a selected cache root, matching the
runner's lack of an application-storage fallback.
- Package fetch checks its overall deadline before each body read, and the
send and every chunk read are bounded by the remaining time. A body that
completes after the deadline is rejected.
- A stale foreign cache-grant record refuses a cache-root selection, and a
stale owner grant is revoked fail-closed instead of being treated as
unrelated.
- A `model_tools` true-to-false change records a durable per-workspace
count. A model-origin run stops even if the preference is re-enabled
before its watcher reads the setting.
- Disk sampling preserves a real measurement error that races with
shutdown; only its own cancellation is ignored.
- Package cache publication uses an atomic no-replace hard link. Two
concurrent fetches cannot overwrite each other, and a synchronized
collision test covers the winner.
- A run records its configured package cache root and whether it came from a
model tool. Clearing or replacing the root, or disabling `model_tools`,
withdraws the live run. The cache-root CLI commands wait for affected runs.
- Changing or clearing a cache root revokes read-execute container grants
that covered it, and selecting a root another workspace can already read is
refused.
- The model command summary finds a UTF-8 boundary before truncation; a long
multibyte program name no longer panics.
- Disk sampling observes cancellation during traversal, and directory
enumeration checks the entry budget before queuing each path.
- Documents that `workspace_run_command` has no shell mode but may name an
interpreter under the exact-request approval. Corrects stale plan, guide,
and AGENTS descriptions of approval records and model tools.
- Strengthens the ungranted-cache refusal test to prove the program did not
start, and the cache-root replay test to compare the exact workspace and
directory identity.
- Tree limits, after the PR #27 review:
- **Range checks before recording:** the core checks every run limit before
it records a run, so a direct caller with an out-of-range tree limit gets
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ serde_json = "1"
uuid = { version = "1", features = ["v4", "serde"] }
time = { version = "0.3", features = ["formatting", "parsing", "serde"] }
thiserror = "2"
tokio = { version = "1", default-features = false, features = ["rt", "time", "net", "fs", "io-util"] }
reqwest = { version = "0.13.5", default-features = false, features = ["blocking", "json", "native-tls"] }
sha2 = "0.11.1"
clap = { version = "4.6.7", features = ["derive"] }
Expand Down
10 changes: 8 additions & 2 deletions crates/omgcode-cli/src/control_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ pub(crate) fn run(action: WorkspaceCommand, data_root: &Path) -> Result<(), CliE
store
.set_package_cache_root(workspace_id, &path, revision)
.map_err(control_error)?;
print_json(&store.snapshot())
let snapshot = store.snapshot();
drop(store);
stop_withdrawn_runs(data_root, &[])?;
print_json(&snapshot)
}
WorkspaceCommand::ClearPackageCache {
workspace,
Expand All @@ -267,7 +270,10 @@ pub(crate) fn run(action: WorkspaceCommand, data_root: &Path) -> Result<(), CliE
store
.clear_package_cache_root(workspace_id, revision)
.map_err(control_error)?;
print_json(&store.snapshot())
let snapshot = store.snapshot();
drop(store);
stop_withdrawn_runs(data_root, &[])?;
print_json(&snapshot)
}
WorkspaceCommand::Register { path, revision } => {
let mut store = open(data_root)?;
Expand Down
1 change: 1 addition & 0 deletions crates/omgcode-cli/src/run_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ pub(crate) fn run(args: RunArgs, data_root: &Path) -> Result<(), CliError> {
working_directory: args.cwd,
host_services: args.host_services,
network: args.network,
model_tools: false,
limits: ProcessLimits {
deadline,
max_stdout_bytes: args.max_output_bytes,
Expand Down
22 changes: 22 additions & 0 deletions crates/omgcode-cli/tests/packages_workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,25 @@ fn a_trusted_fetch_writes_a_private_cache_and_is_audited() {
);
assert_success(&output);

// Windows has no application-storage fallback; select an external root.
#[cfg(windows)]
{
let cache_root = temporary.path().join("package-cache-root");
fs::create_dir(&cache_root).expect("cache root");
let output = run_cli(
&data_root,
&[
"workspace",
"set-package-cache",
&id,
path_arg(&cache_root),
"--revision",
&revision(&data_root).to_string(),
],
);
assert_success(&output);
}

// When the operator fetches a declared package URL.
let url = fixture.url("/fixtures/pkg.bin");
let output = run_cli(
Expand All @@ -187,7 +206,10 @@ fn a_trusted_fetch_writes_a_private_cache_and_is_audited() {
assert_eq!(report["bytes"], BODY.len());
assert_eq!(report["status"], 200);
assert_eq!(report["profile_name"], PROFILE);
#[cfg(target_os = "linux")]
let cache = data_root.join("package-cache").join(&id).join("pkg.bin");
#[cfg(windows)]
let cache = temporary.path().join("package-cache-root").join("pkg.bin");
assert_eq!(fs::read(&cache).expect("cache file"), BODY);
let head = fixture.finish();
assert!(head.starts_with("GET /fixtures/pkg.bin "), "{head}");
Expand Down
18 changes: 17 additions & 1 deletion crates/omgcode-cli/tests/run_workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,24 @@ fn an_ungranted_package_cache_root_fails_the_run() {
]);
assert_success(&output);
fs::write(cache_root.join("pkg.bin"), b"configured-cache").expect("cache file");
let output = scene.run("system", &[], &shell("echo should-not-run"));
let output = scene.run("system", &[], &shell("echo ran>ran.txt"));
assert_error_code(&output, "run");
assert!(
!scene.workspace.join("ran.txt").exists(),
"the refused run started its program"
);
let audit = scene.audit();
let finished: Vec<&Value> = audit["entries"]
.as_array()
.expect("entries")
.iter()
.filter(|entry| entry["action"]["type"] == "run_finished")
.collect();
assert_eq!(finished.len(), 1, "{audit}");
assert_eq!(
finished[0]["action"]["payload"]["finish"]["result"]["kind"], "not_started",
"{audit}"
);
scene.close();
}

Expand Down
1 change: 1 addition & 0 deletions crates/omgcode-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ uuid.workspace = true
time.workspace = true
thiserror.workspace = true
reqwest.workspace = true
tokio.workspace = true
sha2.workspace = true

[dev-dependencies]
Expand Down
Loading