Commit Graph
14 Commits
Author SHA1 Message Date
ex_tianzy e4c3a8ad4e feat(tasks): persist encrypted result handoff and recover received tasks
Add signed device-scoped task state/result endpoints and AES-GCM result outbox. Atomically claim original-message replies, reject cross-user/stale/expired tasks, preserve unknown platform receipts without blind replay, and retain ambiguous ciphertext for at most seven days. Maintain legacy synchronous compatibility and clarify stale deployment-plan diagnostics. Validation: ECS suite 227 passed/2 skipped, later outbox guards 12 passed, deployment diagnostics 54 passed. Real ECS/PostgreSQL/platform failure acceptance remains pending.
2026-11-05 10:24:55 +08:00
ex_tianzy db116284b1 fix(deploy): keep broker credentials active during update rollback
Preserve broker environment and the active keyring mount when rolling application images back. Guard with update staging tests: 54 passed. No runtime services changed.
2026-11-04 18:16:53 +08:00
ex_tianzy 660d7a48d2 feat(tasks): track authenticated native progress until final reply
Renew broker idle waits only for encrypted current-task progress, keep an absolute deadline and binding/session/worker fences, and retain original-message reply deduplication. Add guarded prepare-update staging that reuses the active broker key material and application configuration. Validation: 216 passed, 2 skipped; guarded update and long-task routing covered with synthetic Docker configuration and loopback WebSocket tests. Real ECS build and acceptance remain pending.
2026-11-04 18:12:12 +08:00
ex_tianzy ce965aaf58 fix(deploy): tolerate absent Docker health state during router recovery
Containers without a configured HEALTHCHECK omit State.Health. Direct map
field access in the new inspect template made recovery prechecks fail on
longconn/edge before the router path could be repaired. Use a guarded map
index and report health=none without weakening image/config/key checks.

Distinguish service lookup errors from inspect/template failures instead of
misreporting every query failure as no unique container. Identify the
container-inspect stage in safe command errors.

Add regressions for absent health state through state and the full partial
router repair, plus accurate inspect failure classification. Validation:
265 passed, 3 skipped (no real PostgreSQL), 30 existing warnings; tool tests
52 passed. Python 3.7 syntax and staged diff checks pass.
No remote keys/configuration or containers were changed; rerun the existing
repair-router plan after updating, do not prepare or activate again.
2026-11-04 16:33:35 +08:00
ex_tianzy 8a94d60155 fix(deploy): repair missing router public-key path after partial activation
Live evidence showed a healthy candidate connector and a restarting router:
legacy router environment omitted HN_CONNECTOR_PUBLIC_KEY, so the new routing
verifier tried runtime/pki/connector.pub instead of the existing /trust mount.

Resolve the public key from the existing read-only trust bind, set its path
in new overlays, and actually load it during isolated runtime checks. Add
repair-router for a known healthy candidate connector: preserve credential
keys and live configuration, back up overlay/plan, add only the router path,
update integrity metadata, probe, and recreate router alone with --no-deps.
Retries do not regenerate keys or overwrite repair backups.

Add read-only state including stopped/restarting containers and fixed startup
error classes, including stderr, without printing raw logs or credentials.
Identify command stage/exit code and activation progress. Permit rollback
of known stopped candidate targets and old overlays without requiring the
new router key; unknown images still fail closed.

Validation: full suite 262 passed, 3 skipped (real PostgreSQL unavailable),
30 existing warnings; final tooling suite 50 passed after the added CLI
rollback regression. Python 3.7 syntax and staged diff checks pass.
No live repair was executed by this agent; operator must run repair-router
and verify health and the real client handshake on ECS.
2026-11-04 16:27:47 +08:00
ex_tianzy 2657146334 fix(deploy): preserve legacy environment and diagnose prepared plans safely
The old initializer defaults HN_ENVIRONMENT to development, while migration
validation required the literal production and combined database/platform
prerequisites into one opaque error. Preserve supported environment identity
namespaces without editing the live .env; still require PostgreSQL and fixed
HTTPS/WSS endpoints for every existing-server migration. Match supported
boolean spellings and report failing field names without credential values.

Add read-only diagnose for an existing prepared plan so an earlier failed
prepare can be reviewed without deleting or regenerating its keyring. Move
future prerequisite validation before private directory/key generation.

Validation: 253 passed, 3 skipped (real PostgreSQL unavailable), 30 existing
warnings; 40 deployment-tool tests including 11 new compatibility/redaction
cases. Python 3.7 syntax and staged diff checks pass. Actual ECS diagnosis
must still confirm the current failing field; no live config or key changed.
2026-11-04 13:59:22 +08:00
ex_tianzy d3ce0099b7 fix(deploy): include legacy longconn profile during migration checks
The exported live-deployment baseline declares longconn under a Compose
profile. Default profile filtering can omit the already-running receiver
and make preflight report an unexpected service set.

Explicitly select only the known longconn profile for config and targeted
migration commands. Preserve strict service-set validation and report only
missing/extra service names, never resolved environment or secrets. Up still
targets connector/router with --no-deps, without starting another receiver.

Add regressions for profiled service omission and safe mismatch diagnostics.
Validation: 242 passed, 3 skipped (no real PostgreSQL), 30 existing dependency
warnings. Tool-specific coverage: 29 passed. Python 3.7 syntax and diff pass.
Actual ECS preflight must be rerun to verify its current service set; no
remote configuration, key material or running containers were changed.
2026-11-04 12:27:49 +08:00
ex_tianzy da1b4230b9 feat(deploy): add guarded existing-ECS broker migration tooling
Discover the current Compose project and all override files from container
labels. Add read-only preflight plus prepare/check/build/activate/rollback
commands without editing the running .env, CA, database volumes or unrelated
services. Preserve heterogeneous application image identities for rollback.

Prepare a private keyring, independent router credential, pinned source
snapshot and additive connector/router overlay. Refuse key overwrite and
configuration/image drift. Build offline from the exact existing ARM64
runtime, smoke import and validate role settings through stdin-only inputs.
Require explicit v2 client readiness before activation and recreate only
connector/router with --no-deps. Document actual backup/image evidence,
current client limitation and token-lifecycle rollback boundaries.

Validation: 239 passed, 3 skipped (real PostgreSQL absent), 30 existing
dependency deprecation warnings. Add 26 mocked Docker policy tests; host
script parses as Python 3.7, CLI help/docs/diff checks pass. Docker policy
mocks are not actual Compose or ARM64 build validation.

No remote files, keys, credentials, containers or live configuration were
changed. Stage 5 operational acceptance remains pending actual ECS build,
real databases/platform, v2 client, key recovery and controlled rollout.
2026-11-04 12:18:43 +08:00
ex_tianzy d1ab834ecb feat(lifecycle): add stage 4 authoritative unbind and durable task routing
Unify broker-mode binding changes in database transactions: advance device
generation, invalidate pending authorizations/tasks and prior pairing-code
epochs, and persist audit plus invalidation outbox. Add authenticated device
unbind alongside robot/admin paths. Pairing codes are hashed, generation-
fenced and consumed atomically with binding.

Replay Redis invalidation effects without undoing committed unbind. Guard
online cleanup and delayed kill events by generation. Introduce a separate
router admission credential with no platform-event injection authority.
Router verifies signed nonce-bound internal admission on handshake, task
traffic and periodic checks; reject stale sessions and control-plane outages.

Persist task owner/device/generation/session/worker and original message
mapping. Sign routing metadata, verify late results, claim replies once and
mark ambiguous/crashed tasks unknown instead of replaying writes. Fence
notifications across same-user rebind. Release in-memory slots/waiters even
when database or Redis cleanup fails.

Validation: 213 passed, 3 skipped (real PostgreSQL not configured), 30 existing
uvicorn/websockets deprecation warnings. New lifecycle coverage: 28 tests,
including real loopback WebSocket isolation, reverse completion, missed kill,
periodic unbind checks, outbox recovery, transaction rollback and cleanup
failures. Syntax, docs and staged diff checks pass.

Default legacy mode remains unchanged. Broker mode now requires coordinated
router admission configuration and a v2 client handshake. No production ECS
configuration, real credentials or client installer was changed. PostgreSQL,
real Redis multi-node, ARM64 and actual Work/client rollout remain stage 5.
2026-11-04 11:43:53 +08:00
ex_tianzy 93bfbca83a feat(credentials): add stage 3 authenticated OAuth and access-token issuance
Add explicit legacy/broker configuration. Broker mode requires a protected
keyring, product-approved permission profiles and enabled platform OAuth;
production requires PostgreSQL. Default legacy behavior stays unchanged.

