feat(v1.1.9): QueueService trait + Postgres impl + Services bundle wiring

- shared/services.rs: Services::new gains queue: Arc<dyn QueueService>
  positionally after users (mirrors v1.1.8's append of users).
  with_noop_services adds NoopQueueService.
- manager-core/queue_service.rs: QueueServiceImpl wraps QueueRepo with
  script-as-gate authz on AppQueueEnqueue. enqueue clamps max_attempts
  to [1,20] and delay_ms to [0, 86_400_000ms]. depth/depth_pending are
  read-only — no authz check (scripts in the app can see their own
  queue depths). cx.principal threads through as enqueued_by_principal
  (forensic only).
- manager-core/authz.rs: AppQueueEnqueue(AppId) capability — script:write
  scope, granted to editor+ (same trust shape as AppPubsubPublish).
- picloud/lib.rs: wires PostgresQueueRepo + QueueServiceImpl into
  Services::new alongside the existing v1.1.7+ services.
- 11 sdk test binaries + manager-core/realtime_authority.rs updated to
  pass NoopQueueService to Services::new.

Unit tests cover empty queue_name reject, max_attempts clamping
(0/21 → invalid), delay_ms negative-reject, anonymous principal skips
authz, depth/depth_pending pass-through.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-06-06 19:30:34 +02:00
parent f6c7ab6f7c
commit 73e19ca626
15 changed files with 371 additions and 2 deletions

View File

@@ -261,6 +261,19 @@ pub async fn build_app(
app_secrets_repo.clone(),
users.clone(),
));
// v1.1.9 durable per-app queues. Producers write to queue_messages
// via QueueService; the dispatcher's queue arm (commit 6) consumes
// claimed messages and fires the registered queue:receive trigger.
let queue_repo: Arc<dyn picloud_manager_core::queue_repo::QueueRepo> =
Arc::new(picloud_manager_core::queue_repo::PostgresQueueRepo::new(
pool.clone(),
));
let queue: Arc<dyn picloud_shared::QueueService> = Arc::new(
picloud_manager_core::queue_service::QueueServiceImpl::new(
queue_repo.clone(),
authz.clone(),
),
);
let services = Services::new(
kv,
docs,
@@ -273,6 +286,7 @@ pub async fn build_app(
secrets,
email,
users.clone(),
queue,
);
let engine = Arc::new(Engine::new(Limits::default(), services));