feat(archied): read-only run-scoped sandbox view over the harness contract (#1662)
* feat(archied): read-only run-scoped sandbox view over the harness contract Serve RunTarget: the daemon resolves a running task and attempt to its Kit container and follows its output, refusing a finished or unknown task with a stated reason. The dashboard adds a Sandbox tab behind the task log's read authority. Takeover stays out of scope until the sod1 authority is wired. * fix(archied): scope and close sandbox views correctly Forward harness activity into container output, bind containers and dashboard views to their attempt, enforce the asserted org, and report unavailable dependencies and interrupted streams accurately. Refs: archie-core-qi91, archie-core-252tj
This commit is contained in:
1 parent
59be81c7f6
commit
acec5d392d
29 files changed
+838
-139
No files matched your search
@@ -254,16 +254,18 @@ func invoke(ctx context.Context, workspace string, h *agentrun.HarnessSpec, argv
|
||||
return err
|
||||
}
|
||||
var stderr tailBuffer
|
||||
cmd.Stderr = &stderr
|
||||
cmd.Stderr = io.MultiWriter(&stderr, os.Stderr)
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("start harness: %w", err)
|
||||
}
|
||||
scanner := bufio.NewScanner(stdout)
|
||||
// Keep the raw harness activity visible in the container's live output.
|
||||
output := io.TeeReader(stdout, os.Stdout)
|
||||
scanner := bufio.NewScanner(output)
|
||||
scanner.Buffer(make([]byte, 64*1024), 16*1024*1024)
|
||||
for scanner.Scan() {
|
||||
out.Line(scanner.Bytes(), report)
|
||||
}
|
||||
_, _ = io.Copy(io.Discard, stdout)
|
||||
_, _ = io.Copy(io.Discard, output)
|
||||
if err := cmd.Wait(); err != nil {
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//go:build unix
|
||||
|
||||
package agentexec
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/agentrun"
|
||||
)
|
||||
|
||||
func TestHarnessLiveOutput(t *testing.T) {
|
||||
if os.Getenv("ARCHIE_TEST_HARNESS_OUTPUT") == "1" {
|
||||
adapter := &codexHarnessOutput{}
|
||||
user := ""
|
||||
if os.Geteuid() == 0 {
|
||||
user = "65534"
|
||||
}
|
||||
err := invoke(t.Context(), "/tmp", &agentrun.HarnessSpec{User: user}, []string{"sh", "-c", `printf '%s\n' '{"type":"thread.started","thread_id":"live-thread"}'; printf '%s\n' 'live diagnostic' >&2`}, adapter, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if adapter.SessionID() != "live-thread" {
|
||||
t.Fatal("forwarding lost the adapter input")
|
||||
}
|
||||
return
|
||||
}
|
||||
cmd := exec.CommandContext(t.Context(), os.Args[0], "-test.run=^TestHarnessLiveOutput$")
|
||||
cmd.Env = append(os.Environ(), "ARCHIE_TEST_HARNESS_OUTPUT=1")
|
||||
got, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("harness: %v: %s", err, got)
|
||||
}
|
||||
for _, want := range []string{"live-thread", "live diagnostic"} {
|
||||
if !strings.Contains(string(got), want) {
|
||||
t.Errorf("worker output %q is missing %q", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user