Skip to content

fix(daemon): persist machine identity in machine.json#138

Merged
vreshch merged 1 commit intomasterfrom
feature/machine-identity-persistence
Apr 17, 2026
Merged

fix(daemon): persist machine identity in machine.json#138
vreshch merged 1 commit intomasterfrom
feature/machine-identity-persistence

Conversation

@vreshch
Copy link
Copy Markdown
Contributor

@vreshch vreshch commented Apr 17, 2026

Summary

Split machine.{id,name} into its own file ~/.agentage/machine.json so deleting or regenerating config.json no longer mints a fresh UUID and creates a ghost machine in the hub dashboard.

Resolution order at loadConfig:

  1. machine.json if present — authoritative
  2. Legacy machine block from config.json — migrated into machine.json
  3. Fresh randomUUID() + hostname() — written to machine.json

saveConfig now writes machine.json alongside config.json. The machine block stays mirrored in config.json for back-compat reads (dashboards, logs, anything inspecting the raw file).

Repro that motivated this

After merging #135, I told the user to delete config.json to regenerate it in the new 0.18 shape. The daemon re-registered with a new UUID, and the old machine (same hostname, old UUID) stuck around in Supabase as a ghost — two "vreshch-home-pc" entries in the dashboard.

Test plan

  • npm run verify — 507 tests pass (4 new, covering: first run creates machine.json; identity survives config.json deletion; legacy migration from old config.json block; machine.json authoritative when both exist; saveConfig writes both)
  • Manual on vreshch-home-pc: delete config.json, run agentage status, confirm machine.id is unchanged

Move machine.{id,name} to its own file ~/.agentage/machine.json so
deleting or regenerating config.json doesn't mint a fresh UUID and
create a ghost machine in the hub dashboard.

Resolution order at loadConfig:
1. machine.json if present (authoritative)
2. legacy machine block from config.json → migrated into machine.json
3. freshly minted UUID + hostname (written to machine.json)

saveConfig now writes machine.json alongside config.json; the machine
block stays mirrored in config.json for back-compat reads.

Repro that motivated this: user deletes config.json to adopt the 0.18
shape, daemon re-registers with a new UUID, the old machine sticks
around in Supabase as a ghost.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 17, 2026

🎉 PR Validation ✅ PASSED

Commit: f53fe324a6f0821a0a84460c3d26ceec3efd62f2
Branch: feature/machine-identity-persistence

Checks:

  • ✅ Release guard (no version/changelog changes)
  • ✅ Dependencies installed
  • ✅ Type check passed
  • ✅ Linting passed
  • ✅ Format check passed
  • ✅ Tests + coverage passed
  • ✅ Build successful

Ready to merge!


🔗 View workflow run
⏰ Generated at: 2026-04-17T22:59:38.459Z

@vreshch vreshch merged commit 8b57c4f into master Apr 17, 2026
1 check passed
@vreshch vreshch deleted the feature/machine-identity-persistence branch April 17, 2026 23:00
vreshch added a commit that referenced this pull request Apr 19, 2026
## Summary

Two follow-ups to the config-defaults work (PRs #135, #138):

**Agents (scanner):**
- `src/discovery/scanner.ts` — added `IGNORE_DIRS` set (`node_modules`,
`.git`, `.github`, `.github-private`, `.claude`, `dist`, `build`,
`.next`, `coverage`, `.turbo`, `.cache`) and skip them in `getAllFiles`.
Pointing a discovery dir at a repo with dependencies no longer picks up
ghost agents shipped inside packages or checked into build output.

**Projects (discovery):**
- `src/projects/projects.ts` — `discoverProjects` now accepts `string |
string[]`, walks recursively (depth cap 5), stops descending once it
finds a `.git` dir (repo boundary), and skips the same ignore set. Old
one-level behavior is gone.
- `src/commands/projects.ts` — `agentage projects discover` with no path
now reads `getProjectsDirs(loadConfig())` instead of defaulting to cwd.
Single-root setups in `projects.default` drive the walk.

Unblocks: pointing `projects.default` at `~/projects` finds nested repos
like `agentage/cli`, `agentage/web`, `agents` automatically.

## Test plan
- [x] `npm run verify` — 512 tests pass (5 new: scanner IGNORE_DIRS,
projects recursive walk, projects ignore set, array-of-roots dedupe,
repo-boundary stop; 2 existing projects cmd tests updated for new
signature).
- [ ] Manual: `agentage projects discover` (no args) on the dev machine
— confirm it walks `projects.default` and finds repos without
cwd-dependent behaviour.
- [ ] Manual: `agentage status --set-default
/home/vreshch/projects/agents/plugins` then `agentage agents --refresh`
— confirm no ghost agents from `node_modules`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant