feat(server): W4-A integration endpoints and contract gaps

- POST /acquisition-plans: manual submit via download.plan -> download.submit
  (same authorization/audit/idempotency path as the agent), slotId or entityId
- read-only /media-assets, /asset-locations, /asset-unit-coverage, /path-bindings,
  /reconcile-runs, /server-mappings, /artifacts, GET /title-aliases/{id};
  unimplemented write endpoints removed from api.ts; registry test now checks both directions
- candidate evaluation upsert per (slot, source_release) + migration 0022 dedupe/unique index
- organization records expose downloadTaskId (+ list filter); inventory adds
  subscribed/candidateReasons; feed sources expose derived possibleGap
- GET /events?after=&limit= JSON replay page for API key callers (same sse_event table)
- preference tag revision history from audit_event; subscriptions/identities/aliases
  lists carry mediaEntityTitle; subscription q/mediaKind search; slot subscriptionId
  filter + currentAsset summary; policy preview samples carry title/reasons
- DecisionSummary, IdentityRevisionList, ReleaseIdentityResult, PolicyPreviewSummary exported from contracts

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-27 21:10:02 +08:00
1 parent ea4c384664
commit d3ab54f2bd
34 files changed
+1083 -123

No files matched your search

+22
View File
@@ -216,3 +216,25 @@ export function parseEventPayload<T extends EventType>(type: T, payload: unknown
const r = schema.safeParse(payload);
return r.success ? (r.data as EventPayload<T>) : null;
}
/**
* 事件补读(JSON,给 API Key 调用者轮询;EventSource 带不了 Bearer)。
* GET /events 带 limit 参数(或 Accept 只要 application/json)时返回这一页,否则是 SSE 流。
*/
export const EventReplayQuery = z.object({
after: z.coerce.number().int().nonnegative().default(0),
limit: z.coerce.number().int().min(1).max(1000).optional(),
});
export type EventReplayQuery = z.infer<typeof EventReplayQuery>;
export const EventReplayPage = z.object({
items: z.array(EventEnvelope),
/** 下次请求的 after(本页最后一条 seq;空页时等于请求的 after) */
nextAfter: z.number().int().nonnegative(),
hasMore: z.boolean(),
/** 当前最大 seq */
latestSeq: z.number().int().nonnegative(),
/** true:after 早于保留窗口(已裁剪),应重新拉取业务快照后从 latestSeq 续读 */
gap: z.boolean(),
});
export type EventReplayPage = z.infer<typeof EventReplayPage>;