learning_ai_common_plat/services/platform-service
saravanakumardb1 e06b730161 feat(platform-service): fleet factory enrollment + scoped rotatable tokens (§12)
Adds factory enrollment + a scoped, rotatable credential model for the fleet
coordinator (trust boundary, §12/§18). Tokens are stored HASHED at rest (sha256 —
the same primitive the auth module uses for verify/magic-link tokens); the
high-entropy plaintext is returned exactly once at enroll/rotate and never persisted.

- enrollment.ts: enrollFactory (create/link factory + issue token), rotateToken
  (new active token; prior marked `rotating` with a grace overlap so an in-flight
  worker isn't cut off), revokeToken (immediate), verifyToken (constant-time hash
  compare; revoked/expired-grace → null; updates lastUsedAt). Scope = {productId,
  factoryId, capabilities[]}.
- Gated enforcement: enforceFactoryToken() on POST /fleet/factories/heartbeat and
  POST /fleet/claim, active only when FLEET_REQUIRE_FACTORY_TOKEN is on (default
  OFF — existing behavior/tests unchanged). When on: missing/invalid/revoked → 401;
  out-of-scope productId/capability/factory → 403; and the claim is CONSTRAINED to
  the verified token scope. Does not touch scheduler scoring or the claim CAS.
- types.ts: FleetFactoryTokenDoc + Enroll/Rotate/Revoke request schemas.
- repository.ts: fleet_factory_tokens collection + CRUD + findByHash.
- routes.ts (additive): POST /fleet/factories/enroll, /:id/token/rotate,
  /:id/token/revoke (user auth + productId + Zod).
- cosmos-init.ts: register fleet_factory_tokens (/productId).

Also hardens the artifact routes (review fixes): listArtifactsByJob is now
productId-scoped (GET /fleet/jobs/:id/artifacts threads the request productId), and
artifact upload uses the request/auth productId authoritatively (a spoofed
body.productId no longer overrides it).

Tokens hashed at rest; plaintext shown once; no new crypto schemes; productId on
every doc; no any/console.log; enforcement default OFF.
2026-05-30 00:05:52 -07:00
..
scripts chore(platform): document script CLI output 2026-05-04 16:45:42 -07:00
src feat(platform-service): fleet factory enrollment + scoped rotatable tokens (§12) 2026-05-30 00:05:52 -07:00
.gitignore feat(services): add platform-service (auth, audit, flags, notifications, blob) 2026-02-12 11:39:00 -08:00
Dockerfile fix(docker): INFRA-gap-02 unblock full-stack docker compose up 2026-04-16 15:48:32 -07:00
package.json feat(platform): add /devops page with platform common devops package 2026-05-11 03:38:06 +00:00
POSTAL_SMTP_SETUP.md feat(platform-service): add smtp email delivery and postal setup 2026-03-14 05:52:28 +00:00
tsconfig.json feat(services): add platform-service (auth, audit, flags, notifications, blob) 2026-02-12 11:39:00 -08:00
vitest.config.ts fix(ci): add --pool forks to all vitest test scripts to fix kill EPERM on Node v25 2026-03-27 23:23:38 -07:00