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
5 changes: 5 additions & 0 deletions cli/bash/commands/basectl/basectl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,11 @@ basectl_finalize_run_bundle() {
base_std_log_warn "Skipping finalization for an invalid Base run context."
return 1
fi
# Only the invocation that created the bundle owns its finalization.
# Inherited Base children reuse the parent bundle for logs and history but
# must not close it while the parent command is still running.
[[ "${_basectl_run_bundle_created:-0}" == 1 ]] || return 0

tmp_file="$(mktemp "$run_root/.run.json.XXXXXX")" || return 1
printf '{"run_id":"%s","owner":"base","status":"%s","exit_code":%s,"started_at":"%s","ended_at":"%s"}\n' \
"${BASE_CLI_RUN_ID:-$(basename -- "$run_root")}" \
Expand Down
6 changes: 3 additions & 3 deletions cli/bash/commands/basectl/tests/runtime-dispatch.bats
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ load ./basectl_helpers.bash
}


@test "basectl reuses a validated internal run bundle" {
@test "basectl reuses a validated internal run bundle without finalizing it" {
local cache_root="$TEST_TMPDIR/cache"
local inherited_root="$cache_root/base/runs/parent-run__setup"

Expand Down Expand Up @@ -235,8 +235,8 @@ load ./basectl_helpers.bash
[ "$status" -eq 0 ]
[[ "$output" != *"Ignoring invalid inherited Base run context"* ]]
grep -Fq '"run_id":"parent-run"' "$inherited_root/run.json"
grep -Fq '"status":"ok"' "$inherited_root/run.json"
[ ! -e "$inherited_root/tmp" ]
grep -Fq '"status":"running"' "$inherited_root/run.json"
[ -f "$inherited_root/tmp/private/proof.txt" ]
[ "$(find "$cache_root/base/runs" -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1 ]
}

Expand Down
4 changes: 3 additions & 1 deletion docs/observability.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ An inherited run bundle is reused only when its physical path is a non-symlink
direct child of the active Base cache owner root and its owner, run ID, parent
ID, primary log, and running metadata agree. Invalid inherited state is scrubbed
without echoing its values, and the invocation receives a fresh local bundle.
The same boundary is checked again before finalization.
The same boundary is checked again before finalization. Only the invocation that
created a bundle finalizes its metadata and removes its temporary directory;
inherited Base children reuse the parent bundle without closing it.

Fields should be omitted when unknown instead of guessed.

Expand Down
Loading