carlos / platform Public

feat: export held demo data through an isolated snapshot unit

Add the non-root SQLite worker, private dispatch, and inert systemd
snapshot template. Reuse checkpoint, integrity-check, and digest logic;
test received WAL data, refusals, unit properties, and bootstrap install.

This is the permitted Part 3c subset. Root streaming, disk reservation,
build-slot serialization, restart recovery, cleanup, and the production
adapter remain unwired. Claim capability stays disabled.

Targeted tests and vet pass. The root census has the expected failure
pending the controller's single overlay. Real-systemd witnesses skipped.
codex agent, operated by paul@keymail.dev pushed by claude agent, operated by paul@keymail.dev 13f924fb7b990dbe8d4b248dd3f9c73d1650a9b4 parent b9bce98
9 files changed, +476 −13
  • demo_snapshot_test.go +29 −0
  • internal/democlaim/snapshot.go +21 −13
  • internal/democlaim/worker.go +58 −0
  • internal/democlaim/worker_test.go +110 −0
  • internal/host/demo_snapshot_linux_test.go +62 −0
  • internal/host/demo_snapshot_test.go +125 −0
  • internal/host/host_test.go +1 −0
  • internal/host/units/carlos-demo-snapshot@.service +59 −0
  • main.go +11 −0

CI failed — run details

Intent

Human

<task-notification> <task-id>bwksb3zug</task-id> <tool-use-id>toolu_01M23QHYTxpmGYEPVmC3wmJy</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bwksb3zug.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/claude-1001/agent-start-demo-3; until [ -f $S/t3b.done ]; do sleep 30; done; tail -1 $S/t3b.log" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 6.25 g CO₂e (709,961 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on agent-start-demo-3, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/demo_snapshot_test.go b/demo_snapshot_test.go
new file mode 100644
index 000000000..a30a4ce5b
--- /dev/null
+++ b/demo_snapshot_test.go
@@ -0,0 +1,29 @@
+package main
+
+import (
+ "context"
+ "os/exec"
+ "strings"
+ "testing"
+ "time"
+)
+
+func TestDemoClaimSnapshotPrivateDispatch(t *testing.T) {
+ binary := sharedCarlos(t)
+ ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
+ defer cancel()
+ cmd := exec.CommandContext(ctx, binary, "__demo-snapshot", "/untrusted/source.db")
+ cmd.Env = carlosTestEnv(t)
+ cmd.Dir = t.TempDir()
+ out, err := cmd.CombinedOutput()
+ if err == nil || !strings.Contains(string(out), "DEMO-CLAIM-SNAPSHOT") || strings.Contains(string(out), "unknown command") {
+ t.Fatalf("private dispatch must refuse arguments before opening any data: %s %v", out, err)
+ }
+ cmd = exec.CommandContext(ctx, binary, "help")
+ cmd.Env = carlosTestEnv(t)
+ cmd.Dir = t.TempDir()
+ out, err = cmd.CombinedOutput()
+ if err != nil || strings.Contains(string(out), "__demo-snapshot") {
+ t.Fatalf("private worker exposed in help: %s %v", out, err)
+ }
+}
diff --git a/internal/democlaim/snapshot.go b/internal/democlaim/snapshot.go
index 0545bb9e3..0c673e0e1 100644
--- a/internal/democlaim/snapshot.go
+++ b/internal/democlaim/snapshot.go
@@ -74,37 +74,45 @@ func ExportSQLite(ctx context.Context, dbDir, dbBase, scratchDir string) (out Sn
if err = source.Close(); err != nil {
return out, err
}
- if err = checkWALBounds(ctx, path+"-wal"); err != nil {
- return out, err
+ return finishSnapshot(ctx, path)
+}
+
+// finishSnapshot is called only by unprivileged code on a private copy.
+func finishSnapshot(ctx context.Context, path string) (Snapshot, error) {
+ if os.Geteuid() == 0 {
+ return Snapshot{}, ErrSnapshot
}
- if err = lease.TruncateWAL(ctx, path); err != nil {
- return out, err
+ if err := checkWALBounds(ctx, path+"-wal"); err != nil {
+ return Snapshot{}, err
}
- if err = lease.CheckDBContext(ctx, path); err != nil {
- return out, err
+ if err := lease.TruncateWAL(ctx, path); err != nil {
+ return Snapshot{}, err
+ }
+ if err := lease.CheckDBContext(ctx, path); err != nil {
+ return Snapshot{}, err
}
f, err := os.Open(path)
if err != nil {
- return out, err
+ return Snapshot{}, err
}
defer f.Close()
st, err := f.Stat()
if err != nil {
- return out, err
+ return Snapshot{}, err
}
if st.Size() <= 0 || st.Size() > MaxSnapshotBytes {
- return out, ErrSnapshot
+ return Snapshot{}, ErrSnapshot
}
h := sha256.New()
n, err := io.Copy(h, contextReader{ctx: ctx, r: io.LimitReader(f, MaxSnapshotBytes+1)})
if err != nil {
- return out, err
+ return Snapshot{}, err
}
if n != st.Size() {
- return out, ErrSnapshot
+ return Snapshot{}, ErrSnapshot
}
- if err = ctx.Err(); err != nil {
- return out, err
+ if err := ctx.Err(); err != nil {
+ return Snapshot{}, err
}
return Snapshot{Path: path, SHA256: hex.EncodeToString(h.Sum(nil)), Bytes: n}, nil
}
diff --git a/internal/democlaim/worker.go b/internal/democlaim/worker.go
new file mode 100644
index 000000000..f9dfd2c66
--- /dev/null
+++ b/internal/democlaim/worker.go
@@ -0,0 +1,58 @@
+package democlaim
+
+import (
+ "context"
+ "encoding/json"
+ "errors"
+ "os"
+ "path/filepath"
+)
+
+// RunSnapshotWorker is the private unit entry point. Neither argv nor the
+// environment can choose its files. Root supplies bytes in this unit's /work.
+func RunSnapshotWorker(ctx context.Context) error {
+ return runSnapshotWorkerIn(ctx, "/work")
+}
+
+func runSnapshotWorkerIn(ctx context.Context, dir string) (err error) {
+ if os.Geteuid() == 0 {
+ return ErrSnapshot
+ }
+ ctx, cancel := context.WithTimeout(ctx, SnapshotWindow)
+ defer cancel()
+ if err = ctx.Err(); err != nil {
+ return err
+ }
+ // Reserve the result name before SQLite touches anything. A failed worker
+ // leaves no result; the root controller owns termination and scratch removal.
+ result, err := os.OpenFile(filepath.Join(dir, "result.json"), os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0600)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ err = errors.Join(err, result.Close())
+ if err != nil {
+ _ = os.Remove(filepath.Join(dir, "result.json"))
+ }
+ }()
+ source, err := OpenSource(dir, "snapshot.db")
+ if err != nil {
+ return err
+ }
+ err = source.VerifyUnchanged()
+ err = errors.Join(err, source.Close())
+ if err != nil {
+ return err
+ }
+ snapshot, err := finishSnapshot(ctx, filepath.Join(dir, "snapshot.db"))
+ if err != nil {
+ return err
+ }
+ if err = json.NewEncoder(result).Encode(snapshot); err != nil {
+ return err
+ }
+ if err = result.Sync(); err != nil {
+ return err
+ }
+ return ctx.Err()
+}
diff --git a/internal/democlaim/worker_test.go b/internal/democlaim/worker_test.go
new file mode 100644
index 000000000..d656c7c7f
--- /dev/null
+++ b/internal/democlaim/worker_test.go
@@ -0,0 +1,110 @@
+//go:build linux
+
+package democlaim
+
+import (
+ "context"
+ "database/sql"
+ "encoding/json"
+ "errors"
+ "os"
+ "path/filepath"
+ "testing"
+)
+
+func receivedCopy(t *testing.T) string {
+ t.Helper()
+ source := walFixture(t)
+ work := t.TempDir()
+ for _, suffix := range []string{"", "-wal"} {
+ b, err := os.ReadFile(filepath.Join(source, "source.db"+suffix))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = os.WriteFile(filepath.Join(work, "snapshot.db"+suffix), b, 0600); err != nil {
+ t.Fatal(err)
+ }
+ }
+ return work
+}
+
+func TestDemoClaimExportBoundedWorker(t *testing.T) {
+ t.Run("checkpointCheckedResult", func(t *testing.T) {
+ work := receivedCopy(t)
+ if err := runSnapshotWorkerIn(t.Context(), work); err != nil {
+ t.Fatal(err)
+ }
+ b, err := os.ReadFile(filepath.Join(work, "result.json"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ var result Snapshot
+ if err = json.Unmarshal(b, &result); err != nil || result.Path != "" || result.SHA256 != fileHash(t, filepath.Join(work, "snapshot.db")) {
+ t.Fatalf("result %s: %v", b, err)
+ }
+ st, err := os.Stat(filepath.Join(work, "snapshot.db"))
+ if err != nil || result.Bytes != st.Size() {
+ t.Fatal("incorrect byte count", err)
+ }
+ db, err := sql.Open("sqlite", "file:"+filepath.Join(work, "snapshot.db")+"?mode=ro")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer db.Close()
+ var value string
+ if err = db.QueryRow("SELECT value FROM items").Scan(&value); err != nil || value != "committed in WAL" {
+ t.Fatal(value, err)
+ }
+ })
+ for _, fault := range []string{"cancel", "missing", "symlink", "hardlink", "corrupt", "oversized", "badWAL", "resultExists"} {
+ t.Run(fault, func(t *testing.T) {
+ work := receivedCopy(t)
+ db := filepath.Join(work, "snapshot.db")
+ ctx, cancel := context.WithCancel(t.Context())
+ defer cancel()
+ must := func(err error) {
+ t.Helper()
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+ switch fault {
+ case "cancel":
+ cancel()
+ case "missing":
+ must(os.Remove(db))
+ case "symlink":
+ must(os.Rename(db, db+".saved"))
+ must(os.Symlink(db+".saved", db))
+ case "hardlink":
+ must(os.Link(db, db+".link"))
+ case "corrupt":
+ must(os.WriteFile(db, []byte("invalid sqlite"), 0600))
+ case "oversized":
+ must(os.Truncate(db, MaxSnapshotBytes+1))
+ case "badWAL":
+ must(os.WriteFile(db+"-wal", []byte("invalid wal"), 0600))
+ case "resultExists":
+ must(os.WriteFile(filepath.Join(work, "result.json"), []byte("old"), 0600))
+ }
+ var beforeDB, beforeWAL string
+ if fault == "resultExists" {
+ beforeDB, beforeWAL = fileHash(t, db), fileHash(t, db+"-wal")
+ }
+ if err := runSnapshotWorkerIn(ctx, work); err == nil {
+ t.Fatal("unsafe worker succeeded")
+ }
+ if fault == "resultExists" {
+ old, err := os.ReadFile(filepath.Join(work, "result.json"))
+ if err != nil || string(old) != "old" || beforeDB != fileHash(t, db) || beforeWAL != fileHash(t, db+"-wal") {
+ t.Fatal("stale-result refusal modified files", err)
+ }
+ }
+ if fault != "resultExists" {
+ if _, err := os.Stat(filepath.Join(work, "result.json")); !errors.Is(err, os.ErrNotExist) {
+ t.Fatal("failed worker published result", err)
+ }
+ }
+ })
+ }
+}
diff --git a/internal/host/demo_snapshot_linux_test.go b/internal/host/demo_snapshot_linux_test.go
new file mode 100644
index 000000000..89db96165
--- /dev/null
+++ b/internal/host/demo_snapshot_linux_test.go
@@ -0,0 +1,62 @@
+//go:build linux
+
+package host
+
+import (
+ "bytes"
+ "context"
+ "os"
+ "os/exec"
+ "strings"
+ "testing"
+ "time"
+)
+
+// This witness checks installed bytes and systemd's parsed restrictions. It
+// does not launch a worker or prove runtime isolation, reservation or reaping.
+// Those witnesses must accompany the root snapshot controller.
+func TestDemoClaimSnapshotUnitDevWitness(t *testing.T) {
+ if os.Getenv("CARLOS_DEMO_CLAIM_DEV_WITNESS") != "1" {
+ t.Skip("R6: snapshot unit readback requires an explicitly designated systemd sandbox; runtime isolation remains unproven")
+ }
+ want, err := unitsFS.ReadFile("units/carlos-demo-snapshot@.service")
+ if err != nil {
+ t.Fatal(err)
+ }
+ got, err := os.ReadFile("/etc/systemd/system/carlos-demo-snapshot@.service")
+ if err != nil || !bytes.Equal(want, got) {
+ t.Fatal("install this binary's snapshot unit in the designated sandbox", err)
+ }
+ properties := map[string]string{
+ "DynamicUser": "yes", "MemoryMax": "268435456", "MemorySwapMax": "0", "CPUQuotaPerSecUSec": "500ms", "TasksMax": "32",
+ "RuntimeMaxUSec": "2min", "TimeoutStopUSec": "5s", "KillMode": "control-group", "SendSIGKILL": "yes", "OOMPolicy": "kill",
+ "LimitFSIZE": "268435456", "LimitFSIZESoft": "268435456", "WorkingDirectory": "/work",
+ "ProtectSystem": "strict", "ProtectHome": "yes", "PrivateNetwork": "yes", "PrivateDevices": "yes", "PrivateIPC": "yes", "PrivatePIDs": "yes",
+ "RestrictAddressFamilies": "AF_UNIX", "CapabilityBoundingSet": "", "AmbientCapabilities": "", "NoNewPrivileges": "yes",
+ "RestrictNamespaces": "yes", "ProtectControlGroups": "yes", "ProtectProc": "invisible", "ProcSubset": "pid",
+ "MemoryDenyWriteExecute": "yes", "NetworkNamespacePath": "", "JoinsNamespaceOf": "", "IPAddressAllow": "",
+ }
+ keys := make([]string, 0, len(properties))
+ for key := range properties {
+ keys = append(keys, key)
+ }
+ ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
+ defer cancel()
+ cmd := exec.CommandContext(ctx, "systemctl", "show", "carlos-demo-snapshot@witness.service", "--property="+strings.Join(keys, ","))
+ cmd.Env = []string{"PATH=/usr/bin:/bin", "LANG=C", "SYSTEMD_COLORS=0", "SYSTEMD_PAGER="}
+ raw, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Fatalf("unit readback: %s %v", raw, err)
+ }
+ actual := map[string]string{}
+ for _, line := range strings.Split(string(raw), "\n") {
+ if key, value, ok := strings.Cut(line, "="); ok {
+ actual[key] = value
+ }
+ }
+ for key, value := range properties {
+ if got, ok := actual[key]; !ok || got != value {
+ t.Errorf("%s = %q, want %q", key, got, value)
+ }
+ }
+}
diff --git a/internal/host/demo_snapshot_test.go b/internal/host/demo_snapshot_test.go
new file mode 100644
index 000000000..9ce2bbd8c
--- /dev/null
+++ b/internal/host/demo_snapshot_test.go
@@ -0,0 +1,125 @@
+package host
+
+import (
+ "bytes"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+)
+
+// Parse sections and assignments, refusing duplicates that could override a
+// safe-looking earlier value. Every required restriction is checked locally.
+func TestDemoClaimSnapshotUnitContract(t *testing.T) {
+ b, err := unitsFS.ReadFile("units/carlos-demo-snapshot@.service")
+ if err != nil {
+ t.Fatal(err)
+ }
+ props := map[string]string{}
+ section := ""
+ for _, line := range strings.Split(string(b), "\n") {
+ line = strings.TrimSpace(line)
+ if line == "" || strings.HasPrefix(line, "#") {
+ continue
+ }
+ if strings.HasPrefix(line, "[") {
+ section = line
+ continue
+ }
+ k, v, ok := strings.Cut(line, "=")
+ if !ok {
+ t.Fatalf("bad unit line %q", line)
+ }
+ key := section + "/" + k
+ if _, exists := props[key]; exists {
+ t.Fatalf("duplicate %s", key)
+ }
+ props[key] = v
+ }
+ want := map[string]string{
+ "Type": "exec", "RemainAfterExit": "yes", "DynamicUser": "yes", "Restart": "no",
+ "ExecStart": "/snapshot-worker __demo-snapshot", "WorkingDirectory": "/work",
+ "BindPaths": "/var/lib/carlos-demo-snapshots/%i/work:/work",
+ "BindReadOnlyPaths": "/opt/carlos/carlos:/snapshot-worker",
+ "MemoryMax": "268435456", "MemorySwapMax": "0", "CPUQuota": "50%", "TasksMax": "32",
+ "RuntimeMaxSec": "120", "TimeoutStopSec": "5", "KillMode": "control-group", "SendSIGKILL": "yes", "OOMPolicy": "kill",
+ "LimitFSIZE": "268435456", "UMask": "0077", "Environment": "HOME=/work TMPDIR=/work GOMEMLIMIT=192MiB",
+ "PassEnvironment": "", "SetLoginEnvironment": "no", "StandardInput": "null", "StandardOutput": "null", "StandardError": "null",
+ "ProtectSystem": "strict", "ProtectHome": "yes",
+ "TemporaryFileSystem": "/data:ro /run:ro /var:ro /opt:ro /etc:ro /tmp:ro /dev/shm:ro /dev/mqueue:ro /dev/pts:ro",
+ "PrivateDevices": "yes", "PrivateIPC": "yes", "PrivatePIDs": "yes", "PrivateNetwork": "yes",
+ "NetworkNamespacePath": "", "RestrictAddressFamilies": "AF_UNIX", "IPAddressDeny": "any", "IPAddressAllow": "",
+ "CapabilityBoundingSet": "", "AmbientCapabilities": "", "NoNewPrivileges": "yes", "RestrictNamespaces": "yes",
+ "ProtectControlGroups": "yes", "ProtectProc": "invisible", "ProcSubset": "pid",
+ "ProtectKernelTunables": "yes", "ProtectKernelModules": "yes", "ProtectKernelLogs": "yes", "ProtectClock": "yes", "ProtectHostname": "yes",
+ "RemoveIPC": "yes", "LockPersonality": "yes", "RestrictRealtime": "yes", "MemoryDenyWriteExecute": "yes", "SystemCallArchitectures": "native",
+ }
+ for key := range props {
+ if name, ok := strings.CutPrefix(key, "[Service]/"); ok {
+ if _, known := want[name]; !known {
+ t.Errorf("unreviewed service property %s", name)
+ }
+ }
+ }
+ for k, v := range want {
+ if got, ok := props["[Service]/"+k]; !ok || got != v {
+ t.Errorf("%s = %q, want %q", k, got, v)
+ }
+ }
+ for _, k := range []string{"BindsTo", "After"} {
+ if props["[Unit]/"+k] != "carlos-instance-control.service" {
+ t.Error(k)
+ }
+ }
+ for k := range props {
+ if strings.HasPrefix(k, "[Install]/") {
+ t.Fatal("snapshot unit enables itself")
+ }
+ }
+ for _, list := range [][]string{enabledUnits, ensureSystemArmed} {
+ for _, name := range list {
+ if strings.HasPrefix(name, "carlos-demo-snapshot") {
+ t.Fatal("snapshot armed", name)
+ }
+ }
+ }
+ names, err := unitNames()
+ if err != nil {
+ t.Fatal(err)
+ }
+ found := false
+ for _, name := range names {
+ if name == "carlos-demo-snapshot@.service" {
+ found = true
+ }
+ }
+ if !found {
+ t.Fatal("bootstrap omits snapshot unit")
+ }
+}
+
+func TestDemoClaimSnapshotBootstrap(t *testing.T) {
+ root := t.TempDir()
+ if err := bootstrap(root, nil); err != nil {
+ t.Fatal(err)
+ }
+ want, err := unitsFS.ReadFile("units/carlos-demo-snapshot@.service")
+ if err != nil {
+ t.Fatal(err)
+ }
+ got, err := os.ReadFile(filepath.Join(root, "etc/systemd/system/carlos-demo-snapshot@.service"))
+ if err != nil || !bytes.Equal(got, want) {
+ t.Fatalf("staged snapshot template differs: %v", err)
+ }
+}
+
+func TestDemoClaimSnapshotCapabilityStaysOff(t *testing.T) {
+ f := newClaimFixture(t)
+ if f.w.claimActivator == nil || f.w.claimFreeze == nil || f.w.claimSnapshot == nil {
+ t.Fatal("fixture must provide every callback")
+ }
+ if demoClaimSnapshotWired || f.w.demoHeartbeat(time.Now()).ClaimCapability != "" {
+ t.Fatal("snapshot advertised before root reservation and cleanup are wired")
+ }
+}
diff --git a/internal/host/host_test.go b/internal/host/host_test.go
index 2fea31c2d..733ad7c54 100644
--- a/internal/host/host_test.go
+++ b/internal/host/host_test.go
@@ -42,6 +42,7 @@ var expectedUnits = []string{
"carlos-dbread@.service",
"carlos-demo-build@.service",
"carlos-demo-builds.slice",
+ "carlos-demo-snapshot@.service",
"carlos-edge.service",
"carlos-hibernate-verify.service",
"carlos-hibernate-verify.timer",
diff --git a/internal/host/units/carlos-demo-snapshot@.service b/internal/host/units/carlos-demo-snapshot@.service
new file mode 100644
index 000000000..82e9a8d07
--- /dev/null
+++ b/internal/host/units/carlos-demo-snapshot@.service
@@ -0,0 +1,59 @@
+[Unit]
+Description=DEMO-CLAIM-SNAPSHOT
+BindsTo=carlos-instance-control.service
+After=carlos-instance-control.service
+
+[Service]
+Type=exec
+RemainAfterExit=yes
+DynamicUser=yes
+ExecStart=/snapshot-worker __demo-snapshot
+WorkingDirectory=/work
+BindPaths=/var/lib/carlos-demo-snapshots/%i/work:/work
+BindReadOnlyPaths=/opt/carlos/carlos:/snapshot-worker
+Restart=no
+KillMode=control-group
+RuntimeMaxSec=120
+TimeoutStopSec=5
+SendSIGKILL=yes
+OOMPolicy=kill
+MemoryMax=268435456
+MemorySwapMax=0
+TasksMax=32
+CPUQuota=50%
+LimitFSIZE=268435456
+UMask=0077
+Environment=HOME=/work TMPDIR=/work GOMEMLIMIT=192MiB
+PassEnvironment=
+SetLoginEnvironment=no
+StandardInput=null
+StandardOutput=null
+StandardError=null
+ProtectSystem=strict
+ProtectHome=yes
+TemporaryFileSystem=/data:ro /run:ro /var:ro /opt:ro /etc:ro /tmp:ro /dev/shm:ro /dev/mqueue:ro /dev/pts:ro
+PrivateDevices=yes
+PrivateIPC=yes
+PrivatePIDs=yes
+PrivateNetwork=yes
+NetworkNamespacePath=
+RestrictAddressFamilies=AF_UNIX
+IPAddressDeny=any
+IPAddressAllow=
+CapabilityBoundingSet=
+AmbientCapabilities=
+NoNewPrivileges=yes
+RestrictNamespaces=yes
+ProtectControlGroups=yes
+ProtectProc=invisible
+ProcSubset=pid
+ProtectKernelTunables=yes
+ProtectKernelModules=yes
+ProtectKernelLogs=yes
+ProtectClock=yes
+ProtectHostname=yes
+RemoveIPC=yes
+LockPersonality=yes
+RestrictRealtime=yes
+MemoryDenyWriteExecute=yes
+SystemCallArchitectures=native
diff --git a/main.go b/main.go
index feafc570e..5c19f423b 100644
--- a/main.go
+++ b/main.go
@@ -3,6 +3,7 @@
package main
import (
+ "context"
"fmt"
"io"
"log"
@@ -10,6 +11,7 @@ import (
"strings"
"github.com/carlosframework/platform/internal/cgroup"
+ "github.com/carlosframework/platform/internal/democlaim"
"github.com/carlosframework/platform/internal/edge"
"github.com/carlosframework/platform/internal/host"
"github.com/carlosframework/platform/internal/instanceexec"
@@ -34,6 +36,15 @@ func main() {
os.Exit(2)
}
cmd, args := os.Args[1], os.Args[2:]
+ if cmd == "__demo-snapshot" {
+ if len(args) != 0 {
+ log.Fatal(democlaim.ErrSnapshot)
+ }
+ if err := democlaim.RunSnapshotWorker(context.Background()); err != nil {
+ log.Fatal(err)
+ }
+ return
+ }
if cmd == "__registry-child" {
if err := host.RunRegistryChild(args); err != nil {
log.Fatal(err)