Wire the broker to v2 signed device status, authorization start/status and
access-token issuance routes. Bind proofs to protocol, environment, app,
method/path and complete payload; verify nonce, certificate, owner and
binding generation. Add an additive generation migration and return the
current generation in binding receipts or authenticated bootstrap status.

Persist encrypted OAuth state and atomically claim callbacks. Verify the
actual consenting user, supersede older pending authorization intents and
recheck bindings/transactions before credential writes and issuance.
Preserve rotated credentials if unbind occurs mid-refresh, but deny issuance.
Return an explicit access-only response and record metadata-only audit.

Extract shared legacy device authentication so notifications do not depend
on the business proxy module. Broker mode omits legacy refresh/claim/start
and /work/api routes; authorization cards reference server-owned v2
transactions. Document signatures, configuration and migration boundaries.

Validation: 185 passed, 3 skipped (real PostgreSQL not configured), with
15 existing dependency deprecation warnings. New API coverage: 38 passed,
1 real PostgreSQL case skipped. AST, docs and staged diff checks pass.

No production deployment, key generation, client upgrade or real Work API
calls were performed. Compose/mount configuration, full unbind/connection
compensation and durable message-task lifecycle remain later stages.
2026-11-04 10:52:16 +08:00
ex_tianzy 02d433250f feat(credentials): add stage 2 centralized broker and refresh fencing
Add an internal CredentialBroker that serializes refresh and authorization
by environment/app/user using renewable Redis leases. Re-read credentials
under the lease and persist rotated pairs with expected-version CAS before
returning an explicit access-only grant. Verify the actual platform user,
remaining lifetime and scopes; never return refresh tokens from the broker.

Persist source-version refresh attempts before platform calls. Timeouts,
cancellation, lease loss, malformed responses and ambiguous database errors
fence reuse of the old rotating refresh token, including after restart.
A new authorization can establish a new version without stale overwrite.

Add a strict, separate private Work v1 OIDC adapter while preserving legacy
OAuth method behavior. Enable fakeredis Lua test support for Redis lease
renewal tests. Document stage boundaries, recovery limitations and testing.

Validation: 147 passed, 2 skipped (real PostgreSQL not configured), with
15 existing uvicorn/websockets deprecation warnings. New broker/adapter
coverage: 45 tests. AST, runtime opt-in boundary and diff checks pass.
An earlier Windows temp-file replace failure in a legacy client test passed
both isolated rerun and the final full suite; no client code was changed.

No public credential/OAuth routes are wired, no production database/key is
initialized, and no real Work authorization, refresh or ECS deployment was
performed. Authenticated access-token issuance, state transactions, binding
checks and unbind integration remain subsequent stages.
2026-11-04 10:30:27 +08:00
ex_tianzy 71b9678d22 feat(credentials): add stage 1 encrypted server-side credential storage
Introduce an opt-in AES-256-GCM credential store keyed by environment,
application and principal. Bind ciphertext to identity, version and key ID
with authenticated data; support retained decryption keys and active-key
rotation. Use expected-version CAS to reject duplicate or stale writers.

Keep token values and scopes encrypted at rest, hide token fields from
object repr, and use fixed errors without credential contents. Add tests
for identity substitution, authenticated tampering, wrong keys, rotation,
persistence, concurrent writers and malformed inputs. Include an opt-in
PostgreSQL test using an isolated schema.

Validation: 102 passed, 2 skipped (no real PostgreSQL URL), 15 existing
uvicorn/websockets deprecation warnings. Python AST and diff checks pass.

This is stage 1 only: no public routes or existing OAuth/refresh behavior
are changed, no production key/database is initialized, and no ECS
runtime deployment or real platform requests were performed. Broker,
centralized refresh, access-token-only issuance and unbind lifecycle
integration remain subsequent stages. See deployable/CREDENTIAL_MIGRATION.md.
2026-11-04 10:04:42 +08:00
ex_tianzy f5a38e0808 Add device-bound robot notifications and automatic OAuth cards 2026-10-28 16:33:14 +08:00
ex_tianzy b774941890 Add self-contained relay deployment project and operational guidance 2026-10-27 17:51:43 +08:00