Skip to content

Commit 0d3340e

Browse files
committed
autonomy: personal.db -> agent.db; cover the last two matrix rows
The store file was still named personal.db. It holds state for any agent running unattended, not a species of agent — rename it, and note in place that it is opened lazily so an ordinary conversational agent never grows one. That claim is now a test rather than a comment: TestOrdinaryAgentGetsNoAutonomyStore creates a plain agent, exercises the admin surface against it, and asserts no agent.db appears — the governance machinery costs nothing until asked for. Also covers the remaining orthogonality row: an agent WITH an objective but WITHOUT autonomy still wakes on demand, reaching the policy gate rather than being refused for lacking autonomy. Autonomy governs unprompted action, not whether a human may ask. All four combinations of (objective, autonomous) now have a test.
1 parent d59b9c6 commit 0d3340e

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

‎cmd/admin_autonomy_test.go‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,37 @@ func TestDoctorAndInbox(t *testing.T) {
244244
t.Fatalf("inbox=%q", out)
245245
}
246246
}
247+
248+
// The fourth combination: an ordinary agent — no objective, not autonomous —
249+
// stays exactly as it was. In particular it grows no autonomy store, so the
250+
// governance machinery costs nothing until someone asks for it.
251+
func TestOrdinaryAgentGetsNoAutonomyStore(t *testing.T) {
252+
home := setupAgentHome(t)
253+
admin(t, tools.GwAgent, map[string]any{"action": "add", "name": "plain"})
254+
admin(t, tools.GwOverview, nil)
255+
256+
cfg, _ := gwconfig.Load()
257+
a := cfg.Agents["plain"]
258+
if a.Autonomous || a.Objective != "" || a.Paused {
259+
t.Fatalf("ordinary agent picked up autonomy settings: %+v", a)
260+
}
261+
if _, err := os.Stat(filepath.Join(home, ".memcode", "agents", "plain", "agent.db")); !os.IsNotExist(err) {
262+
t.Fatalf("ordinary agent grew an autonomy store (err=%v)", err)
263+
}
264+
}
265+
266+
// An agent with an objective but WITHOUT autonomy still works on demand — the
267+
// grant governs unprompted action, not whether a human may ask.
268+
func TestObjectiveWithoutAutonomyStillWakesOnDemand(t *testing.T) {
269+
setupAgentHome(t)
270+
admin(t, tools.GwAgent, map[string]any{"action": "add", "name": "ondemand", "objective": "Tidy notes"})
271+
cfg, _ := gwconfig.Load()
272+
if cfg.Agents["ondemand"].Autonomous {
273+
t.Fatal("became autonomous")
274+
}
275+
// Reaches the policy gate rather than being refused for lacking autonomy.
276+
out := admin(t, tools.GwWake, map[string]any{"agent": "ondemand"})
277+
if !strings.Contains(out, "blocked") || !strings.Contains(out, "policy") {
278+
t.Fatalf("expected the policy gate, not an autonomy refusal: %q", out)
279+
}
280+
}

‎internal/agent/autonomy/store.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ func Open(ctx context.Context, home string) (*Store, error) {
4444
if err := InitializeHome(home); err != nil {
4545
return nil, fmt.Errorf("initialize agent home: %w", err)
4646
}
47-
path := filepath.Join(home, "personal.db")
47+
// agent.db, not personal.db: this is state for any agent running
48+
// unattended, not a separate species of agent. Opened lazily, so an
49+
// ordinary conversational agent never grows one.
50+
path := filepath.Join(home, "agent.db")
4851
db, err := sql.Open("sqlite", path)
4952
if err != nil {
5053
return nil, fmt.Errorf("opening %s: %w", path, err)

‎internal/agent/autonomy/store_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestOpenInitializesHomeAndSchema(t *testing.T) {
1919
}
2020
defer s.Close()
2121

22-
for _, path := range []string{"personal.db", "policies", "workspace/generated", "workspace/scratch", "runs", "workers", ".memcode/jobs", ".memcode/sessions"} {
22+
for _, path := range []string{"agent.db", "policies", "workspace/generated", "workspace/scratch", "runs", "workers", ".memcode/jobs", ".memcode/sessions"} {
2323
if _, err := os.Stat(filepath.Join(home, path)); err != nil {
2424
t.Errorf("missing %s: %v", path, err)
2525
}

0 commit comments

Comments
 (0)