[AGENT-HOMES-001 PR-3] Machine homes: record the machine an agent runs on - #15
Conversation
Records the machine an agent actually runs on as first-class relay data, so PR-4 can grant cross-machine SSH between named homes. Modeling choice (the open item flagged for review): columns on users, not a new table. Agents are already users; a dedicated table would create a second identity space to keep in sync, and the plan calls for no second identity space. - 0047_agent_machine_homes.sql: additive nullable machine_id/label/runtime - one home per machine per community via partial unique index - label/runtime require machine_id (no orphan metadata) - community-scoped: same machine_id may exist in another community Tests: 14/14 store::user postgres tests, 13/13 migration tests (incl. the scoped_primary_key + tenant-scoping lints).
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Verified: the two 0047s are compatible once renumbered — proof attachedFollowing up on the version collision reported above. I applied the full chain against a real PostgreSQL instance with HW-017 renumbered to Setup: clean cluster, Result:
Integration behaviour verified (a task assigned to a machine-homed agent):
The two migrations touch disjoint tables ( Remaining action is still just the rename + bumping Note for fixture authors: |
CI attribution (attempt 3): the remaining reds are pre-existing desktop E2E flakes, not this diffA full 1. This PR changes no desktop code at all. Files under 2. The actual failing test is a Playwright click timeout, in a spec this PR never touches. This is the same failure family already documented on #33 ( 3. Several of the 9 "failures" are not tests — they are rollup aggregators. It re-reports an upstream shard result. The same is true of 4. The DB change itself is verified green out-of-band. The full 47-migration chain (this PR's Conclusion: the desktop E2E flake is a pre-existing trunk condition with no owner assigned. It is not caused by, and cannot be fixed from, a migrations-only diff. Flagging for a ruleset/ownership decision rather than merging past a red gate. |
…-homes/pr3-machine-homes
…b.com/mfethe1/buzz into feature/agent-homes/pr3-machine-homes
…-homes/pr3-machine-homes
…-homes/pr3-machine-homes
CI builds its test database from schema/schema.sql, the declarative snapshot, not by replaying migrations/. 0047 added the machine-home columns only to the migration, so all 5 store::user::postgres_tests::*machine* tests failed CI with 'column machine_id of relation users does not exist' while passing locally. Mirrors the three columns, four CHECK constraints, and the partial unique index into the users table in schema.sql. Verified by building two databases from scratch and diffing catalogs: migration-replay vs schema.sql are IDENTICAL on users columns, machine constraints, and indexes. store::user::postgres_tests: 14 passed, 0 failed against a schema.sql-built DB, covering all 5 that CI reported red.
CI builds its database with 'pgschema apply --file schema/schema.sql', and
pgschema does not reproduce multi-column CHECK constraints. Declaring them in
schema.sql is not enough - they are silently absent from the live catalog.
test_label_without_machine_id_is_rejected caught this: it expects a bare
machine_label with no machine_id to be rejected, which passed on a
migration-replayed DB and failed in CI.
Restores two constraints in the existing reconcile script, using its
idempotent DROP/ADD + verify-or-RAISE pattern:
- users.chk_users_machine_fields_require_machine_id (0047) - without it a
pgschema DB accepts an unaddressable agent home.
- tasks.chk_tasks_done_at_matches_status (0046, already on trunk) - same
gap, no test covered it; a task could be done with no done_at.
Verified against a real pgschema bootstrap: all chk_ constraints are now
IDENTICAL between migration-replay and pgschema+reconcile, and
store::user::postgres_tests is 14 passed / 0 failed on a CI-identical DB.
What
Records the machine an agent actually runs on as first-class relay data, so PR-4 can grant cross-machine SSH between named homes instead of raw hostnames.
Modeling choice (the open item flagged for review)
Columns on
users, not a dedicated table. Agents are alreadyusers; a separate table would create a second identity space to keep in sync, and the plan explicitly calls for no second identity space. Happy to flip this if review disagrees — it is the one decision the plan left open.Changes
0047_agent_machine_homes.sql— additive, all-nullablemachine_id/machine_label/machine_runtimemachine_label/machine_runtimerequiremachine_id(no orphan metadata)machine_idmay exist in another communityset_machine_home/clear_machine_home/get_machine_home/find_agent_by_machineBehavioral impact
None. Columns are nullable and unset; nothing reads them until PR-4. No relay restart, no backfill.
Verification (run locally against real Postgres)
store::user::postgres_tests— 14/14 pass, incl. collision + community-scoping invariantsruntime::migration— 13/13 pass, incl.scoped_primary_key_...andall_non_operator_global_tables_have_not_null_community_idlintscargo clippy -p buzz-db --all-targetsclean;cargo fmt --checkcleanPath B (sensitive-path: migration + identity) — requires review before merge.