opencode-swarm 7.140.2 → 7.140.4

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 (113) hide show
  1. package/.opencode/skills/brainstorm/SKILL.md +1 -1
  2. package/.opencode/skills/ci-failure-batching/SKILL.md +11 -1
  3. package/.opencode/skills/ci-fix-monitor/SKILL.md +6 -4
  4. package/.opencode/skills/discover/SKILL.md +1 -1
  5. package/.opencode/skills/durable-session-state/SKILL.md +82 -0
  6. package/.opencode/skills/engineering-conventions/SKILL.md +1 -1
  7. package/.opencode/skills/issue-ingest/SKILL.md +13 -7
  8. package/.opencode/skills/issue-tracer/SKILL.md +1 -1
  9. package/.opencode/skills/orchestrating-subagents/SKILL.md +113 -0
  10. package/.opencode/skills/parallel-work-check/SKILL.md +1 -1
  11. package/.opencode/skills/swarm-ci-monitor/SKILL.md +5 -3
  12. package/.opencode/skills/swarm-pr-feedback/SKILL.md +30 -4
  13. package/.opencode/skills/writing-tests/SKILL.md +1 -1
  14. package/dist/agents/reviewer-directive-compliance.d.ts +19 -5
  15. package/dist/cli/{config-doctor-shc0n4q1.js → config-doctor-qqe6172n.js} +3 -3
  16. package/dist/cli/{core-p5cyej3r.js → core-52k057mf.js} +2 -2
  17. package/dist/cli/{curation-policy-7n6t8he4.js → curation-policy-9291bdat.js} +5 -7
  18. package/dist/cli/{curator-zp5qq24c.js → curator-04xqq68e.js} +28 -28
  19. package/dist/cli/{curator-llm-factory-pr4bdfqw.js → curator-llm-factory-cfm8fhdw.js} +28 -28
  20. package/dist/cli/{evidence-summary-service-nfdc1ht9.js → evidence-summary-service-em58myd7.js} +8 -8
  21. package/dist/cli/{gate-evidence-46qeyfc1.js → gate-evidence-ezxfkb22.js} +4 -4
  22. package/dist/cli/{guardrail-explain-thddj6jv.js → guardrail-explain-pn1bcgfz.js} +29 -29
  23. package/dist/cli/{guardrail-log-w8fmxe1x.js → guardrail-log-vb5zkegf.js} +4 -4
  24. package/dist/cli/{hive-promoter-0yg3gxg6.js → hive-promoter-z09khawt.js} +28 -28
  25. package/dist/cli/index-2rb3x0fk.js +2554 -0
  26. package/dist/cli/{index-hfvxhk4z.js → index-35qep0v7.js} +1 -1
  27. package/dist/cli/{index-h2waehqq.js → index-4hp8nvwb.js} +1 -1
  28. package/dist/cli/{index-1j5my2qy.js → index-7begd9aq.js} +4 -4
  29. package/dist/cli/{index-n831qq2v.js → index-a1fjhx4w.js} +822 -688
  30. package/dist/cli/{index-chx92bes.js → index-arza4m4j.js} +2 -2
  31. package/dist/cli/{index-ry0hgg3m.js → index-bfhwtdsw.js} +34 -0
  32. package/dist/cli/{index-jfjnn408.js → index-bn17ycxn.js} +1 -1
  33. package/dist/cli/{index-1m1ksyqt.js → index-c5kr20nz.js} +1 -1
  34. package/dist/cli/{index-4rje8dc0.js → index-djbhe0yh.js} +30 -30
  35. package/dist/cli/{index-t59cdg48.js → index-dtam929z.js} +2 -19
  36. package/dist/cli/{index-n0pja0qs.js → index-dtyeabmj.js} +2 -2
  37. package/dist/cli/{index-9txca231.js → index-hfjvepk2.js} +11 -9
  38. package/dist/cli/{index-vjqe1z2w.js → index-hfwzxh3j.js} +3 -3
  39. package/dist/cli/{index-n408rw7n.js → index-hxvkfx6t.js} +12 -0
  40. package/dist/cli/{index-brh827g0.js → index-hz0refz4.js} +10 -10
  41. package/dist/cli/{index-yt3vz0e1.js → index-mpytsq6k.js} +2 -2
  42. package/dist/cli/{index-rs1f1bh0.js → index-mrpfd1jx.js} +1 -1
  43. package/dist/cli/{index-0tevsq1a.js → index-pp5m7xga.js} +2 -2
  44. package/dist/cli/{index-b9rd29ge.js → index-rrb6cz2f.js} +1 -1
  45. package/dist/cli/{index-adyxbmt5.js → index-ryq97w1x.js} +2 -2
  46. package/dist/cli/{index-y98ngs4g.js → index-s8g7jh1k.js} +2 -2
  47. package/dist/cli/{index-bmmzfrc7.js → index-tj04dj06.js} +5 -2
  48. package/dist/cli/{index-z6md3t8m.js → index-v1an91bq.js} +54 -19
  49. package/dist/cli/{index-898f16j9.js → index-v3x7j9ey.js} +2 -2
  50. package/dist/cli/{index-7ax0bkqh.js → index-v3xhc7kg.js} +1 -1
  51. package/dist/cli/{index-325zmfyj.js → index-vrmkg8fm.js} +46 -15
  52. package/dist/cli/{index-yyyk63kk.js → index-w4etfamq.js} +2 -2
  53. package/dist/cli/{index-kbfsp07d.js → index-wk8s1m7b.js} +2 -2
  54. package/dist/cli/{index-x6mtyj6q.js → index-ysa38bnr.js} +2 -2
  55. package/dist/cli/index.js +28 -28
  56. package/dist/cli/{knowledge-escalator-58tw74js.js → knowledge-escalator-gdjnwszd.js} +19 -7
  57. package/dist/cli/{knowledge-events-knr0pfq4.js → knowledge-events-581x4q7n.js} +18 -5
  58. package/dist/cli/{knowledge-link-q46k9adx.js → knowledge-link-axx45d1h.js} +4 -4
  59. package/dist/cli/{knowledge-store-e2srcd89.js → knowledge-store-ttg33482.js} +5 -5
  60. package/dist/cli/{knowledge-validator-1dtj02q8.js → knowledge-validator-8kywqt8b.js} +7 -8
  61. package/dist/cli/{pending-delegations-qzrx38y9.js → pending-delegations-btwqsvz4.js} +3 -3
  62. package/dist/cli/{pr-subscriptions-5s59h4dd.js → pr-subscriptions-83y1cdwv.js} +3 -3
  63. package/dist/cli/{runner-y78d7ryb.js → runner-fh3r41nw.js} +5 -5
  64. package/dist/cli/{scan-cursor-7tqsvbp8.js → scan-cursor-j8ytdpam.js} +6 -6
  65. package/dist/cli/{schema-b046zss2.js → schema-6xfqtpvn.js} +2 -2
  66. package/dist/cli/{scope-persistence-dr1msqxw.js → scope-persistence-8c72jrgp.js} +4 -4
  67. package/dist/cli/{skill-generator-bvph9d98.js → skill-generator-n8vm1yhn.js} +18 -9
  68. package/dist/cli/{telemetry-sc57xtb0.js → telemetry-fb44gpba.js} +1 -1
  69. package/dist/cli/{worktree-collision-ownership-7a8e6gr9.js → worktree-collision-ownership-f28r473k.js} +3 -3
  70. package/dist/commands/ci-simulate.d.ts +7 -3
  71. package/dist/commands/close.d.ts +8 -0
  72. package/dist/commands/registry.d.ts +2 -2
  73. package/dist/commands/sdd.d.ts +15 -0
  74. package/dist/config/bundled-skills.d.ts +1 -1
  75. package/dist/config/schema.d.ts +2 -0
  76. package/dist/git/branch.d.ts +1 -1
  77. package/dist/hooks/compaction-customizer.d.ts +8 -0
  78. package/dist/hooks/delegate-ack-collector.d.ts +5 -0
  79. package/dist/hooks/hive-promoter.d.ts +4 -4
  80. package/dist/hooks/issue-trace-reducer.d.ts +7 -1
  81. package/dist/hooks/issue-trace-state.d.ts +18 -0
  82. package/dist/hooks/issue-trace.d.ts +3 -1
  83. package/dist/hooks/knowledge-application-gate.d.ts +8 -3
  84. package/dist/hooks/knowledge-application.d.ts +8 -5
  85. package/dist/hooks/knowledge-escalator.d.ts +9 -5
  86. package/dist/hooks/knowledge-events.d.ts +21 -8
  87. package/dist/hooks/knowledge-injector.d.ts +9 -0
  88. package/dist/hooks/knowledge-receipt-ledger-storage.d.ts +49 -0
  89. package/dist/hooks/knowledge-receipt-ledger.d.ts +305 -0
  90. package/dist/hooks/knowledge-receipt-observability.d.ts +28 -0
  91. package/dist/hooks/knowledge-receipt-validator.d.ts +13 -50
  92. package/dist/hooks/knowledge-store.d.ts +6 -1
  93. package/dist/hooks/knowledge-types.d.ts +12 -0
  94. package/dist/hooks/phase-complete-directive-gate.d.ts +3 -1
  95. package/dist/hooks/phase-directives.d.ts +4 -4
  96. package/dist/hooks/pr-workflow-gate.d.ts +34 -1
  97. package/dist/hooks/promotion-evidence-store.d.ts +14 -8
  98. package/dist/hooks/reviewer-verdict-parser.d.ts +34 -10
  99. package/dist/index.js +551 -532
  100. package/dist/knowledge/curation-policy.d.ts +0 -2
  101. package/dist/observability/catalog.d.ts +5 -3
  102. package/dist/observability/legacy.d.ts +4 -3
  103. package/dist/telemetry.d.ts +1 -1
  104. package/dist/tools/index.d.ts +3 -0
  105. package/dist/tools/manifest.d.ts +3 -0
  106. package/dist/tools/phase-complete.d.ts +9 -0
  107. package/dist/tools/rebind-pr-feedback-head.d.ts +17 -0
  108. package/dist/tools/record-implementation-review.d.ts +19 -0
  109. package/dist/tools/record-recurrence-sweep.d.ts +17 -0
  110. package/dist/tools/run-pr-feedback-stage-a.d.ts +8 -0
  111. package/dist/tools/tool-metadata.d.ts +12 -0
  112. package/package.json +3 -1
  113. package/dist/cli/index-jfp1bgt1.js +0 -666
@@ -4,18 +4,18 @@ import {
4
4
  alreadyCuratedThisGeneration,
5
5
  claimNextScanBatch,
6
6
  getScanStatus
7
- } from "./index-yt3vz0e1.js";
8
- import"./index-325zmfyj.js";
7
+ } from "./index-mpytsq6k.js";
8
+ import"./index-vrmkg8fm.js";
9
9
  import"./index-ae75rja9.js";
10
- import"./index-rs1f1bh0.js";
11
- import"./index-h2waehqq.js";
10
+ import"./index-mrpfd1jx.js";
11
+ import"./index-4hp8nvwb.js";
12
12
  import"./index-ed5ykebp.js";
13
- import"./index-hfvxhk4z.js";
13
+ import"./index-35qep0v7.js";
14
14
  import"./index-7g4c7s5r.js";
15
15
  import"./index-4nt52yr9.js";
16
16
  import"./index-zgwm4ryv.js";
17
17
  import"./index-bk5tah7q.js";
18
- import"./index-ry0hgg3m.js";
18
+ import"./index-bfhwtdsw.js";
19
19
  import"./index-bpmtbmy9.js";
20
20
  import"./index-a76rekgs.js";
21
21
  export {
@@ -96,8 +96,8 @@ import {
96
96
  resolveGeneratedAgentRole,
97
97
  resolveGuardrailsConfig,
98
98
  stripKnownSwarmPrefix
99
- } from "./index-bmmzfrc7.js";
100
- import"./index-n408rw7n.js";
99
+ } from "./index-tj04dj06.js";
100
+ import"./index-hxvkfx6t.js";
101
101
  import"./index-zjygnfay.js";
102
102
  import"./index-bk5tah7q.js";
103
103
  import"./index-bpmtbmy9.js";
@@ -23,15 +23,15 @@ import {
23
23
  tombstoneScopeBinding,
24
24
  writeScopeBindingToDisk,
25
25
  writeScopeToDisk
26
- } from "./index-adyxbmt5.js";
26
+ } from "./index-ryq97w1x.js";
27
27
  import"./index-556ja8an.js";
28
- import"./index-kbfsp07d.js";
29
- import"./index-hfvxhk4z.js";
28
+ import"./index-wk8s1m7b.js";
29
+ import"./index-35qep0v7.js";
30
30
  import"./index-7g4c7s5r.js";
31
31
  import"./index-4nt52yr9.js";
32
32
  import"./index-d181x9zr.js";
33
33
  import"./index-zgwm4ryv.js";
34
- import"./index-ry0hgg3m.js";
34
+ import"./index-bfhwtdsw.js";
35
35
  import"./index-bpmtbmy9.js";
36
36
  import"./index-a76rekgs.js";
37
37
  export {
@@ -33,23 +33,32 @@ import {
33
33
  sanitizeSlug,
34
34
  selectCandidateEntries,
35
35
  writeEvalStub
36
- } from "./index-9txca231.js";
37
- import"./index-1j5my2qy.js";
38
- import"./index-t59cdg48.js";
36
+ } from "./index-hfjvepk2.js";
37
+ import"./index-2rb3x0fk.js";
38
+ import"./index-k46me75h.js";
39
+ import"./index-ee3x66a5.js";
40
+ import"./index-7begd9aq.js";
41
+ import"./index-dtam929z.js";
39
42
  import"./index-rtry5xyf.js";
40
- import"./index-325zmfyj.js";
41
- import"./index-jfp1bgt1.js";
43
+ import"./index-vrmkg8fm.js";
42
44
  import"./index-ae75rja9.js";
43
- import"./index-rs1f1bh0.js";
44
- import"./index-h2waehqq.js";
45
+ import"./index-mrpfd1jx.js";
46
+ import"./index-4hp8nvwb.js";
45
47
  import"./index-ed5ykebp.js";
46
- import"./index-hfvxhk4z.js";
48
+ import"./index-35qep0v7.js";
47
49
  import"./index-7g4c7s5r.js";
48
50
  import"./index-4nt52yr9.js";
51
+ import"./index-pp5m7xga.js";
52
+ import"./index-gprxjmm7.js";
53
+ import"./index-n832052r.js";
54
+ import"./index-d181x9zr.js";
49
55
  import"./index-4rhhvd1a.js";
50
56
  import"./index-zgwm4ryv.js";
57
+ import"./index-tj04dj06.js";
58
+ import"./index-hxvkfx6t.js";
59
+ import"./index-zjygnfay.js";
51
60
  import"./index-bk5tah7q.js";
52
- import"./index-ry0hgg3m.js";
61
+ import"./index-bfhwtdsw.js";
53
62
  import"./index-bpmtbmy9.js";
54
63
  import"./index-a76rekgs.js";
55
64
  export {
@@ -13,7 +13,7 @@ import {
13
13
  startHeartbeatTracking,
14
14
  stopHeartbeatTracking,
15
15
  telemetry
16
- } from "./index-ry0hgg3m.js";
16
+ } from "./index-bfhwtdsw.js";
17
17
  import"./index-bpmtbmy9.js";
18
18
  import"./index-a76rekgs.js";
