opencode-swarm 7.194.0 → 7.195.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 (110) hide show
  1. package/.opencode/skills/commit-pr/SKILL.md +8 -0
  2. package/.opencode/skills/issue-tracer/references/acceptance-checks.md +20 -0
  3. package/.opencode/skills/issue-tracer/references/full-resolution-contract.md +12 -0
  4. package/.opencode/skills/swarm-pr-feedback/SKILL.md +2 -2
  5. package/.opencode/skills/swarm-pr-feedback/references/operational-gotchas.md +18 -0
  6. package/.opencode/skills/swarm-pr-review/SKILL.md +11 -10
  7. package/.opencode/skills/swarm-pr-review/references/counterbalancing.md +68 -0
  8. package/.opencode/skills/swarm-pr-review/references/findings-persistence-contract.md +21 -0
  9. package/.opencode/skills/swarm-pr-review/references/parser-dry-run.md +11 -0
  10. package/.opencode/skills/swarm-pr-review/references/prompt-templates.md +8 -0
  11. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  12. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  13. package/dist/background/pr-review-collection-receipt.d.ts +7 -1
  14. package/dist/background/pr-review-contract.d.ts +10 -0
  15. package/dist/cli/{auto-checkpoint-67dk8rjz.js → auto-checkpoint-anf21wwa.js} +9 -9
  16. package/dist/cli/{checkpoint-jbqqyp5e.js → checkpoint-ngdw2qx2.js} +17 -17
  17. package/dist/cli/{coder-settlement-a09t7mvx.js → coder-settlement-bqb059y2.js} +13 -13
  18. package/dist/cli/{config-doctor-dkp263xx.js → config-doctor-vetg215g.js} +16 -16
  19. package/dist/cli/{core-stnmz1rg.js → core-8qgvsm6x.js} +4 -4
  20. package/dist/cli/{curation-policy-8j6qn6nt.js → curation-policy-5hm6328s.js} +6 -6
  21. package/dist/cli/{curator-drift-d1wedyed.js → curator-drift-3gjycbkv.js} +9 -9
  22. package/dist/cli/{curator-mc0wcpvw.js → curator-hh0n9wgz.js} +43 -43
  23. package/dist/cli/curator-llm-factory-d17ybmgm.js +82 -0
  24. package/dist/cli/{doctor-knowledge-receipt-phase-id-dfwx5jha.js → doctor-knowledge-receipt-phase-id-1d465vkg.js} +9 -9
  25. package/dist/cli/{evidence-summary-service-k1shqefr.js → evidence-summary-service-rkd3yc5x.js} +20 -20
  26. package/dist/cli/{gate-evidence-vw9y4gs6.js → gate-evidence-wtjrerkh.js} +8 -8
  27. package/dist/cli/guardrail-explain-8xh3r0dn.js +83 -0
  28. package/dist/cli/{guardrail-log-vbeyx6nq.js → guardrail-log-jrey2myg.js} +8 -8
  29. package/dist/cli/{guardrail-reset-jwtt15e3.js → guardrail-reset-m5qbg30j.js} +43 -43
  30. package/dist/cli/{hive-promoter-p9ad63mx.js → hive-promoter-36yhdfre.js} +43 -43
  31. package/dist/cli/{index-at34nry4.js → index-1hcjxz6w.js} +5 -5
  32. package/dist/cli/{index-dy7nztyp.js → index-3k65kdfp.js} +12 -10
  33. package/dist/cli/{index-d7pznffh.js → index-479kf368.js} +4 -4
  34. package/dist/cli/{index-5rkh69f3.js → index-4gmxdkcd.js} +2 -2
  35. package/dist/cli/{index-cwr69qw7.js → index-5gf2wx2c.js} +7 -7
  36. package/dist/cli/{index-qh93qjc2.js → index-6183at3v.js} +2 -2
  37. package/dist/cli/{index-r8mavcg6.js → index-6vpqe4ws.js} +5 -5
  38. package/dist/cli/{index-48h1yn6c.js → index-780g1hht.js} +5 -5
  39. package/dist/cli/{index-vjytfp05.js → index-7kbpzg05.js} +291 -92
  40. package/dist/cli/{index-mtqwyjrg.js → index-7rtq2t5n.js} +1 -1
  41. package/dist/cli/{index-7bfshvq1.js → index-82aj6gaj.js} +3 -3
  42. package/dist/cli/{index-vfdkvvkf.js → index-8448vj9w.js} +2 -2
  43. package/dist/cli/{index-y3n9ry9q.js → index-863hst4e.js} +3 -3
  44. package/dist/cli/{index-x7qeaa9y.js → index-9teqkkp4.js} +43 -43
  45. package/dist/cli/{index-51dxek4p.js → index-akb436kn.js} +4 -4
  46. package/dist/cli/{index-0e318vgt.js → index-app2rmxv.js} +1 -1
  47. package/dist/cli/{index-ajkdt5b8.js → index-bftpd2m5.js} +4 -4
  48. package/dist/cli/{index-h14wpwpa.js → index-bpq6z8qe.js} +4 -4
  49. package/dist/cli/{index-43v5axvm.js → index-c4hx57tz.js} +5 -5
  50. package/dist/cli/{index-668npagp.js → index-c5xvm318.js} +1 -1
  51. package/dist/cli/{index-0xe19j9g.js → index-c6hyd8hg.js} +1 -1
  52. package/dist/cli/{index-vg8sxg12.js → index-crz772sx.js} +1 -1
  53. package/dist/cli/{index-6s3ab22d.js → index-dfrcc46h.js} +2 -2
  54. package/dist/cli/{index-9v43y7y6.js → index-epdzvp4w.js} +11 -11
  55. package/dist/cli/{index-n5xwza76.js → index-fk4j26km.js} +7 -7
  56. package/dist/cli/{index-ndec8akq.js → index-gc0aeth5.js} +2 -2
  57. package/dist/cli/{index-fd6b9f38.js → index-ghckhk16.js} +2 -2
  58. package/dist/cli/{index-ehab3z5y.js → index-gns3gc87.js} +4 -4
  59. package/dist/cli/{index-rpnkp79f.js → index-gz16dke1.js} +6 -6
  60. package/dist/cli/{index-kp5qw5p4.js → index-h7275akd.js} +45 -45
  61. package/dist/cli/{index-9kbnxb7v.js → index-ha8xc5d3.js} +2 -2
  62. package/dist/cli/{index-1jt12p3y.js → index-hqrkr9ag.js} +1 -1
  63. package/dist/cli/{index-w2vbaczx.js → index-hy2fqapm.js} +1 -1
  64. package/dist/cli/{index-st80sjg7.js → index-j8t1g5qd.js} +1 -1
  65. package/dist/cli/{index-t6aae9wq.js → index-jatgbm7k.js} +1 -1
  66. package/dist/cli/{index-4ftg3p9n.js → index-jn4mmhqc.js} +2 -2
  67. package/dist/cli/{index-jrs2qh6j.js → index-kmvy5fr8.js} +4 -4
  68. package/dist/cli/{index-84k9zzv1.js → index-kphy4we7.js} +1 -1
  69. package/dist/cli/{index-7njm9jk1.js → index-necqa5bj.js} +2 -2
  70. package/dist/cli/{index-6xppb1er.js → index-peyz4k9k.js} +1 -1
  71. package/dist/cli/{index-3atkcqpb.js → index-ry5g9s8d.js} +1 -1
  72. package/dist/cli/{index-3dpb3kps.js → index-tc8x0zc5.js} +4 -4
  73. package/dist/cli/{index-e8k0v19e.js → index-xmbtwtgw.js} +1 -1
  74. package/dist/cli/{index-yfbk69b1.js → index-xs9cn3c0.js} +6 -6
  75. package/dist/cli/{index-hfssjyxs.js → index-yf2z4j7s.js} +2 -2
  76. package/dist/cli/{index-hfnyykvm.js → index-ypkfhqbc.js} +7 -7
  77. package/dist/cli/{index-9bzgea2y.js → index-yryy781f.js} +4 -4
  78. package/dist/cli/{index-f3ttgqak.js → index-z59414gv.js} +2 -2
  79. package/dist/cli/index.js +44 -44
  80. package/dist/cli/{knowledge-escalator-g6dctrae.js → knowledge-escalator-6sgrjbcj.js} +15 -15
  81. package/dist/cli/{knowledge-events-acdz0x2g.js → knowledge-events-hztjt63y.js} +13 -13
  82. package/dist/cli/{knowledge-link-srnt95wh.js → knowledge-link-8bn2b7vr.js} +5 -5
  83. package/dist/cli/{knowledge-store-vxtj4m59.js → knowledge-store-3sd2034v.js} +6 -6
  84. package/dist/cli/{knowledge-validator-b545vc9t.js → knowledge-validator-3fe82zy4.js} +8 -8
  85. package/dist/cli/{mcp-c3t18313.js → mcp-spbx3efe.js} +1 -1
  86. package/dist/cli/{model-preflight-r99c08re.js → model-preflight-k2bw7rt1.js} +43 -43
  87. package/dist/cli/{pending-delegations-57f3049j.js → pending-delegations-kcvd9t41.js} +12 -12
  88. package/dist/cli/{pr-subscriptions-5jb793xe.js → pr-subscriptions-nqby87en.js} +12 -12
  89. package/dist/cli/{pr-workflow-gate-n3x25ddw.js → pr-workflow-gate-cgbc0x1z.js} +57 -43
  90. package/dist/cli/{runner-b2e89cp1.js → runner-rt2smh14.js} +6 -6
  91. package/dist/cli/{scan-cursor-s9mazw82.js → scan-cursor-sphr9phs.js} +7 -7
  92. package/dist/cli/{schema-7czxpvwm.js → schema-x892aatt.js} +2 -2
  93. package/dist/cli/{scope-persistence-y0ebqyjm.js → scope-persistence-n9xksct2.js} +16 -16
  94. package/dist/cli/{server-m10e78ey.js → server-am2y11yn.js} +43 -43
  95. package/dist/cli/{skill-generator-kzw1dcba.js → skill-generator-p71b6h5k.js} +17 -17
  96. package/dist/cli/{snapshot-coordination-init-z1aqsvn4.js → snapshot-coordination-init-x9b4t9sk.js} +43 -43
  97. package/dist/cli/{speckit-checkoff-1g3vzywn.js → speckit-checkoff-xp9vsp9k.js} +5 -5
  98. package/dist/cli/{telemetry-qaymh4gg.js → telemetry-vapc5q4p.js} +1 -1
  99. package/dist/cli/{workspace-snapshot-p69t9zn7.js → workspace-snapshot-e3kw9kpg.js} +3 -3
  100. package/dist/cli/{worktree-collision-ownership-d0etv08a.js → worktree-collision-ownership-2pmyww6g.js} +13 -13
  101. package/dist/cli/{worktree-isolation-dj2qw13p.js → worktree-isolation-379tmkta.js} +43 -43
  102. package/dist/hooks/pr-workflow-gate.d.ts +153 -0
  103. package/dist/host/v2/session-client.d.ts +45 -26
  104. package/dist/index.js +28 -26
  105. package/dist/pr-review/legacy-transcript-adapter.d.ts +54 -0
  106. package/dist/pr-review/render-review-body.d.ts +20 -0
  107. package/dist/tools/dispatch-lanes.d.ts +16 -1
  108. package/package.json +1 -1
  109. package/dist/cli/curator-llm-factory-97dpqjz4.js +0 -82
  110. package/dist/cli/guardrail-explain-24g3bsqw.js +0 -83
