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: 7 additions & 1 deletion cli/bash/commands/basectl/basectl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,13 @@ basectl_main() {
}
else
if basectl_finalize_run_bundle "$command_status"; then
basectl_history_record "$command" "$command_status" "$history_scope" "${history_args[@]}"
# Only the invocation that owns the bundle writes its
# completion record. Inherited Base children share the
# parent's log and lifecycle; recording them with the parent
# bundle would mark it complete before the parent returns.
if [[ "${_basectl_run_bundle_created:-0}" == 1 ]]; then
basectl_history_record "$command" "$command_status" "$history_scope" "${history_args[@]}"
fi
else
basectl_scrub_inherited_run_context
fi
Expand Down
6 changes: 4 additions & 2 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 without finalizing it" {
@test "basectl reuses a validated internal run bundle without finalizing or recording it" {
local cache_root="$TEST_TMPDIR/cache"
local inherited_root="$cache_root/base/runs/parent-run__setup"

Expand All @@ -224,11 +224,12 @@ load ./basectl_helpers.bash
BASE_BASH_LIBS_PRIMARY_LOG="$inherited_root/logs/primary.log" \
BASE_CLI_HISTORY_PARENT_RUN_ID=parent-run \
BASE_CLI_HISTORY_SCOPE=internal \
BASE_TEST_STATE_DIR="$TEST_STATE_DIR" \
bash -c '
source "$BASE_HOME/cli/bash/commands/basectl/basectl.sh"
base_std_log_debug() { :; }
basectl_do_setup() { return 0; }
basectl_history_record() { :; }
basectl_history_record() { touch "$BASE_TEST_STATE_DIR/history-recorded"; }
basectl_main setup
'

Expand All @@ -237,6 +238,7 @@ load ./basectl_helpers.bash
grep -Fq '"run_id":"parent-run"' "$inherited_root/run.json"
grep -Fq '"status":"running"' "$inherited_root/run.json"
[ -f "$inherited_root/tmp/private/proof.txt" ]
[ ! -e "$TEST_STATE_DIR/history-recorded" ]
[ "$(find "$cache_root/base/runs" -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1 ]
}

Expand Down
6 changes: 4 additions & 2 deletions docs/observability.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ A history record should include:
```

Primary records use `scope: "primary"` and represent the command the user
invoked. Delegated records use `scope: "internal"` and carry that invocation's
`run_id` in `parent_run_id`.
invoked. Inherited Base children do not write separate completion records;
their delegated output remains in the parent's primary log and their lifecycle
remains owned by the parent invocation. Legacy `scope: "internal"` records may
still exist in older history indexes and are ignored by public history views.

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
Expand Down
Loading