19
19
  export {
@@ -10,18 +10,18 @@ import {
10
10
  import {
11
11
  scanDelegationFallbacksForRecovery,
12
12
  scanDelegationsForRecovery
13
- } from "./index-b9rd29ge.js";
13
+ } from "./index-rrb6cz2f.js";
14
14
  import"./index-k46me75h.js";
15
15
  import"./index-ee3x66a5.js";
16
16
  import"./index-ed5ykebp.js";
17
- import"./index-hfvxhk4z.js";
17
+ import"./index-35qep0v7.js";
18
18
  import"./index-7g4c7s5r.js";
19
19
  import {
20
20
  bunSpawn
21
21
  } from "./index-4nt52yr9.js";
22
22
  import"./index-zgwm4ryv.js";
23
23
  import"./index-zjygnfay.js";
24
- import"./index-ry0hgg3m.js";
24
+ import"./index-bfhwtdsw.js";
25
25
  import"./index-bpmtbmy9.js";
26
26
  import"./index-a76rekgs.js";
27
27
 
@@ -14,20 +14,24 @@
14
14
  * merge-queue kick-outs.
15
15
  *
16
16
  * Input contract:
17
- * /swarm ci-simulate → uses current HEAD branch
18
- * /swarm ci-simulate <pr-ref> → uses the specified branch/ref
17
+ * /swarm ci-simulate → uses current HEAD branch
18
+ * /swarm ci-simulate <pr-ref> → uses the specified branch/ref
19
+ * /swarm ci-simulate <pr-ref> --base <ref> → validated explicit base for
20
+ * stacked/release-branch PRs
19
21
  */
20
22
  import * as fs from 'node:fs';
21
- import { getDefaultBaseBranch } from '../git/branch.js';
23
+ import { detectDefaultRemoteBranch, getDefaultBaseBranch } from '../git/branch.js';
22
24
  import { runExternalTool } from '../utils/external-tool-runner.js';
23
25
  export declare const _internals: {
24
26
  runExternalTool: typeof runExternalTool;
25
27
  getDefaultBaseBranch: typeof getDefaultBaseBranch;
28
+ detectDefaultRemoteBranch: typeof detectDefaultRemoteBranch;
26
29
  platform: string;
27
30
  osTmpdir: () => string;
28
31
  fs: {
29
32
  existsSync: typeof fs.existsSync;
30
33
  rmSync: typeof fs.rmSync;
34
+ realpathSync: (p: fs.PathLike) => string;
31
35
  };
32
36
  };
33
37
  /**
@@ -6,6 +6,14 @@ import { createCuratorLLMDelegate } from '../hooks/curator-llm-factory';
6
6
  import { runCuratorPostMortem } from '../hooks/curator-postmortem';
7
7
  import { checkHivePromotions } from '../hooks/hive-promoter';
8
8
  import { curateAndStoreSwarm } from '../hooks/knowledge-curator';
9
+ import { reconcilePhaseClose } from '../hooks/knowledge-receipt-ledger.js';
10
+ /** Narrow seam for receipt/plan ordering tests. */
11
+ export declare const closeReceiptLifecycleInternals: {
12
+ recordPhaseCloseIntent: (directory: string, phase: string, sessionId?: string, taskId?: string) => Promise<import("../hooks/knowledge-receipt-ledger.js").ReceiptLedgerResult<{
13
+ event_id: string;
14
+ }>>;
15
+ reconcilePhaseClose: typeof reconcilePhaseClose;
16
+ };
9
17
  import { runFinalizeRewardSweep } from '../memory/finalize-reward-sweep';
10
18
  import { closePlanTerminalState } from '../plan/manager';
11
19
  import { type SessionReflectionResult } from '../services/session-reflection';
@@ -701,8 +701,8 @@ export declare const COMMAND_REGISTRY: {
701
701
  readonly 'ci-simulate': {
702
702
  readonly handler: (ctx: CommandContext) => Promise<string>;
703
703
  readonly description: "Create a temporary merge-result worktree and run CI before merge queue entry";
704
- readonly args: "[--base origin/main] [--head <ref>]";
705
- readonly details: "Creates a detached temporary worktree under .swarm/ci-simulate from the base ref, merges the current worktree HEAD (or --head ref), runs fixed local CI gates (typecheck, Biome CI, build, unit/integration/security/smoke tests, drift check), then removes the worktree and prunes metadata. Intended as a pre-queue merge_group simulation helper.";
704
+ readonly args: "[pr-ref] [--base <ref>]";
705
+ readonly details: "Creates a detached temporary worktree under the OS temp dir (swarm-ci-simulate) from the base — an explicit validated --base <ref> when given (stacked/release-branch PRs), otherwise the detected default remote branch (origin/HEAD, init.defaultBranch, origin/main, origin/master, verified to exist) — merges the given PR ref (or the current ref), runs fixed local CI gates (typecheck, lint, build, test), then removes the worktree non-force and prunes metadata. Worktree removal is fail-closed: a blocked or dirty worktree is surfaced, never force-deleted. Intended as a pre-queue merge_group simulation helper.";
706
706
  readonly category: "agent";
707
707
  readonly toolPolicy: "agent";
708
708
  };
@@ -16,6 +16,21 @@ interface ParsedSddArgs {
16
16
  feature?: string;
17
17
  error?: string;
18
18
  }
19
+ /**
20
+ * Returns true when `value` contains characters that are unsafe in a directory
21
+ * name id: path separators, traversal sequences, bracket characters, or control/bidi
22
+ * characters.
23
+ *
24
+ * Shared by both --change and --feature so the same rejection logic is reused
25
+ * (task 2.2 explicit requirement; matches the pre-task baseline).
26
+ */
27
+ /**
28
+ * Issue #2131 criterion G: the allowed-mutations policy derived from the
29
+ * effective spec's source kind. Only a native swarm spec may be created,
30
+ * refined, or archived through the swarm tooling; projected sources
31
+ * (openspec / speckit) are read-only inputs — refine them in their own tool.
32
+ */
33
+ export declare function allowedMutationsFor(source: 'swarm' | 'openspec_projection' | 'speckit_projection'): string[];
19
34
  declare function parseArgs(args: string[]): ParsedSddArgs;
20
35
  export declare function handleSddStatusCommand(directory: string, args: string[]): Promise<string>;
21
36
  export declare function handleSddValidateCommand(directory: string, args: string[]): Promise<string>;
@@ -1,4 +1,4 @@
1
- export declare const BUNDLED_PROJECT_SKILLS: readonly ["brainstorm", "specify", "clarify-spec", "resume", "clarify", "discover", "consult", "pre-phase-briefing", "council", "deep-dive", "deep-research", "codebase-review-swarm", "swarm-implement", "design-docs", "swarm-pr-review", "swarm", "swarm-pr-feedback", "swarm-pr-subscribe", "swarm-ci-monitor", "issue-ingest", "plan", "critic-gate", "execute", "phase-wrap", "loop", "writing-tests", "running-tests", "engineering-conventions", "commit-pr", "ci-failure-batching", "gate-attribution", "merge-queue-readiness", "skill-edit-validation", "worktree-retry-cleanup", "test-file-split", "fork-pr-operations", "parallel-work-check", "ci-fix-monitor", "issue-tracer"];
1
+ export declare const BUNDLED_PROJECT_SKILLS: readonly ["brainstorm", "specify", "clarify-spec", "resume", "clarify", "discover", "consult", "pre-phase-briefing", "council", "deep-dive", "deep-research", "codebase-review-swarm", "swarm-implement", "design-docs", "swarm-pr-review", "swarm", "swarm-pr-feedback", "swarm-pr-subscribe", "swarm-ci-monitor", "issue-ingest", "plan", "critic-gate", "execute", "phase-wrap", "loop", "writing-tests", "running-tests", "engineering-conventions", "commit-pr", "ci-failure-batching", "gate-attribution", "merge-queue-readiness", "skill-edit-validation", "worktree-retry-cleanup", "test-file-split", "fork-pr-operations", "parallel-work-check", "ci-fix-monitor", "issue-tracer", "orchestrating-subagents", "durable-session-state"];
2
2
  export type BundledProjectSkill = (typeof BUNDLED_PROJECT_SKILLS)[number];
3
3
  /**
4
4
  * Project-private runtime location for plugin-owned skills. Repository-native
@@ -676,6 +676,7 @@ export declare const KnowledgeConfigSchema: z.ZodObject<{
676
676
  evergreen_utility: z.ZodDefault<z.ZodNumber>;
677
677
  low_utility_threshold: z.ZodDefault<z.ZodNumber>;
678
678
  min_retrievals_for_utility: z.ZodDefault<z.ZodNumber>;
679
+ receipt_close_grace_days: z.ZodDefault<z.ZodNumber>;
679
680
  schema_version: z.ZodDefault<z.ZodNumber>;
680
681
  directive_min_confidence: z.ZodDefault<z.ZodNumber>;
681
682
  same_project_weight: z.ZodDefault<z.ZodNumber>;
@@ -2121,6 +2122,7 @@ export declare const PluginConfigSchema: z.ZodObject<{
2121
2122
  evergreen_utility: z.ZodDefault<z.ZodNumber>;
2122
2123
  low_utility_threshold: z.ZodDefault<z.ZodNumber>;
2123
2124
  min_retrievals_for_utility: z.ZodDefault<z.ZodNumber>;
2125
+ receipt_close_grace_days: z.ZodDefault<z.ZodNumber>;
2124
2126
  schema_version: z.ZodDefault<z.ZodNumber>;
2125
2127
  directive_min_confidence: z.ZodDefault<z.ZodNumber>;
2126
2128
  same_project_weight: z.ZodDefault<z.ZodNumber>;
@@ -142,7 +142,7 @@ export interface ResetToRemoteBranchResult {
142
142
  /**
143
143
  * Detect the default remote branch using multiple fallback methods
144
144
  */
145
- declare function detectDefaultRemoteBranch(cwd: string): string | null;
145
+ export declare function detectDefaultRemoteBranch(cwd: string): string | null;
146
146
  /**
147
147
  * Reset local branch to align with its remote counterpart.
148
148
  * Safely handles uncommitted changes, unpushed commits, and detached HEAD states.
@@ -13,6 +13,14 @@ import type { PluginConfig } from '../config';
13
13
  * (`- [ ] <id>: ... ← CURRENT`), and the legacy `extractIncompleteTasks` path
14
14
  * relays it verbatim whenever plan.md was derived from or hand-written in the
15
15
  * canonical ` ← CURRENT` format, so the strip is applied to both paths.
16
+ *
17
+ * Callers must pass TASK_EXTRACT_PRE_STRIP_CHARS to the extractor so the full
18
+ * marker always fits before this function runs. `(?:\.\.\.)?` is defense-in-depth
19
+ * for hand-authored plan.md lines that end with `← CURRENT...` — the programmatic
20
+ * extractor never appends `...` when TASK_EXTRACT_PRE_STRIP_CHARS is MAX_SAFE_INTEGER.
21
+ *
22
+ * Uses `[^\S\r\n]*` (horizontal whitespace only) to avoid O(n²) regex backtracking
23
+ * across line boundaries that `\s*` would cause on large inputs.
16
24
  */
17
25
  declare function stripTaskActionMarkers(value: string): string;
18
26
  interface CompactionFact {
@@ -53,6 +53,11 @@ export interface CollectDelegateAcksResult {
53
53
  * promotion evidence.
54
54
  */
55
55
  unacknowledgedNonCritical: string[];
56
+ /** Typed authority failure: no V2 mutation was attempted. */
57
+ unverifiable?: {
58
+ code: 'missing_session_id';
59
+ detail: string;
60
+ };
56
61
  }
57
62
  /**
58
63
  * Core reconciliation used by both the runtime hook and tests. Returns a summary
@@ -81,10 +81,9 @@ export declare const _internals: {
81
81
  transactHiveStore: typeof transactHiveStore;
82
82
  validateLesson: typeof validateLesson;
83
83
  authorizeCuration: typeof authorizeCuration;
84
- /** (#1849) Loads validated terminal-application evidence per swarm entry id
85
- * from .swarm/knowledge-promotion-evidence.jsonl. Empty when no validated
86
- * receipts exist yet (conservative: no synthetic credit). */
87
- loadPromotionEvidence: (directory: string) => Promise<Record<string, PromotionEvidenceRecord[]>>;
84
+ /** Loads authoritative terminal-application evidence per swarm entry id.
85
+ * Empty on receipt-ledger uncertainty (conservative: no synthetic credit). */
86
+ loadPromotionEvidence: (directory: string, canonicalCohortId?: string) => Promise<Record<string, PromotionEvidenceRecord[]>>;
88
87
  /** Loads the default KnowledgeConfig (schema defaults) for manual promotion
89
88
  * paths when the command did not load one. */
90
89
  loadDefaultKnowledgeConfig: () => {
@@ -105,6 +104,7 @@ export declare const _internals: {
105
104
  evergreen_utility: number;
106
105
  low_utility_threshold: number;
107
106
  min_retrievals_for_utility: number;
107
+ receipt_close_grace_days: number;
108
108
  schema_version: number;
109
109
  directive_min_confidence: number;
110
110
  same_project_weight: number;
@@ -55,6 +55,10 @@ export interface WorkflowArtifacts {
55
55
  reproductionPermitted: boolean;
56
56
  /** A verifiable publication receipt has been observed (issue #2131 2.4). */
57
57
  publicationObserved: boolean;
58
+ /** A valid recurrence-sweep receipt exists (issue #2131 residual B). */
59
+ recurrenceSweepVerified: boolean;
60
+ /** Fresh reviewer + critic APPROVE verdicts recorded (issue #2131 residual B). */
61
+ implementationReviewVerified: boolean;
58
62
  }
59
63
  export interface TransitionResult {
60
64
  nextMode: string | null;
@@ -82,7 +86,9 @@ export interface ComputeNextModeParams {
82
86
  * (f-block) Spec exists, no plan, reproduction NOT permitted → no-op
83
87
  * (g) Plan exists but critic not approved → no-op
84
88
  * (h) Critic approved, phases incomplete, not yet PLAN_TO_EXECUTE → EXECUTE
85
- * (i) All phases complete, not yet EXECUTE_TO_COMMIT publication_handoff + COMMIT directive
89
+ * (i-pre1) Phases complete, impl-review receipt missing one-shot REVIEW_GATE directive
90
+ * (i-pre2) Impl-review ok, recurrence-sweep receipt missing → one-shot RECURRENCE_GATE directive
91
+ * (i) All phases complete + both gates verified, not yet EXECUTE_TO_COMMIT → publication_handoff + COMMIT directive
86
92
  *
87
93
  * Idempotency: rows (f), (h), (i) return no-op when
88
94
  * `traceState.lastTransition` already equals the target transition value.
@@ -17,6 +17,8 @@ import type { IssueReference, TraceState } from './issue-trace-reducer';
17
17
  declare function _defaultLoadPlanFromLedger(directory: string): Promise<Plan | null>;
18
18
  declare function _defaultReproductionReceiptExists(directory: string, issueNumber: number): Promise<boolean>;
19
19
  declare function _defaultPublicationReceiptExists(directory: string, issueNumber: number): Promise<boolean>;
20
+ declare function _defaultRecurrenceSweepReceiptExists(directory: string, issueNumber: number): Promise<boolean>;
21
+ declare function _defaultImplementationReviewReceiptExists(directory: string, issueNumber: number): Promise<boolean>;
20
22
  export declare const _internals: {
21
23
  readFileSync: typeof readFileSync;
22
24
  writeFileSync: typeof writeFileSync;
@@ -27,6 +29,8 @@ export declare const _internals: {
27
29
  loadPlanFromLedger: typeof _defaultLoadPlanFromLedger;
28
30
  reproductionReceiptExists: typeof _defaultReproductionReceiptExists;
29
31
  publicationReceiptExists: typeof _defaultPublicationReceiptExists;
32
+ recurrenceSweepReceiptExists: typeof _defaultRecurrenceSweepReceiptExists;
33
+ implementationReviewReceiptExists: typeof _defaultImplementationReviewReceiptExists;
30
34
  };
31
35
  /**
32
36
  * Reads `.swarm/issue-reference.json` and returns the parsed object,
@@ -90,4 +94,18 @@ export declare function reproductionReceiptExists(directory: string, issueNumber
90
94
  * a new trace.
91
95
  */
92
96
  export declare function publicationReceiptExists(directory: string, issueNumber: number): Promise<boolean>;
97
+ /**
98
+ * Returns whether a valid recurrence-sweep receipt exists for the given issue
99
+ * (issue #2131 residual criterion B). Modeled on issue-tracer Phase 4.2: for a
100
+ * real defect class it must record search predicates, a typed disposition for
101
+ * every hit, and a guardrail with proof it catches the original defect; the
102
+ * "no defect class" fast path requires a one-line justification.
103
+ */
104
+ export declare function recurrenceSweepReceiptExists(directory: string, issueNumber: number): Promise<boolean>;
105
+ /**
106
+ * Returns whether a valid independent implementation-review receipt exists for
107
+ * the given issue (issue #2131 residual criterion B): fresh reviewer AND critic
108
+ * contexts both recorded APPROVE verdicts for the implementation diff.
109
+ */
110
+ export declare function implementationReviewReceiptExists(directory: string, issueNumber: number): Promise<boolean>;
93
111
  export {};
@@ -17,7 +17,7 @@
17
17
  */
18
18
  import { error as _logErrorImpl } from '../utils/logger.js';
19
19
  import { isPlanCriticApproved } from './delegation-gate';
20
- import { publicationReceiptExists, readIssueReference, readPlanPhaseStatus, readSpecIssueNumber, readTraceState, reproductionReceiptExists, specExists, writeTraceState } from './issue-trace-state';
20
+ import { implementationReviewReceiptExists, publicationReceiptExists, readIssueReference, readPlanPhaseStatus, readSpecIssueNumber, readTraceState, recurrenceSweepReceiptExists, reproductionReceiptExists, specExists, writeTraceState } from './issue-trace-state';
21
21
  export declare const _internals: {
22
22
  readIssueReference: typeof readIssueReference;
23
23
  readTraceState: typeof readTraceState;
@@ -27,6 +27,8 @@ export declare const _internals: {
27
27
  specExists: typeof specExists;
28
28
  reproductionReceiptExists: typeof reproductionReceiptExists;
29
29
  publicationReceiptExists: typeof publicationReceiptExists;
30
+ recurrenceSweepReceiptExists: typeof recurrenceSweepReceiptExists;
31
+ implementationReviewReceiptExists: typeof implementationReviewReceiptExists;
30
32
  isPlanCriticApproved: typeof isPlanCriticApproved;
31
33
  logError: typeof _logErrorImpl;
32
34
  };
@@ -12,13 +12,13 @@
12
12
  *
13
13
  * 2. `tool.execute.before` (FAIL-CLOSED chain at src/index.ts) — when a
14
14
  * high-risk tool fires and the calling agent is the architect,
15
- * consults `swarmState.currentCriticalShownIds` and the audit log to
16
- * assemble the set of critical directives that have been shown but
15
+ * consults the authoritative receipt ledger for critical architect
16
+ * directives in the current active phase/task that have been shown but
17
17
  * not acknowledged. In `mode: 'enforce'` it THROWS to block the
18
18
  * action (per the FAIL-CLOSED contract — `output.error` is NOT a
19
19
  * write API at toolBefore time) — UNLESS one of two bounded escape
20
20
  * hatches has fired first (a per-directive denial-count limit, or a
21
- * staleness TTL since the directive was shown; see
21
+ * per-exact-pair staleness TTL since the directive was shown; see
22
22
  * `incrementGateDenialCount`/`buildGateDenialDirectiveKey` in
23
23
  * `../state.js`), in which case the pending directives are
24
24
  * auto-acknowledged and an audit event is durably written before the
@@ -34,6 +34,7 @@
34
34
  * Non-architect agents are never gated.
35
35
  */
36
36
  import { type KnowledgeApplicationConfig } from './knowledge-application.js';
37
+ import { type ReceiptMembership } from './knowledge-receipt-ledger.js';
37
38
  import type { MessageWithParts } from './knowledge-types.js';
38
39
  /** Tools that require knowledge-directive acknowledgment before execution. */
39
40
  export declare const HIGH_RISK_TOOLS: Set<string>;
@@ -42,6 +43,8 @@ export interface GateInput {
42
43
  agent?: unknown;
43
44
  sessionID?: unknown;
44
45
  }
46
+ declare function selectCurrentArchitectDirectiveMemberships(memberships: ReceiptMembership[]): ReceiptMembership[];
47
+ declare function selectStaleUnmarkedMemberships(memberships: ReceiptMembership[], now: number, stalenessMs: number): ReceiptMembership[];
45
48
  /**
46
49
  * Pre-tool gate. Throws when the architect attempts a high-risk action with
47
50
  * an unacknowledged critical directive in `enforce` mode. Always returns in
@@ -64,5 +67,7 @@ export declare const _internals: {
64
67
  knowledgeApplicationTransformScan: typeof knowledgeApplicationTransformScan;
65
68
  HIGH_RISK_TOOLS: Set<string>;
66
69
  writeWarnEvent: typeof writeWarnEvent;
70
+ selectCurrentArchitectDirectiveMemberships: typeof selectCurrentArchitectDirectiveMemberships;
71
+ selectStaleUnmarkedMemberships: typeof selectStaleUnmarkedMemberships;
67
72
  };
68
73
  export {};
@@ -11,14 +11,17 @@ export declare const MAX_LEGACY_APPLICATION_LOG_ENTRIES = 5000;
11
11
  /**
12
12
  * Parse explicit knowledge-acknowledgment markers from architect/delegate text.
13
13
  * Recognised forms (case-insensitive, line-anchored or inline):
14
- * KNOWLEDGE_APPLIED: <id>
15
- * KNOWLEDGE_IGNORED: <id> reason=<reason>
16
- * KNOWLEDGE_CONTRADICTED: <id> reason=<observable conflict>
17
- * KNOWLEDGE_VIOLATED: <id> reason=<reason>
18
- * KNOWLEDGE_N_A: <id> reason=<reason> (delegate contract, Change 1)
14
+ * KNOWLEDGE_APPLIED: <trace_id>:<entry_id>
15
+ * KNOWLEDGE_IGNORED: <trace_id>:<entry_id> reason=<reason>
16
+ * KNOWLEDGE_CONTRADICTED: <trace_id>:<entry_id> reason=<observable conflict>
17
+ * KNOWLEDGE_VIOLATED: <trace_id>:<entry_id> reason=<reason>
18
+ * KNOWLEDGE_N_A: <trace_id>:<entry_id> reason=<reason>
19
+ * Legacy one-token delegate markers remain parseable, but architect application
20
+ * reconciliation requires the exact trace token.
19
21
  */
20
22
  export interface ParsedAcknowledgment {
21
23
  id: string;
24
+ trace_id?: string;
22
25
  result: 'applied' | 'ignored' | 'contradicted' | 'violated' | 'n_a';
23
26
  reason?: string;
24
27
  }
@@ -11,6 +11,7 @@
11
11
  * Persistence goes through `rewriteKnowledge` (never a raw JSONL write). Fail-open:
12
12
  * any error leaves the entry untouched and returns `escalated:false`.
13
13
  */
14
+ import { queryHistoricalOutcomes } from './knowledge-receipt-ledger.js';
14
15
  import type { DirectivePriority } from './knowledge-types.js';
15
16
  export declare const ESCALATION_WINDOW_DAYS = 30;
16
17
  export declare const ESCALATION_THRESHOLD = 2;
@@ -25,7 +26,7 @@ export interface EscalationResult {
25
26
  }
26
27
  /**
27
28
  * Evaluate and (if warranted) apply a repeat-violation escalation to a single
28
- * entry. Call AFTER the triggering `violated` event has been persisted.
29
+ * entry. Call AFTER the triggering authoritative `violated` terminal commits.
29
30
  */
30
31
  export declare function maybeEscalateOnViolation(directory: string, entryId: string, now?: Date): Promise<EscalationResult>;
31
32
  export interface RecentEscalation {
@@ -58,9 +59,12 @@ export interface ContradictionQuarantineResult {
58
59
  /**
59
60
  * G3 (#1715): if an entry's `contradicted` count within `windowDays` crosses
60
61
  * `threshold`, auto-quarantine it. Mirrors {@link maybeEscalateOnViolation}
61
- * (counts from the RAW event log via {@link countEntryContradictionsInWindow}
62
- * — NOT the rollup cache, which is mtime-keyed and can be stale immediately
63
- * after an append). Idempotent: already-quarantined/archived entries are
64
- * skipped. Never throws.
62
+ * Counts exact authoritative receipt terminals, never the diagnostic FIFO or
63
+ * rollup cache. Idempotent: already-quarantined/archived entries are skipped.
64
+ * Receipt-ledger uncertainty is conservative and never quarantines.
65
65
  */
66
66
  export declare function maybeQuarantineOnContradiction(directory: string, entryId: string, threshold: number, windowDays: number, now?: Date): Promise<ContradictionQuarantineResult>;
67
+ /** Dependency seam for authoritative-history tests; restore after each test. */
68
+ export declare const _internals: {
69
+ queryHistoricalOutcomes: typeof queryHistoricalOutcomes;
70
+ };
@@ -1,11 +1,13 @@
1
1
  /**
2
- * Event-sourced knowledge lifecycle for opencode-swarm.
2
+ * Bounded diagnostic knowledge lifecycle stream for opencode-swarm.
3
3
  *
4
4
  * `.swarm/knowledge-events.jsonl` records meaningful knowledge interactions
5
5
  * (retrieval, receipt, outcome, archival). Recent lines stay in the event log;
6
6
  * old lines are folded into `.swarm/knowledge-counter-baseline.json` when the
7
- * log exceeds the cap. The event log plus baseline are the authoritative
8
- * history for derived per-entry counters (`retrieval_outcomes.*`).
7
+ * log exceeds the cap. The event log plus baseline remain the source for
8
+ * best-effort aggregate metrics (`retrieval_outcomes.*`), but are not receipt,
9
+ * membership, gate, promotion, escalation, or destructive-action authority.
10
+ * Correctness state lives in the canonical project-local V2 receipt ledger.
9
11
  *
10
12
  * Design contracts:
11
13
  * - Append-first, bounded retention. New events use OS-level atomic append; trim
@@ -20,6 +22,7 @@
20
22
  * from the process working directory.
21
23
  */
22
24
  import { resolveHiveEventsPath as resolveHiveEventsPathImpl } from '../knowledge/hive-paths.js';
25
+ import { queryHistoricalOutcomes } from './knowledge-receipt-ledger.js';
23
26
  import type { ConfidenceFloorOptions } from './knowledge-store.js';
24
27
  import type { KnowledgeApplicationRecord, RetrievalOutcome } from './knowledge-types.js';
25
28
  /** Current event-log record schema version. Bump when the on-disk shape changes. */
@@ -372,16 +375,24 @@ export declare function countEntryViolationsInWindow(directory: string, entryId:
372
375
  */
373
376
  export declare function countEntryContradictionsInWindow(directory: string, entryId: string, windowDays: number, now?: Date): Promise<number>;
374
377
  /**
375
- * Fail-open rollup reader for hot paths. Search and promotion use this instead
376
- * of stale persisted counters so `knowledge_receipt` feedback affects ranking
377
- * and safety gates immediately.
378
+ * Fail-open diagnostic rollup reader. This preserves legacy metrics and
379
+ * postmortem views, but correctness-affecting consumers must use
380
+ * {@link readAuthoritativeKnowledgeCounterRollups} instead.
378
381
  */
379
382
  export declare function readKnowledgeCounterRollups(directory: string): Promise<Map<string, CounterRollup>>;
383
+ /**
384
+ * Build correctness-affecting retrieval/outcome counters exclusively from the
385
+ * project-local receipt authority. The bounded knowledge-events FIFO remains a
386
+ * diagnostics/metrics source and must never influence ranking, curation,
387
+ * confidence floors, promotion, or generated-skill eligibility.
388
+ */
389
+ export declare function readAuthoritativeKnowledgeCounterRollups(directory: string): Promise<Map<string, CounterRollup>>;
380
390
  /** Merge event-derived rollups over stored outcome counters for scoring only. */
381
391
  export declare function effectiveRetrievalOutcomes(stored: RetrievalOutcome | undefined, rollup: CounterRollup | undefined): RetrievalOutcome;
382
392
  /**
383
- * Read receipt events (applied/violated/ignored), aggregate per knowledge entry,
384
- * and apply bounded confidence deltas via `bumpKnowledgeConfidenceBatch`.
393
+ * Read authoritative receipt terminals (applied/violated/ignored), aggregate
394
+ * per knowledge entry, and apply bounded confidence deltas via
395
+ * `bumpKnowledgeConfidenceBatch`.
385
396
  *
386
397
  * Complements `applySkillUsageFeedback` (skill-usage-log.ts) which bridges
387
398
  * skill compliance → confidence. This function bridges raw knowledge verdict
@@ -407,9 +418,11 @@ export declare const _internals: {
407
418
  appendKnowledgeEvent: typeof appendKnowledgeEvent;
408
419
  recordKnowledgeEvent: typeof recordKnowledgeEvent;
409
420
  readKnowledgeEvents: typeof readKnowledgeEvents;
421
+ queryHistoricalOutcomes: typeof queryHistoricalOutcomes;
410
422
  readCounterBaseline: typeof readCounterBaseline;
411
423
  readLegacyApplicationRecords: typeof readLegacyApplicationRecords;
412
424
  readKnowledgeCounterRollups: typeof readKnowledgeCounterRollups;
425
+ readAuthoritativeKnowledgeCounterRollups: typeof readAuthoritativeKnowledgeCounterRollups;
413
426
  effectiveRetrievalOutcomes: typeof effectiveRetrievalOutcomes;
414
427
  recomputeCounters: typeof recomputeCounters;
415
428
  applyKnowledgeVerdictFeedback: typeof applyKnowledgeVerdictFeedback;
@@ -5,11 +5,14 @@
5
5
  * compaction. Skips for non-architect agents. Appends rejected-pattern warnings
6
6
  * to prevent re-learning loops.
7
7
  */
8
+ import { ensureCohortIdCached } from './cohort-cache.js';
8
9
  import { recordKnowledgeShown } from './knowledge-application.js';
9
10
  import { buildEscalationBriefing, readRecentEscalations } from './knowledge-escalator.js';
10
11
  import { recordKnowledgeEvent } from './knowledge-events.js';
12
+ import { readLinkPointer } from './knowledge-link.js';
11
13
  import type { RankedEntry } from './knowledge-reader.js';
12
14
  import { recordLessonsShown } from './knowledge-reader.js';
15
+ import { commitDisplayedMembership, commitEmptyRetrieval, queryLiveMemberships } from './knowledge-receipt-ledger.js';
13
16
  import { confirmEntriesPhase } from './knowledge-store.js';
14
17
  import type { DirectivePriority, KnowledgeConfig, MessageWithParts } from './knowledge-types.js';
15
18
  import { searchKnowledge } from './search-knowledge.js';
@@ -48,6 +51,7 @@ export interface InjectForDelegateParams {
48
51
  agent: string;
49
52
  expectedTools?: string[];
50
53
  taskTitle?: string;
54
+ taskId?: string;
51
55
  sessionId?: string;
52
56
  config: KnowledgeConfig;
53
57
  /**
@@ -117,6 +121,11 @@ export declare const _internals: {
117
121
  buildEscalationBriefing: typeof buildEscalationBriefing;
118
122
  recordLessonsShown: typeof recordLessonsShown;
119
123
  confirmEntriesPhase: typeof confirmEntriesPhase;
124
+ commitDisplayedMembership: typeof commitDisplayedMembership;
125
+ commitEmptyRetrieval: typeof commitEmptyRetrieval;
126
+ queryLiveMemberships: typeof queryLiveMemberships;
127
+ ensureCohortIdCached: typeof ensureCohortIdCached;
128
+ readLinkPointer: typeof readLinkPointer;
120
129
  };
121
130
  /**
122
131
  * Tier-0 test seam (see `.opencode/skills/writing-tests/SKILL.md`). Exposes the