opencode-swarm 7.121.3 → 7.122.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/cli/{curation-policy-10wnhpwn.js → curation-policy-cj1tpzr5.js} +2 -2
  2. package/dist/cli/{curator-ed91r7rw.js → curator-3rze3pd4.js} +8 -8
  3. package/dist/cli/{curator-llm-factory-q9veqj3h.js → curator-llm-factory-8rg0f77t.js} +8 -8
  4. package/dist/cli/{guardrail-explain-0vcaa7hj.js → guardrail-explain-hdsxa2c5.js} +9 -9
  5. package/dist/cli/{hive-promoter-dg6fk563.js → hive-promoter-dh38qd9m.js} +8 -8
  6. package/dist/cli/{index-5a3xsnzg.js → index-3r1w7xky.js} +1 -1
  7. package/dist/cli/{index-35xyj7gn.js → index-3sx27bxt.js} +26 -3
  8. package/dist/cli/{index-qad0m9bz.js → index-68aggz0v.js} +1 -1
  9. package/dist/cli/{index-fs2q8jyf.js → index-ahxrne50.js} +709 -550
  10. package/dist/cli/{index-x4fwtd59.js → index-gr7ssnj9.js} +3 -3
  11. package/dist/cli/{index-db82jxt7.js → index-j33zb3cx.js} +2 -2
  12. package/dist/cli/{index-g9eg7z93.js → index-jzpv74mq.js} +9 -9
  13. package/dist/cli/{index-0f800qg7.js → index-ny13nr0x.js} +2 -2
  14. package/dist/cli/{index-j8349ac0.js → index-rkd6qwjh.js} +1 -1
  15. package/dist/cli/{index-ft6jw816.js → index-xdsj4qtd.js} +3 -3
  16. package/dist/cli/index.js +8 -8
  17. package/dist/cli/{knowledge-escalator-8ajq1fhb.js → knowledge-escalator-sya06p12.js} +3 -3
  18. package/dist/cli/{knowledge-events-2sjy3aa7.js → knowledge-events-xzps61a9.js} +3 -1
  19. package/dist/cli/{knowledge-store-27cesthc.js → knowledge-store-qg66a93n.js} +1 -1
  20. package/dist/cli/{knowledge-validator-9keh3p8j.js → knowledge-validator-gar6wv4f.js} +4 -4
  21. package/dist/cli/{scan-cursor-qmsmmg1b.js → scan-cursor-nx5y5k7r.js} +2 -2
  22. package/dist/cli/{skill-generator-hkyxdc3j.js → skill-generator-nt5qxafq.js} +5 -5
  23. package/dist/db/index.d.ts +4 -0
  24. package/dist/db/sqlite-loader.d.ts +78 -0
  25. package/dist/hooks/cohort-cache.d.ts +44 -0
  26. package/dist/hooks/hive-promoter.d.ts +4 -3
  27. package/dist/hooks/host-boundary.d.ts +147 -0
  28. package/dist/hooks/incremental-verify.d.ts +3 -0
  29. package/dist/hooks/knowledge-events.d.ts +25 -2
  30. package/dist/hooks/knowledge-injector.d.ts +9 -1
  31. package/dist/hooks/knowledge-receipt-validator.d.ts +98 -0
  32. package/dist/hooks/micro-reflector.d.ts +3 -0
  33. package/dist/hooks/pr-auto-subscribe.d.ts +3 -0
  34. package/dist/hooks/promotion-evidence-store.d.ts +33 -0
  35. package/dist/index.js +362 -355
  36. package/dist/services/knowledge-diagnostics.d.ts +12 -0
  37. package/dist/session/snapshot-writer.d.ts +5 -0
  38. package/dist/state.d.ts +11 -0
  39. package/package.json +3 -2
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Shared receipt validator (issue #1849).
3
+ *
4
+ * One validator that enforces the terminal-receipt contract for BOTH the
5
+ * `knowledge_receipt` tool AND the `delegate-ack-collector`. Reads the
6
+ * authoritative event log and rejects forged / expired / conflicting /
7
+ * non-trace receipts while keeping idempotent retries free of double-counting.
8
+ *
9
+ * Authority contract (per issue #1849 §3):
10
+ * - trace/result delivery proves shown/retrieved only;
11
+ * - a validated terminal receipt is the durable audit outcome;
12
+ * - applied counters derive ONLY from validated `applied` receipts;
13
+ * - ignored/contradicted/no_relevant remain visible but are not application credit.
14
+ *
15
+ * Uniqueness grain: ONE terminal per (trace_id, knowledge_id). A trace surfaces a
16
+ * set of entries; for each entry at most one terminal outcome is accepted.
17
+ * Idempotent retry of the SAME outcome is accepted (not re-emitted, not
18
+ * double-counted); a DIFFERENT outcome for the same (trace_id, knowledge_id)
19
+ * is a conflicting-terminal rejection. The delegate ack path legitimately
20
+ * emits multiple terminals per trace (one per shown directive) — that is fine
21
+ * because each directive has a distinct knowledge_id.
22
+ */
23
+ import { type KnowledgeEvent, type RetrievedEvent } from './knowledge-events.js';
24
+ /** Terminal outcomes the validator accepts. */
25
+ export type ReceiptOutcome = 'applied' | 'ignored' | 'contradicted' | 'violated' | 'n_a' | 'no_relevant';
26
+ /** A single item being filed in a receipt. */
27
+ export interface ReceiptItem {
28
+ id: string;
29
+ outcome: Exclude<ReceiptOutcome, 'no_relevant'>;
30
+ reason?: string;
31
+ }
32
+ export interface ReceiptValidationContext {
33
+ directory: string;
34
+ /** The retrieval trace this receipt accounts for, or `'none'`. */
35
+ trace_id: string;
36
+ session_id: string;
37
+ task_id?: string;
38
+ phase?: string;
39
+ agent: string;
40
+ items: ReceiptItem[];
41
+ /** True when the receipt asserts nothing relevant was surfaced. */
42
+ no_relevant_knowledge: boolean;
43
+ }
44
+ export type ReceiptRejectReason = 'trace_not_found' | 'id_not_in_trace' | 'wrong_session' | 'expired' | 'duplicate_conflicting_terminal' | 'invalid_outcome' | 'empty_receipt';
45
+ export type ReceiptValidationResult = {
46
+ ok: true;
47
+ /** Items that should be freshly emitted (excludes idempotent skips). */
48
+ accepted: ReceiptItem[];
49
+ /** Items already recorded with the same outcome — skip emitting. */
50
+ idempotent_skips: ReceiptItem[];
51
+ /** The matched retrieval trace, or null for the real-empty (`'none'`) path. */
52
+ trace: RetrievedEvent | null;
53
+ /** True when this receipt closes the loop with a `no_relevant` terminal. */
54
+ closes_no_relevant: boolean;
55
+ /**
56
+ * Per-item rejections when SOME items were accepted but others were not
57
+ * (id_not_in_trace / conflicting). Present only when non-empty.
58
+ */
59
+ rejected_items?: Array<{
60
+ item: ReceiptItem;
61
+ reason: ReceiptRejectReason;
62
+ }>;
63
+ } | {
64
+ ok: false;
65
+ rejected: true;
66
+ reason: ReceiptRejectReason;
67
+ detail: string;
68
+ /** Items rejected by per-item checks (id_not_in_trace / conflicting). */
69
+ rejected_items?: Array<{
70
+ item: ReceiptItem;
71
+ reason: ReceiptRejectReason;
72
+ }>;
73
+ };
74
+ /**
75
+ * Receipt validity window. A receipt must be filed within this many
76
+ * milliseconds of the retrieval trace's timestamp. Generous constant (30 min)
77
+ * covers slow agents. NOTE: this is a compile-time constant, NOT configurable
78
+ * via the config schema — raise an issue if runtime configurability is needed.
79
+ */
80
+ export declare const RECEIPT_VALIDITY_MS: number;
81
+ /** The `trace_id` sentinel meaning "no retrieval occurred". */
82
+ export declare const NO_TRACE_SENTINEL = "none";
83
+ /**
84
+ * Validate a receipt against the authoritative event log. Never throws — any
85
+ * internal error fails open by accepting the items (the agent's work must not
86
+ * be blocked by a validator crash). Rejections are AUDITED by the caller via
87
+ * the returned reason; the validator itself does not write audit events to
88
+ * keep it side-effect-free and testable.
89
+ */
90
+ export declare function validateReceipt(ctx: ReceiptValidationContext): Promise<ReceiptValidationResult>;
91
+ declare function findTrace(events: KnowledgeEvent[], traceId: string): RetrievedEvent | null;
92
+ declare function isTerminalReceipt(e: KnowledgeEvent): boolean;
93
+ export declare const _internals: {
94
+ findTrace: typeof findTrace;
95
+ isTerminalReceipt: typeof isTerminalReceipt;
96
+ VALID_OUTCOMES: ReadonlySet<string>;
97
+ };
98
+ export {};
@@ -80,6 +80,9 @@ export interface MicroReflectorInput {
80
80
  tool: unknown;
81
81
  args?: unknown;
82
82
  sessionID?: unknown;
83
+ /** (#1849) callID from the SDK tool.execute.after input — used to recover the
84
+ * snapshot args (the SDK toolAfter input has NO args field). */
85
+ callID?: unknown;
83
86
  }
84
87
  export interface MicroReflectorOutput {
85
88
  output?: unknown;
@@ -23,6 +23,9 @@ export interface PrAutoSubscribeHook {
23
23
  tool: string;
24
24
  sessionID?: string;
25
25
  args?: unknown;
26
+ /** (#1849) SDK tool.execute.after input carries callID (not args); used
27
+ * to recover the snapshot args via resolveToolAfterContext. */
28
+ callID?: string;
26
29
  }, output: {
27
30
  output?: unknown;
28
31
  args?: unknown;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Promotion-evidence store (issue #1849 §B2).
3
+ *
4
+ * Append-only, FIFO-bounded JSONL store for {@link PromotionEvidenceRecord}s
5
+ * produced when a validated terminal receipt (applied/violated/contradicted) is
6
+ * filed. This is the wiring that finally feeds #1847's
7
+ * {@link evaluatePromotionPolicy} consumer (previously inert "until #1849
8
+ * produces real receipts").
9
+ *
10
+ * Per-worktree by design: promotion evidence records THIS worktree's observed
11
+ * applications. It is intentionally NOT a member of `KNOWLEDGE_FAMILY` (the
12
+ * linked-cohort shared-artifact manifest), matching the precedent set by
13
+ * `src/turbo/epic/promotion-evidence.ts`. It lives under the project-root
14
+ * `.swarm/` (via {@link validateSwarmPath}), NOT the link-aware shared store
15
+ * dir, so it stays per-worktree.
16
+ */
17
+ import type { PromotionEvidenceRecord } from './knowledge-types.js';
18
+ /** Resolve the promotion-evidence log path under the project-root `.swarm/`. */
19
+ export declare function resolvePromotionEvidencePath(directory: string): string;
20
+ /**
21
+ * Append validated promotion-evidence records. Fail-open + bounded: a write
22
+ * error logs and continues (the receipt event itself is the authoritative
23
+ * record; promotion evidence is a derived consumer). FIFO-trims the log when it
24
+ * exceeds {@link MAX_PROMOTION_EVIDENCE_ENTRIES}.
25
+ */
26
+ export declare function appendPromotionEvidence(directory: string, records: PromotionEvidenceRecord[]): Promise<void>;
27
+ /**
28
+ * Load all promotion-evidence records, grouped by entry_id. This is the loader
29
+ * that replaces the inert stub at `hive-promoter.ts:loadPromotionEvidence`.
30
+ * Returns an empty object when the file is absent (no evidence yet — the
31
+ * conservative default). Never throws.
32
+ */
33
+ export declare function loadPromotionEvidenceByEntry(directory: string): Promise<Record<string, PromotionEvidenceRecord[]>>;