Host Agent: - One-time local operator account bootstrap (PBKDF2-HMAC-SHA256, atomic 0600-permission write) gating the daemon's first unattended start via a new `setup` CLI subcommand. - Default control-plane URL now https://amcp.home.jerryyan.top (env var override unchanged). - Enrollment no longer requires a pre-issued token; falls back to zero-token self-service enrollment when none is configured. Cloud control plane: - CLOUD_SELF_SERVICE_ENROLLMENT_ENABLED (default false) opt-in flag. - SelfServiceEnrollmentAuthProvider + ChainedEnrollmentAuthProvider: configured tokens still take priority; self-service only applies when no token matches, preserving edge-host-enrollment's token-bound path. - Fixed a latent bug in sql_repository.py::enroll_host: the token-conflict lookup used `== enrollment_token_digest`, which SQLAlchemy compiles to `IS NULL` when the value is None, so every self-service enrollment after the first would have falsely collided with an existing NULL-digest host. Skipped that lookup entirely when the digest is None. Docs/deploy: .env.example, compose.yaml, compose.deploy.yaml, CLOUD_DEPLOYMENT.md, MACOS_IPHONE_SETUP.md updated for the new flag, URL default, and required `device-host-agent setup` step. Verification: 494 non-integration tests pass; openspec validate --strict passes. PostgreSQL-backed contract tests and full manual end-to-end verification were not run (no Postgres/Docker or reachable cloud-api in this environment); noted as unchecked in tasks.md 7.2/7.4.
This commit is contained in:
@@ -45,7 +45,7 @@ class SQLAlchemyCloudRepository:
|
||||
host_id: str,
|
||||
agent_instance_id: str,
|
||||
credential_digest: str,
|
||||
enrollment_token_digest: str,
|
||||
enrollment_token_digest: str | None,
|
||||
display_name: str | None,
|
||||
enrolled_at: datetime,
|
||||
) -> Any:
|
||||
@@ -72,11 +72,19 @@ class SQLAlchemyCloudRepository:
|
||||
)
|
||||
return _host_enrollment_from_row(existing)
|
||||
|
||||
token_owner = session.scalars(
|
||||
select(HostRow).where(
|
||||
HostRow.enrollment_token_digest == enrollment_token_digest
|
||||
)
|
||||
).first()
|
||||
# A NULL enrollment_token_digest marks self-service Hosts, which
|
||||
# never bind a shared token; comparing `== NULL` would otherwise
|
||||
# match every other self-service Host via SQL's `IS NULL` and
|
||||
# falsely report a token conflict.
|
||||
token_owner = (
|
||||
session.scalars(
|
||||
select(HostRow).where(
|
||||
HostRow.enrollment_token_digest == enrollment_token_digest
|
||||
)
|
||||
).first()
|
||||
if enrollment_token_digest is not None
|
||||
else None
|
||||
)
|
||||
if token_owner is not None:
|
||||
raise EnrollmentTokenConflictError(
|
||||
"enrollment token is already bound to another Host"
|
||||
@@ -109,11 +117,15 @@ class SQLAlchemyCloudRepository:
|
||||
and existing.enrollment_token_digest == enrollment_token_digest
|
||||
):
|
||||
return _host_enrollment_from_row(existing)
|
||||
token_owner = session.scalars(
|
||||
select(HostRow).where(
|
||||
HostRow.enrollment_token_digest == enrollment_token_digest
|
||||
)
|
||||
).first()
|
||||
token_owner = (
|
||||
session.scalars(
|
||||
select(HostRow).where(
|
||||
HostRow.enrollment_token_digest == enrollment_token_digest
|
||||
)
|
||||
).first()
|
||||
if enrollment_token_digest is not None
|
||||
else None
|
||||
)
|
||||
if token_owner is not None:
|
||||
raise EnrollmentTokenConflictError(
|
||||
"enrollment token is already bound to another Host"
|
||||
|
||||
Reference in New Issue
Block a user