Skip to content
Closed
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
3 changes: 3 additions & 0 deletions dag/extdeps/exec/command.dag
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ fn argv_command(program: ProgramIdentity, arguments: List<String>) -> ArgvComman
decl_ref(module_path: "extdeps.git", decl_name: "git_diff_binary_head_command"),
decl_ref(module_path: "extdeps.git", decl_name: "git_reset_hard_command"),
decl_ref(module_path: "extdeps.git", decl_name: "git_worktree_add_detached_command"),
decl_ref(module_path: "extdeps.git", decl_name: "git_worktree_add_dispatch_command"),
decl_ref(module_path: "extdeps.git", decl_name: "git_worktree_add_detached_dispatch_command"),
decl_ref(module_path: "extdeps.git", decl_name: "git_for_each_ref_dispatch_command"),
decl_ref(module_path: "extdeps.git", decl_name: "git_worktree_remove_force_command"),
decl_ref(module_path: "extdeps.git", decl_name: "git_worktree_prune_command"),
decl_ref(module_path: "extdeps.crypto.hash", decl_name: "sha256sum_file_command"),
Expand Down
6 changes: 6 additions & 0 deletions dag/extdeps/exec/program.dag
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ fn uncataloged_program(invocation: NonEmptyStr) -> ProgramIdentity
decl_ref(module_path: "extdeps.tools.findutils", decl_name: "find_program"),
decl_ref(module_path: "extdeps.posix.getconf", decl_name: "getconf_program"),
decl_ref(module_path: "extdeps.git", decl_name: "git_program"),
decl_ref(module_path: "gunbc.roadmap_dispatch_actuator", decl_name: "dispatch_git_program"),
decl_ref(module_path: "gunbc.roadmap_dispatch_actuator", decl_name: "git_worktree_add_argv"),
decl_ref(module_path: "gunbc.roadmap_dispatch_actuator", decl_name: "git_worktree_add_argv_for_instance"),
decl_ref(module_path: "gunbc.roadmap_dispatch_actuator", decl_name: "git_worktree_add_detached_argv_for_instance"),
decl_ref(module_path: "gunbc.roadmap_dispatch_actuator", decl_name: "git_for_each_ref_dispatch_argv"),
decl_ref(module_path: "gunbc.roadmap_dispatch_actuator", decl_name: "git_for_each_ref_dispatch_argv_for_instance"),
Comment on lines +131 to +134

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove non-callers from the program mint roster

The _for_instance functions admitted here never call uncataloged_program; they obtain the identity through dispatch_git_program, which is already admitted. Granting these wrappers direct mint access unnecessarily widens the sealed capability, allowing a later edit to mint arbitrary uncataloged program identities without changing this audit roster. Keep only dispatch_git_program and the two instance-less helpers that actually invoke the mint.

Useful? React with 👍 / 👎.

decl_ref(module_path: "extdeps.tools.gnu_time", decl_name: "gnu_time_program"),
decl_ref(module_path: "extdeps.tools.hostname", decl_name: "hostname_program"),
decl_ref(module_path: "extdeps.tools.id", decl_name: "id_program"),
Expand Down
23 changes: 23 additions & 0 deletions dag/extdeps/git/git.dag
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,29 @@ fn shape_git_worktree_add_argv(path: FilePath, branch: NonEmptyStr, remote_ref:
["worktree", "add", path as String, "-b", branch as String, remote_ref as String]
}

// Dispatch worktrees run against an instance-selected git executable. Keep the selection as an
// explicit ProgramIdentity input while this tool-owned builder owns the operation spelling.
fn git_worktree_add_dispatch_command(
program: ProgramIdentity,
path: FilePath,
branch: NonEmptyStr,
remote_ref: GitRef,
) -> ArgvCommand {
argv_command(program: program, arguments: shape_git_worktree_add_argv(path: path, branch: branch, remote_ref: remote_ref))
}

fn git_worktree_add_detached_dispatch_command(
program: ProgramIdentity,
path: FilePath,
commit: GitRef,
) -> ArgvCommand {
argv_command(program: program, arguments: shape_git_worktree_add_detached_argv(path: path, commit: commit))
}

fn git_for_each_ref_dispatch_command(program: ProgramIdentity) -> ArgvCommand {
argv_command(program: program, arguments: ["for-each-ref", "--format=%(refname:short)", "refs/heads/dispatch/"])
}

// Worktree at an EXISTING branch (no -b): the branch is created elsewhere and this checks it out.
fn shape_git_worktree_add_branch_argv(path: FilePath, branch: NonEmptyStr) -> List<String> {
["worktree", "add", path as String, branch as String]
Expand Down
63 changes: 40 additions & 23 deletions dag/gunbc/roadmap/roadmap_dispatch_actuator.dag
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ import gunbc.session_lease {
Start,
classify_process_port_upsert,
}
import extdeps.git { shape_git_worktree_add_argv, shape_git_worktree_add_detached_argv }
import extdeps.exec.program { ProgramIdentity, uncataloged_program }
import extdeps.exec.command { ArgvCommand }
import extdeps.git {
git_worktree_add_dispatch_command,
git_worktree_add_detached_dispatch_command,
git_for_each_ref_dispatch_command,
}
import std.measure { ByteSize, byte_size_count }
import std.algebra { trim }
import extdeps.systemd.systemctl
Expand Down Expand Up @@ -438,6 +444,25 @@ type HostExecArgv {
args: List<String>
}

// Capability executables come from the per-instance dispatch environment. Preserve that identity
// boundary when constructing typed extdeps commands; the declared mint only accepts this named
// adapter, so all uses remain auditable at one seam.
fn dispatch_git_program(instance: HostDashboardInstance) -> ProgramIdentity {
uncataloged_program(
invocation: dispatch_capability_program(
environment: instance.execution_environment,
cap: GitWorkspaceCapability,
) as NonEmptyStr,
)
}

fn host_argv_from_command(command: ArgvCommand) -> HostExecArgv {
HostExecArgv {
program: command.program.invocation as String,
args: command.arguments,
}
}

data dispatch_unrealized_capability_marker: String = "gunbc-unrealized-capability:"

// An environment with no realization for a capability used to resolve to the empty program string.
Expand Down Expand Up @@ -1639,9 +1664,9 @@ fn host_exec_argv(program: String, args: List<String>) -> HostExecArgv {
}

fn git_worktree_add_argv(worktree_path: String, branch_name: String, remote_ref: String) -> HostExecArgv {
host_exec_argv(
program: "git",
args: shape_git_worktree_add_argv(
host_argv_from_command(
command: git_worktree_add_dispatch_command(
program: uncataloged_program(invocation: "git"),
path: worktree_path as FilePath,
branch: branch_name as NonEmptyStr,
remote_ref: remote_ref as GitRef,
Expand All @@ -1655,12 +1680,9 @@ fn git_worktree_add_argv_for_instance(
branch_name: String,
remote_ref: String,
) -> HostExecArgv {
host_exec_argv(
program: dispatch_capability_program(
environment: instance.execution_environment,
cap: GitWorkspaceCapability,
),
args: shape_git_worktree_add_argv(
host_argv_from_command(
command: git_worktree_add_dispatch_command(
program: dispatch_git_program(instance: instance),
path: worktree_path as FilePath,
branch: branch_name as NonEmptyStr,
remote_ref: remote_ref as GitRef,
Expand All @@ -1673,12 +1695,9 @@ fn git_worktree_add_detached_argv_for_instance(
worktree_path: String,
commit_sha: String,
) -> HostExecArgv {
host_exec_argv(
program: dispatch_capability_program(
environment: instance.execution_environment,
cap: GitWorkspaceCapability,
),
args: shape_git_worktree_add_detached_argv(
host_argv_from_command(
command: git_worktree_add_detached_dispatch_command(
program: dispatch_git_program(instance: instance),
path: worktree_path as FilePath,
commit: commit_sha as GitRef,
),
Expand Down Expand Up @@ -3166,18 +3185,16 @@ fn dispatch_attempt_refs(git_output: String) -> List<DispatchAttemptRef> {
}

fn git_for_each_ref_dispatch_argv() -> HostExecArgv {
host_exec_argv(program: "git", args: ["for-each-ref", "--format=%(refname:short)", "refs/heads/dispatch/"])
host_argv_from_command(
command: git_for_each_ref_dispatch_command(program: uncataloged_program(invocation: "git")),
)
}

fn git_for_each_ref_dispatch_argv_for_instance(
instance: HostDashboardInstance,
) -> HostExecArgv {
host_exec_argv(
program: dispatch_capability_program(
environment: instance.execution_environment,
cap: GitWorkspaceCapability,
),
args: ["for-each-ref", "--format=%(refname:short)", "refs/heads/dispatch/"],
host_argv_from_command(
command: git_for_each_ref_dispatch_command(program: dispatch_git_program(instance: instance)),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,8 @@ test fn witness_host_exec_argv_shapes_bound_to_extdeps() -> Bool {
persist_session: true,
},
)
bound_worktree.args == worktree_args
bound_worktree.program == "git"
&& bound_worktree.args == worktree_args
&& starts_with(s: join(tmux_args, separator: " "), prefix: "new-session -d -s gunbc-dispatch-bound-node")
&& string_contains(s: join(claude_args_dangerous, separator: "\0"), pattern: "--dangerously-skip-permissions")
&& !string_contains(s: join(claude_args_default, separator: "\0"), pattern: "--dangerously-skip-permissions")
Expand Down
Loading