@@ -464,6 +464,20 @@ interface PrReviewBatchCoherenceRecord {
464
464
  reviewerItemBindings?: Record<string, string>;
465
465
  /** Key encoding for reviewerItemBindings; absent means legacy raw item IDs. */
466
466
  reviewerItemBindingKeyEncoding?: 'prefixed-v1';
467
+ /**
468
+ * Issue #2906: reviewer batches only. The presentation order this batch's
469
+ * candidates were counterbalanced into — 'A' renders the canonical sorted
470
+ * inventory, 'B' the exact reverse — alternating by reviewer-batch ordinal
471
+ * within the reviewer window so repeated passes observe order effects.
472
+ */
473
+ presentationOrder?: 'A' | 'B';
474
+ /**
475
+ * Issue #2906: critic batches only. AUDIT-ONLY snapshot of the
476
+ * order-unstable item ids the critic prompt for this batch was flagged
477
+ * with (the prompt re-derives them live via
478
+ * `derivePrReviewOrderUnstableItems`); no runtime reader consumes this.
479
+ */
480
+ orderUnstableItemIds?: string[];
467
481
  }
468
482
  /** One rejected `submit_pr_review_result` attempt (issue #2859 F3 journal). */
469
483
  export interface PrReviewSubmitRejectionRecord {
@@ -474,6 +488,22 @@ export interface PrReviewSubmitRejectionRecord {
474
488
  }
475
489
  /** FIFO cap for the gate-state submit-rejection journal (issue #2859 F3). */
476
490
  export declare const MAX_PR_REVIEW_SUBMIT_REJECTIONS = 24;
491
+ /**
492
+ * One rejected `write_pr_review_artifact` attempt (issue #3098 verdict-lane
493
+ * journal, mirroring the #2859 discovery journal). `sessionId` is the gate
494
+ * owner (the orchestrator session that called the tool) — provenance only;
495
+ * the composition joins entries to lanes via `workflowLane`/`laneId`.
496
+ */
497
+ export interface PrReviewVerdictRejectionRecord {
498
+ sessionId: string;
499
+ laneId?: string;
500
+ workflowLane?: string;
501
+ boundary?: 'post_explorer' | 'post_reviewer' | 'post_critic';
502
+ at: number;
503
+ message: string;
504
+ }
505
+ /** FIFO cap for the gate-state verdict-write-rejection journal (issue #3098). */
506
+ export declare const MAX_PR_REVIEW_VERDICT_REJECTIONS = 24;
477
507
  export interface PrWorkflowGateState {
478
508
  schemaVersion: 1;
479
509
  /** Monotonic durable revision used to reject stale same-session transitions. */
@@ -588,6 +618,17 @@ export interface PrWorkflowGateState {
588
618
  * to 300 chars at write time.
589
619
  */
590
620
  prReviewSubmitRejections?: PrReviewSubmitRejectionRecord[];
621
+ /**
622
+ * Bounded FIFO journal of rejected `write_pr_review_artifact` attempts
623
+ * (issue #3098, the verdict-lane mirror of the #2859 journal above).
624
+ * Observability only — surfaced in the verdict composition diagnostic so
625
+ * the orchestrator can see WHY a declared reviewer/critic lane produced no
626
+ * successful exact artifact; never consulted for artifact validity. Capped
627
+ * by {@link MAX_PR_REVIEW_VERDICT_REJECTIONS}; each entry's message is
628
+ * bounded to 300 chars at write time. `sessionId` is the gate-owner caller
629
+ * (provenance); lane join happens via `workflowLane`/`laneId`.
630
+ */
631
+ prReviewVerdictRejections?: PrReviewVerdictRejectionRecord[];
591
632
  prReviewHandoffPath?: string;
592
633
  prReviewHandoffRequired?: boolean;
593
634
  checkoutRecovery?: PrWorkflowCheckoutRecoveryRecord;
@@ -714,6 +755,38 @@ export declare function recordPrReviewSubmitRejection(directory: string, childSe
714
755
  * ever see its most recent rejections.
715
756
  */
716
757
  export declare function latestPrReviewSubmitRejectionMessage(state: Pick<PrWorkflowGateState, 'prReviewSubmitRejections'>, childSessionId: string): string | undefined;
758
+ /**
759
+ * Issue #3098: best-effort, fail-open journal of one rejected
760
+ * `write_pr_review_artifact` attempt onto the CALLER's own PR_REVIEW gate
761
+ * state (the tool is a controller tool invoked by the gate-owner session —
762
+ * no delegation parent-hop, unlike the #2859 discovery journal).
763
+ * Observability only — never changes the rejection outcome, never creates
764
+ * gate state for a session that has none (the pre-read outside the
765
+ * session-state lock means a non-gated caller gets no lock file either).
766
+ */
767
+ export declare function recordPrReviewVerdictRejection(directory: string, sessionID: string, message: string, attribution?: {
768
+ laneId?: string;
769
+ workflowLane?: string;
770
+ boundary?: 'post_explorer' | 'post_reviewer' | 'post_critic';
771
+ }): Promise<void>;
772
+ /**
773
+ * Issue #3098: latest journal message for a failing obligation, or undefined.
774
+ * Newest wins. Join keys are `workflowLane` (the declared obligation) and
775
+ * `laneId`; the recorded `sessionId` is the gate-owner caller (provenance),
776
+ * never a lane child session, so it is deliberately not a join key.
777
+ *
778
+ * The production writer only ever stamps `boundary` (the write args name the
779
+ * boundary, never a lane), so in practice the phase-scoped fallback below is
780
+ * what resolves: it reports the newest rejection recorded for the failing
781
+ * lane's PHASE, which is honest about being phase-scoped rather than
782
+ * lane-scoped. The lane-exact arms stay because a future attribution producer
783
+ * (or a hand-seeded state) can populate them.
784
+ */
785
+ export declare function latestPrReviewVerdictRejectionForLane(state: Pick<PrWorkflowGateState, 'prReviewVerdictRejections'>, matchers: {
786
+ workflowLane?: string;
787
+ laneIds?: readonly string[];
788
+ boundary?: 'post_explorer' | 'post_reviewer' | 'post_critic';
789
+ }): string | undefined;
717
790
  /**
718
791
  * Issue #2859 (F3): single wrap point over every gate-layer rejection path in
719
792
  * `submitPrReviewResultCore` (all 15 `{ status: 'rejected' }` return sites —
@@ -1253,6 +1326,13 @@ export declare function recordPrReviewMicroFamilyDispatch(directory: string, ses
1253
1326
  export declare function recordPrReviewValidationBatch(directory: string, sessionID: string, phase: PrReviewValidationPhase, lanes: readonly PrWorkflowLaneSpec[], options: {
1254
1327
  batchId: string;
1255
1328
  prHeadSha: string;
1329
+ /**
1330
+ * Issue #2906: reviewer batches only. The presentation order the dispatch
1331
+ * prompt was counterbalanced for (from `derivePrReviewPresentationOrder`).
1332
+ * When supplied and the re-derived ordinal disagrees, recording fails
1333
+ * closed so the prompt can never misrepresent the stamped receipt.
1334
+ */
1335
+ expectedPresentationOrder?: 'A' | 'B';
1256
1336
  }): Promise<PrWorkflowGateState>;
1257
1337
  /**
1258
1338
  * Validate that every declared council obligation has a successful retry, and
@@ -1491,6 +1571,27 @@ export declare function markPrReviewHandoffComplete(directory: string, sessionID
1491
1571
  state: PrWorkflowGateState;
1492
1572
  alreadyOffered: boolean;
1493
1573
  }>;
1574
+ interface PrReviewFindingPolicyAuthority {
1575
+ policyFindings: Array<{
1576
+ id: string;
1577
+ status: string;
1578
+ severity: string;
1579
+ action: string;
1580
+ [key: string]: unknown;
1581
+ }>;
1582
+ criticSettlements: Array<{
1583
+ findingId: string;
1584
+ terminal: boolean;
1585
+ status: CriticOutcome;
1586
+ }>;
1587
+ }
1588
+ /**
1589
+ * Read the policy sidecar as an integrity-bound projection of the final
1590
+ * findings artifact. A write-only sidecar is not evidence: the route receipt
1591
+ * pins the PR head and exact findings bytes, while the sidecar digest pins the
1592
+ * synthesized projection itself.
1593
+ */
1594
+ export declare function readAuthoritativeFindingPolicy(directory: string, state: PrWorkflowGateState): Promise<PrReviewFindingPolicyAuthority>;
1494
1595
  /** Read-only final finding-policy projection for completion reports. */
1495
1596
  export declare function readPrReviewFinalFindingPolicyForReport(directory: string, sessionID: string): Promise<{
1496
1597
  policyVersion: 1;
@@ -1677,6 +1778,8 @@ export declare const _test_exports: {
1677
1778
  validatedInventory: string[];
1678
1779
  reviewerItemBindings?: Record<string, string> | undefined;
1679
1780
  reviewerItemBindingKeyEncoding?: "prefixed-v1" | undefined;
1781
+ presentationOrder?: "A" | "B" | undefined;
1782
+ orderUnstableItemIds?: string[] | undefined;
1680
1783
  }> | undefined;
1681
1784
  prReviewRetiredReviewerSessionIds?: string[] | undefined;
1682
1785
  prReviewRetiredConsolidatedLanes?: string[] | undefined;
@@ -1721,6 +1824,15 @@ export declare const _test_exports: {
1721
1824
  message: string;
1722
1825
  laneId?: string | undefined;
1723
1826
  }[] | undefined;
1827
+ prReviewVerdictRejections?: {
1828
+ [x: string]: unknown;
1829
+ sessionId: string;
1830
+ at: number;
1831
+ message: string;
1832
+ laneId?: string | undefined;
1833
+ workflowLane?: string | undefined;
1834
+ boundary?: "post_explorer" | "post_reviewer" | "post_critic" | undefined;
1835
+ }[] | undefined;
1724
1836
  prReviewArtifactBoundaries?: ("post_explorer" | "post_reviewer" | "post_critic")[] | undefined;
1725
1837
  prReviewHandoffPath?: string | undefined;
1726
1838
  prReviewHandoffRequired?: boolean | undefined;
@@ -2333,6 +2445,47 @@ export declare function readAuthoritativePrReviewCriticVerdicts(directory: strin
2333
2445
  status: string;
2334
2446
  severity: string;
2335
2447
  }>>;
2448
+ /**
2449
+ * Issue #2906: the presentation order the NEXT reviewer batch will be
2450
+ * counterbalanced into — 'A' when the reviewer window holds an even number of
2451
+ * batches, 'B' when odd. Pure function of the persisted window state; the
2452
+ * dispatch tool derives it before prompt assembly and passes the same value to
2453
+ * `recordPrReviewValidationBatch` as `expectedPresentationOrder`, which
2454
+ * re-derives and fails closed on divergence.
2455
+ *
2456
+ * Issue #2906 review finding F-03: at the `MAX_WORKFLOW_BATCHES` cap the
2457
+ * record guard counts the window of the PRUNED state (its read-prune-append
2458
+ * transaction applies `prunePrWorkflowBatchesForCapacity` before deriving the
2459
+ * stamped ordinal), while this derivation used to count the unpruned persisted
2460
+ * window. When the prune flipped the window parity the guard threw — before
2461
+ * `persistState`, so the prune was never durable — and every retry re-derived
2462
+ * the same divergent value: a permanent liveness wedge that failed closed.
2463
+ * This derivation therefore applies the SAME pure prune under the SAME
2464
+ * >= cap condition, so both sides count the identical window. The prune is
2465
+ * pure with respect to durable state (it reads artifacts and returns a
2466
+ * candidate state; only the record path persists it), so running it here
2467
+ * cannot violate the BL-6 single-transaction rule. Every prune-abort path
2468
+ * (inventory inequality, unreadable delegation store, ledger overflow) returns
2469
+ * the state unchanged here AND inside the record guard, so the two sides agree
2470
+ * on those paths as well; a divergence that still reaches the guard means the
2471
+ * state genuinely changed between derivation and recording, which fails closed
2472
+ * and is recoverable by re-deriving.
2473
+ */
2474
+ export declare function derivePrReviewPresentationOrder(directory: string, sessionID: string): Promise<'A' | 'B'>;
2475
+ /**
2476
+ * Issue #2906: every currently-composed reviewer item whose verdict flipped
2477
+ * across counterbalanced presentation orders (`orderAgreement: 'disagree'`).
2478
+ * The critic dispatch tool renders these as `order_unstable_item_ids` so the
2479
+ * critic prioritizes them.
2480
+ */
2481
+ export declare function derivePrReviewOrderUnstableItems(directory: string, sessionID: string): Promise<string[]>;
2482
+ /**
2483
+ * Issue #2906: the authoritative per-item order-agreement map for the findings
2484
+ * writer — the same reader shape as `readAuthoritativePrReviewCriticVerdicts`,
2485
+ * so a model-supplied `order_agreement` on a findings row can be cross-checked
2486
+ * against the composed reviewer claims instead of being taken on trust.
2487
+ */
2488
+ export declare function readAuthoritativePrReviewOrderAgreement(directory: string, sessionID: string): Promise<Map<string, 'agree' | 'disagree' | 'single'>>;
2336
2489
  interface ExpectedWorkflowLane {
2337
2490
  laneId: string;
2338
2491
  workflowLane: string;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * v2 session client shim — issue #3169 Phase 2.
2
+ * v2 session client shim — issue #3169 Phase 2 (+ Phase 3 lane sessions).
3
3
  *
4
4
  * A narrow `OpencodeClient` subset implementing exactly the v1 session surface
5
5
  * Epic's dispatch paths use (`session.create/prompt/abort/delete` plus `get`,
@@ -14,27 +14,36 @@
14
14
  * findings on @opencode/cli 2.0.26):
15
15
  *
16
16
  * - `create({body:{parentID,title}, query:{directory}})` validates placement
17
- * BEFORE creating anything: v2 child sessions inherit the parent's
18
- * directory and ignore the requested one (Phase 0 C1 catch), so a divergent
19
- * or unverifiable placement fails closed with a typed `{data: null,
20
- * error}` result — routing worktree isolation to its existing degradation
21
- * path instead of silently running a "lane" session in the project root.
22
- * A passing precheck mints a placeholder id; the real v2 session is
23
- * created at PROMPT time, when the v1 prompt body supplies the create-time
24
- * options (agent/model/permissions) the published `SessionCreateInput`
25
- * expects (issue R2: one session per dispatch contains the per-session
26
- * shift).
17
+ * BEFORE creating anything. Phase 3: a CONFIRMED parent-directory divergence
18
+ * (the worktree-isolation lane shape — a lane worktree directory always
19
+ * differs from the parent's project root) now takes the EAGER path: a REAL
20
+ * parentless host session created immediately in the requested directory
21
+ * (Phase 0 C1: parented children inherit the parent's directory; parentless
22
+ * creates honor the requested one), placement verified post-create (echo,
23
+ * `get` fallback) with a remove-and-fail-closed guard, and the requested
24
+ * `parentID` REMEMBERED plugin-side and overlaid onto `get` results so
25
+ * `prWorkflowSessionResolver`'s first-hop controller resolution
26
+ * (`pr-workflow-session-resolver.ts`) and `lookupParentSessionIDForTaskRoute`
27
+ * stay v1-faithful for parentless lane children (the host-side link is what
28
+ * the v2 host cannot carry here). A real id is returned — the native
29
+ * `subagent` tool resumes it by id (Phase 0 C7). Unverifiable parent
30
+ * placement still fails closed with the Phase 2 typed error (live-verification
31
+ * item), and same-directory/parentless creates keep the deferred placeholder
32
+ * (the real create there must carry prompt-time options — permissions are
33
+ * create-time-only on v2).
27
34
  * - `prompt({path:{id}, body:{agent,model?,system?,tools,parts}, signal?})`
28
- * emulates the v1 BLOCKING call: real create (carrying agent/model and the
29
- * read-only denial map as `effect:'deny'` permissions) → one sessionID-
30
- * scoped `context` hook that replaces `event.system` (fence-aware: parts
31
- * carrying the `<swarm_system_directive` provenance fence survive, per
32
- * #2526) and deletes denied keys from `event.tools` → `prompt` → bounded
33
- * `wait` → `context()` translated into the v1 `{data:{info,parts}}`
34
- * envelope so `dispatchEphemeralAgent` and `readProviderMessageError`
35
- * work unchanged. A prompt addressed to a non-placeholder (real) session
36
- * id takes a direct path without re-creating — the pr-event-delivery wake
37
- * prompt shape.
35
+ * emulates the v1 BLOCKING call over three arms keyed on the registry:
36
+ * (1) an EAGER record → full treatment on the real session — `switchAgent` +
37
+ * `switchModel`, a sessionID-scoped `context` hook (fence-aware system
38
+ * replacement preserving `<swarm_system_directive` parts, denied-tool
39
+ * deletion from `event.tools`), epoch-scoped error clear, `prompt` →
40
+ * bounded `wait` → `context()`; (2) a deferred/already-prompted PLACEHOLDER
41
+ * → real create carrying agent/model + the read-only denial map as
42
+ * `effect:'deny'` permissions, then the same hook/prompt/wait/context
43
+ * sequence, with the #3186 PRR-002 retire-and-recreate on re-prompts;
44
+ * (3) a foreign real id → the direct path (agent switch only). All three
45
+ * translate into the v1 `{data:{info,parts}}` envelope so
46
+ * `dispatchEphemeralAgent` and `readProviderMessageError` work unchanged.
38
47
  * - Provider failures are EVENT-SOURCED on v2 (Phase 0 C4: no error text in
39
48
  * `context()`), so the event pump records `session.error` /
40
49
  * `session.execution.failed` payloads here (`recordV2SessionErrorFromEnvelope`,
@@ -42,15 +51,25 @@
42
51
  * translation surfaces them as the v1 `info.error` shape. A failed outcome
43
52
  * without recorded detail yields a bounded `provider.unknown` error
44
53
  * instead of a silent empty success.
45
- * - `abort` maps to `interrupt`, `delete` to `remove`, `get` to the v2 get
46
- * (unresolved placeholders read as `{data: null}` — never prompted means
47
- * gone, satisfying `teardownEphemeralSessionVerified`).
54
+ * - `abort` maps to `interrupt`, `delete` to `remove` (eager records are
55
+ * pruned after the removal resolves — the id is real, so a later `get`
56
+ * still resolves through to a host that reports the session gone), and
57
+ * `get` maps `{path:{id}}` onto `ctx.session.get({sessionID})` returning
58
+ * `{data: info}` — verified teardown through the shim resolves.
59
+ *
60
+ * Registry (invariant 8): placeholder and eager records share ONE bounded map
61
+ * (cap 64, FIFO). Placeholder residue is intentionally not pruned (keep-for-get);
62
+ * that residue shares the cap, so a live eager record can be evicted after 64
63
+ * later insertions of any kind — a disclosed, bounded degradation (its next
64
+ * prompt takes the direct path and the parentID overlay stops applying), pinned
65
+ * in tests/unit/host/v2/session-client-lane-3169.test.ts.
48
66
  *
49
67
  * Deferred-work marker: NONE. The unverified live-host behaviors this design
50
68
  * rests on are recorded as deferrals in the trace (context-hook firing for
51
69
  * plugin-created sessions, permission vocabulary honor, `context()` entry
52
- * shapes, `wait` on failed prompts, `get(parent).location` availability) with
53
- * the owning follow-up on #3169.
70
+ * shapes, `wait` on failed prompts, `get(parent).location` availability,
71
+ * parentless subagent resume + parentID overlay — LVD-1..LVD-4) with the owning
72
+ * follow-up on #3169.
54
73
  *
55
74
  * C6 await convention: every `await` lives inside a `deferredV2Session*`
56
75
  * function declaration or `const deferredV2SessionX = async (` binding — the