pi-lens 4.4.5 → 4.4.7

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 (159) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +37 -1
  3. package/config/biome/core.jsonc +3 -3
  4. package/dist/{chunk-6XSESGWD.js → chunk-24BILSZW.js} +2 -2
  5. package/dist/{chunk-YXDCRUKQ.js → chunk-2PHMIAKO.js} +4 -4
  6. package/dist/{chunk-EN5AM7PX.js → chunk-2TF6RXWB.js} +10 -10
  7. package/dist/{chunk-XI34NWDI.js → chunk-3F6BMY53.js} +1 -1
  8. package/dist/{chunk-VUAVE3QC.js → chunk-3FRLWYBG.js} +36 -36
  9. package/dist/{chunk-THEXI2QO.js → chunk-3K2F6UDZ.js} +42 -42
  10. package/dist/{chunk-ZPJM7DID.js → chunk-3YY7IXIL.js} +3 -3
  11. package/dist/chunk-46TNM7XZ.js +88 -0
  12. package/dist/{chunk-TL2TCJYL.js → chunk-4L36HG27.js} +14 -14
  13. package/dist/{chunk-UCVMSOXF.js → chunk-4LM3VAZH.js} +2 -2
  14. package/dist/{chunk-AI3GP74G.js → chunk-4LOE5R5P.js} +15 -15
  15. package/dist/{chunk-AHWA4AKM.js → chunk-4YHYPW2G.js} +32 -9
  16. package/dist/{chunk-VITFDI3O.js → chunk-4ZYJHQMB.js} +12 -12
  17. package/dist/{chunk-KCBRHV5E.js → chunk-6IR3ZYIB.js} +3 -3
  18. package/dist/chunk-72OKUXSD.js +31 -0
  19. package/dist/{chunk-RCHO5W7M.js → chunk-75GAYVNO.js} +13 -12
  20. package/dist/{chunk-2SDHYHHO.js → chunk-7E2563GA.js} +13 -13
  21. package/dist/chunk-7GLOLOSH.js +57 -0
  22. package/dist/{chunk-CG5V25HX.js → chunk-ABPKUVA4.js} +1 -1
  23. package/dist/chunk-AKUUMGD5.js +26 -0
  24. package/dist/chunk-ASUXV767.js +22 -0
  25. package/dist/{chunk-Q42LJANT.js → chunk-AWDSEDER.js} +2 -2
  26. package/dist/{chunk-Y2TPADJR.js → chunk-BZARLRJW.js} +9 -9
  27. package/dist/{chunk-YKVDBNPO.js → chunk-CB4WHS4H.js} +3 -3
  28. package/dist/{chunk-YXGRRORB.js → chunk-CCV2EU7T.js} +13 -13
  29. package/dist/{chunk-PJXNTPB2.js → chunk-CE6VMBCB.js} +21 -21
  30. package/dist/{chunk-KPVLQHCZ.js → chunk-CPSR3AVL.js} +2 -2
  31. package/dist/chunk-CTADOKYM.js +25 -0
  32. package/dist/{chunk-CPZ5JJW6.js → chunk-DH5JPM3K.js} +4 -4
  33. package/dist/{chunk-4FHUGDKU.js → chunk-DPGEAHZT.js} +5 -5
  34. package/dist/{chunk-SNEUMLM7.js → chunk-DQZFQSR5.js} +4 -4
  35. package/dist/{chunk-RG3MXTRI.js → chunk-E7HJ56Y7.js} +7 -7
  36. package/dist/{chunk-YSDPVDFC.js → chunk-EAOK7MIZ.js} +3 -3
  37. package/dist/{chunk-PP2A5V2T.js → chunk-EKWX4WD3.js} +7 -7
  38. package/dist/{chunk-2LDMXL2M.js → chunk-F5Z6URKM.js} +2 -2
  39. package/dist/{chunk-72J27ICO.js → chunk-F6X3YJWD.js} +2 -2
  40. package/dist/{chunk-ELZRSR5N.js → chunk-F7K5IBZG.js} +41 -39
  41. package/dist/{chunk-EX4EXBW7.js → chunk-FB5SCCPT.js} +15 -15
  42. package/dist/{chunk-SJHC3BCZ.js → chunk-FZKFVUEC.js} +518 -233
  43. package/dist/{chunk-UVY4TOJH.js → chunk-GNSIWBAT.js} +3 -3
  44. package/dist/{chunk-EXVXBSGN.js → chunk-H7OR7DFZ.js} +20 -18
  45. package/dist/{chunk-NLIVE7L6.js → chunk-HO6LWE2E.js} +1 -1
  46. package/dist/{chunk-X3UTCXAA.js → chunk-HR3OJ3TH.js} +12 -12
  47. package/dist/{chunk-HYVXA3BB.js → chunk-HWDAVBFU.js} +23 -23
  48. package/dist/{chunk-ZSUX7KEM.js → chunk-J6JP25XU.js} +2 -2
  49. package/dist/{chunk-T4NGVFYI.js → chunk-JJ2RRESP.js} +8 -5
  50. package/dist/{chunk-RU34BA4D.js → chunk-JMEKXFOL.js} +34 -34
  51. package/dist/{chunk-IL7K66ZQ.js → chunk-KDX35VXP.js} +74 -18
  52. package/dist/{chunk-EDMLIW6W.js → chunk-KKCK636N.js} +12 -12
  53. package/dist/{chunk-KJJAVH3X.js → chunk-KPPJTH44.js} +6 -5
  54. package/dist/{chunk-5LRUKYFA.js → chunk-KW5JQPO5.js} +2 -2
  55. package/dist/{chunk-N3PLNNCW.js → chunk-KXF5R4UN.js} +1 -1
  56. package/dist/{chunk-YWNO5Q4R.js → chunk-L3CMBQMH.js} +17 -17
  57. package/dist/{chunk-YWWG4AQA.js → chunk-L5JYIU47.js} +24 -25
  58. package/dist/{chunk-K2GUZ4DN.js → chunk-LBLBAFG3.js} +4 -4
  59. package/dist/{chunk-APFJKOP6.js → chunk-LLS45EWB.js} +10 -2
  60. package/dist/{chunk-MKPCELNI.js → chunk-LS3QJRUB.js} +13 -13
  61. package/dist/chunk-LSC3VADM.js +23 -0
  62. package/dist/{chunk-F7BO6FWH.js → chunk-LUBPZN36.js} +11 -11
  63. package/dist/{chunk-ASRAO7KG.js → chunk-LV4UMYVH.js} +27 -27
  64. package/dist/{chunk-COOUUC5W.js → chunk-MB6PXBUA.js} +6 -6
  65. package/dist/{chunk-3WCEHYOI.js → chunk-MNJIXFX4.js} +1 -1
  66. package/dist/{chunk-FEDWAYDS.js → chunk-MPKRJBPK.js} +35 -15
  67. package/dist/{chunk-Q4BKKOVC.js → chunk-N5WSK2K7.js} +8 -8
  68. package/dist/{chunk-K4SZB56V.js → chunk-NA7SEXHE.js} +12 -8
  69. package/dist/{chunk-UL5SXQVX.js → chunk-O4BJFESU.js} +1 -1
  70. package/dist/{chunk-LMCTHJ2H.js → chunk-OE5ZBP7F.js} +18 -18
  71. package/dist/{chunk-NFNVDDGB.js → chunk-OSTKYB55.js} +1 -1
  72. package/dist/{chunk-27VWVB23.js → chunk-OXOI55RU.js} +10 -10
  73. package/dist/{chunk-7IYC4ENJ.js → chunk-PKES3ISE.js} +2 -2
  74. package/dist/{chunk-EWXXLS26.js → chunk-PQJFG24Z.js} +82 -12
  75. package/dist/{chunk-3SNDVPOR.js → chunk-PR6PO3ES.js} +8 -8
  76. package/dist/{chunk-63NMUNYP.js → chunk-PUZ3E2J4.js} +6 -6
  77. package/dist/{chunk-DS2USX5G.js → chunk-QHSNL7B2.js} +11 -11
  78. package/dist/{chunk-UO66IMVP.js → chunk-QOE342SU.js} +2 -2
  79. package/dist/{chunk-7ZS7MC24.js → chunk-R5MOQM2H.js} +107 -40
  80. package/dist/{chunk-JWOVP5BL.js → chunk-RC2Z6K47.js} +6 -6
  81. package/dist/{chunk-GLW3YDZZ.js → chunk-RORGS5II.js} +9 -9
  82. package/dist/{chunk-Y5KTA2OB.js → chunk-RQS4QQSD.js} +2 -2
  83. package/dist/{chunk-KFXCL4OV.js → chunk-RRV3FNNM.js} +22 -23
  84. package/dist/{chunk-GYRZ72R4.js → chunk-RZOXUSPC.js} +2 -2
  85. package/dist/chunk-SHLDT3OI.js +27 -0
  86. package/dist/{chunk-IEBJF3PN.js → chunk-SNDXCFRS.js} +15 -13
  87. package/dist/{chunk-XHLK33VM.js → chunk-T7A2HK2B.js} +16 -16
  88. package/dist/{chunk-WUY4BZEP.js → chunk-TIQJPRDD.js} +106 -50
  89. package/dist/{chunk-2FYKETQJ.js → chunk-U2SDMG7C.js} +5 -5
  90. package/dist/{chunk-EIKRZ32J.js → chunk-U5HPROLA.js} +2 -2
  91. package/dist/{chunk-2Y6OJRSI.js → chunk-U6VN4NVL.js} +3 -3
  92. package/dist/{chunk-OZNCKLOX.js → chunk-U7BD2QL7.js} +12 -12
  93. package/dist/chunk-UF7RTZSO.js +27 -0
  94. package/dist/{chunk-XHDBJODR.js → chunk-URCQWAQ4.js} +21 -21
  95. package/dist/{chunk-7FLRUH6B.js → chunk-V63BC55Q.js} +1 -1
  96. package/dist/{chunk-TVZRLTG6.js → chunk-VSFLRN5Y.js} +1 -1
  97. package/dist/{chunk-OMJ3OFBJ.js → chunk-VUZWQ7UG.js} +6 -6
  98. package/dist/chunk-W4WP2ERB.js +30 -0
  99. package/dist/{chunk-G224FADB.js → chunk-WDBICWH3.js} +1 -1
  100. package/dist/{chunk-4ODSZ35Z.js → chunk-WGRJOXED.js} +121 -155
  101. package/dist/{chunk-FWZRGGGY.js → chunk-WME2OQST.js} +39 -4
  102. package/dist/{chunk-MEFLGBCS.js → chunk-XT2HTCJ5.js} +3 -3
  103. package/dist/{chunk-VIDEKABZ.js → chunk-Y7F7IEE3.js} +55 -23
  104. package/dist/chunk-YES5CACN.js +73 -0
  105. package/dist/{chunk-ZAPSUBLU.js → chunk-YHC2O2WO.js} +7 -7
  106. package/dist/{chunk-GTDSYEA2.js → chunk-YISME6ON.js} +1 -1
  107. package/dist/{chunk-TPYYEDP5.js → chunk-YVHBNSME.js} +48 -29
  108. package/dist/{chunk-XWFIHYCH.js → chunk-Z2XAOKHK.js} +2 -2
  109. package/dist/{chunk-QT66NEYN.js → chunk-ZE3KXHS7.js} +3 -3
  110. package/dist/{chunk-S55TEC7I.js → chunk-ZGSJDWQU.js} +2 -2
  111. package/dist/{chunk-4U7GDSZQ.js → chunk-ZJTT47IG.js} +2 -2
  112. package/dist/{chunk-KX56K73G.js → chunk-ZKXQKGWZ.js} +2 -2
  113. package/dist/{chunk-5DKE4HGX.js → chunk-ZMAUPOMG.js} +34 -34
  114. package/dist/index.js +2446 -1303
  115. package/dist/mcp/analyze-cli.js +10 -10
  116. package/dist/mcp/cli.js +42 -42
  117. package/dist/mcp/server.js +724 -472
  118. package/dist/mcp/worker.js +61 -61
  119. package/dist/probes/installer.js +19 -19
  120. package/docs/agent-tools.md +39 -10
  121. package/docs/configuration.md +3 -1
  122. package/docs/defect-shapes.md +752 -0
  123. package/docs/dependencies.md +1 -0
  124. package/docs/environment-variables.md +14 -0
  125. package/docs/features.md +11 -1
  126. package/docs/globalconfig.md +12 -1
  127. package/docs/invariants/caches-stores.md +30 -0
  128. package/docs/invariants/dispatch-runners.md +164 -0
  129. package/docs/invariants/git-guard-host.md +87 -0
  130. package/docs/invariants/language-config.md +31 -0
  131. package/docs/invariants/lsp-trust-exec.md +292 -0
  132. package/docs/invariants/paths-os.md +59 -0
  133. package/docs/invariants/session-telemetry.md +114 -0
  134. package/docs/lsp-capability-matrix.md +89 -45
  135. package/docs/lsp-idle-eviction.md +3 -5
  136. package/docs/pi-lens-fixer.md +10 -2
  137. package/docs/pi-lens-merge-policy.md +17 -12
  138. package/docs/pi-lens-monitor.md +2 -2
  139. package/docs/pi-lens-orchestration.md +41 -0
  140. package/docs/pi-lens-release.md +20 -0
  141. package/docs/pi-lens-retro.md +3 -2
  142. package/docs/pi-lens-reviewer.md +6 -6
  143. package/docs/pi-lens-subagent.md +9 -6
  144. package/docs/schema/pi-lens-config-v1.json +23 -0
  145. package/docs/servercapabilities.md +1 -1
  146. package/docs/settings.md +5 -0
  147. package/docs/usage.md +5 -0
  148. package/package.json +3 -2
  149. package/dist/chunk-22Y2BM7H.js +0 -23
  150. package/dist/chunk-44X7VIKR.js +0 -73
  151. package/dist/chunk-54NIOJJZ.js +0 -25
  152. package/dist/chunk-7WWQAW5P.js +0 -30
  153. package/dist/chunk-EA2ZRG44.js +0 -27
  154. package/dist/chunk-EKNWOL2I.js +0 -27
  155. package/dist/chunk-G5UCJFT7.js +0 -26
  156. package/dist/chunk-N5FBM25N.js +0 -22
  157. package/dist/chunk-P5XUGPIX.js +0 -31
  158. package/dist/chunk-PKOXJIVT.js +0 -88
  159. package/dist/chunk-RG7OODGM.js +0 -57
@@ -0,0 +1,292 @@
1
+ <important if="touching lsp, trust, and process execution rules">
2
+
3
+ ### LSP, trust, and process execution
4
+
5
+ - `safeSpawnAsync` is the subprocess seam. It carries ambient abort behavior,
6
+ process-tree cleanup, output caps, typed failure kinds, and bounded timeouts.
7
+ Installs pass `ignoreAmbientSignal: true` and remain trust-gated.
8
+ The seam defaults `GIT_OPTIONAL_LOCKS=0`, so unless a caller `env` override
9
+ sets it, no child takes git's optional index lock that a timeout or host exit
10
+ could orphan (#4930). The cost of the default: git does not write back its
11
+ refreshed stat cache, so
12
+ on a stat-dirty checkout each status read re-hashes the dirty set until the
13
+ user's own git command refreshes the index.
14
+ It is also the lookup chokepoint. Under pi trust other than
15
+ `trusted`, every child's search path loses the session repository's own
16
+ directories, and a bare command that still resolves into them is refused
17
+ with a typed `trust-refused` result. "Session repository" is one rule in
18
+ `clients/session-repository.ts`, never a caller-threaded root: the kernel-real
19
+ path lies under `process.cwd()`, under a project-local bin dir of its
20
+ ancestors below HOME, or in a checkout sharing its git commondir; the data
21
+ dir never counts and a session at or above HOME owns nothing. Lookups that
22
+ start a path rather than a name (`which` answers, global bin dirs, the
23
+ installer's PATH walk, the LSP launcher) ask `isUntrustedProjectPath` or
24
+ `admittedLookupAnswer` for the same judgment, and every refusal writes one
25
+ `trust-refusal` row per target. A raw `node:child_process` start in the
26
+ runtime trees is a hole by construction:
27
+ `tests/config/spawn-chokepoint-sweep.test.ts` derives them from the module
28
+ binding and requires each to be routed, or admitted with a reason, evidence
29
+ and a pinned site count. Extend the seam; never add a per-caller guard. A
30
+ non-pi maintenance host that starts the checkout's own tools adopts trust at
31
+ its entry, as the MCP entry points do.
32
+ - Under pi, project trust is consumed through `isProjectTrusted`; pi-lens never
33
+ registers the host's trust-answer handler. `compileLspRegistry` is the one admission
34
+ seam for LSP executable fields: global config and built-ins remain allowed,
35
+ while project `command`, command overrides, `env`, and
36
+ `initializationOptions` require pi's `trusted` answer. Missing trust APIs are
37
+ fail-closed for those project fields with one bounded notice; installs keep
38
+ their existing compatibility policy. `tests/clients/lsp/lsp-registry-trust.test.ts`
39
+ and the LSP config/service suites pin the boundary.
40
+ Non-pi process entry points (`mcp/server.ts`, `mcp/worker.ts`,
41
+ `mcp/analyze-cli.ts`, and `mcp/cli.ts`) declare trusted execution once at
42
+ startup through `setProjectTrustState`: workspace trust belongs to their
43
+ calling client, and pi trust is not consulted.
44
+ `tests/mcp/server.smoke.test.ts` and `tests/mcp/analyze-cli.test.ts` pin it.
45
+ The standalone harness scripts that drive the built `dist/clients/lsp/`
46
+ service (`scripts/characterize-lsp.mjs`, `probe-clean-signal.mjs`,
47
+ `server-capabilities.mjs`, `measure-lsp-idle-eviction.mjs`, `bench-lsp.mjs`,
48
+ `smoke-tools.mjs`) are the same kind of entry point: each adopts trust once
49
+ through `adoptFixtureProjectTrust` (`scripts/lib/lsp-fixture-workspace.mjs`),
50
+ because a script that leaves trust `unknown` measures every refused server as
51
+ absent. `tests/config/lsp-script-trust-census.test.ts` fails a
52
+ `scripts/*.mjs` that reaches `dist/clients/lsp/` without it. The four nightly
53
+ producers that run under `continue-on-error` also report what they evaluated
54
+ to `scripts/lib/assert-evaluated.mjs` (one pure count function per producer,
55
+ called by the script and by its test); the nightly's floor step fails below
56
+ each measured floor and when a matrix cell classified at HEAD turned
57
+ `unknown` without a HEAD `firstMissed` stamp at least
58
+ `FIRST_PUBLISH_EXPIRY_DAYS` old (`tests/config/nightly-evaluated-floors.test.ts`).
59
+ Every other
60
+ `continue-on-error` producer either calls the same helper (`--count
61
+ <producer>=<n> --floor <m>` from a workflow step; `--min-pass`, the
62
+ complexity file count and the shuffle census's missing starts already do) or
63
+ needs none, and one census decides that: every `continue-on-error` site in a
64
+ `.github/workflows/*.yml` or `*.yaml` file and in a composite
65
+ `.github/actions/**/action.yml` or `action.yaml` is registered in
66
+ `tests/fixtures/nightly-floors/continue-on-error-sites.json` as `floored`
67
+ (naming the gating step and the floor text, which must sit in the argument
68
+ list of a named measuring invocation — `scripts/assert-evaluated.mjs`,
69
+ `scripts/smoke-tools.mjs`, `scripts/complexity-report.mjs` — on a top-level
70
+ line the shell executes, of a step whose `if:` is absent or a conjunction of
71
+ `always()`, `success()`, `!cancelled()` and one `github.event_name` or
72
+ `matrix.<name>` comparison the parsed document settles (the workflow's `on:`
73
+ keys, that job's `strategy.matrix` list), so
74
+ `!cancelled() && matrix.os == 'macos-latest'` counts only where the matrix
75
+ declares that leg; every other `if:` expression, including a trivially true
76
+ literal and a comparison no declared value satisfies, leaves the floor
77
+ unproven, and so does a job whose own `if:` the document proves never true).
78
+ A `\`-continued line and a line the previous one left unfinished with `&&`,
79
+ `||` or `|` are one command, so the measuring invocation must start the
80
+ joined command; an `exit` ends the script only in command position. A
81
+ `no-floor` row states the reader that makes an empty result visible, or
82
+ `governed-by` (naming the issue and the live tests that own the site, in
83
+ files vitest collects). The reader derives the population from the parsed
84
+ files, so it fails closed on a site the registry
85
+ does not name, on a producer file or a non-file entry it does not classify,
86
+ on a `continue-on-error` key in a location that is not a job or a step, and
87
+ on a floor whose evidence is not in the argument list of such an invocation
88
+ on a top-level command (a comment, a quoted command, a heredoc body, a
89
+ printed command, a function or block body, a subshell, a chained command, or
90
+ a line after an `exit`), or that names a step whose `if:` is outside that
91
+ allowlist; a floor comes from a run recorded in
92
+ `tests/fixtures/nightly-floors/measurements.json`. A
93
+ `# No floor (<issue>): <reason>` header above a job is human-facing copy
94
+ where one exists, not the record: six sites keep one (the five `lint.yml`
95
+ jobs and `install-smoke.yml`'s `mise-repro`), and the registry row the
96
+ census requires is the record.
97
+ The helper must stay importable without `dist/` (the refresh-PR job runs it
98
+ on a fresh checkout).
99
+ - LSP service generations, workspace-sweep holds, and repair latches use
100
+ versioned process singletons. Reset tears down the old generation before a
101
+ replacement can spawn. Idle eviction is lease-guarded and clears ownership
102
+ timers on every removal path.
103
+ - Production callers use the grouped experimental `LspCapabilities` adapter in
104
+ `clients/lsp/capabilities.ts`; direct `LSPService` module imports are limited
105
+ to that adapter and are enforced by
106
+ `tests/config/lsp-capabilities-import-sweep.test.ts` (#2372/#277).
107
+ - Idle-eviction policy is the registry's `idleEviction` field, declared per
108
+ server. The nightly (`scripts/measure-lsp-idle-eviction.mjs`) measures every
109
+ registry server's eviction cost and respawn safety into
110
+ `docs/lsp-idle-eviction.md` and changes no policy; a declaration change is a
111
+ follow-up that cites its row, or the nightly's draft promotion PR
112
+ (`bot/lsp-idle-evict-promote`, #3989: two consecutive eligible nights, idle
113
+ RSS floor, cold-start cap, hold list in
114
+ `scripts/lib/lsp-idle-eviction-promote.mjs`, derived from the registry test's
115
+ `HOLD_INDEXER_IDS` class; the PR also moves the id into
116
+ the registry test's `TRANSPARENT_IDS`; night memory in the matrix doc's
117
+ refresh-state block; never auto-merged, never demotes). `tests/config/lsp-idle-eviction-measurement.test.ts`
118
+ fails when a registry server can go unmeasured without an admission or when
119
+ the committed measurement vetoes a server declared `transparent`.
120
+ - The compiled registry holds the CATALOG ENTRY for every built-in with no
121
+ command override (`compileLspRegistry`), so the object the client registry
122
+ keeps (`SpawnedServer.info`) is the object `LSP_SERVERS`/`getServerById`
123
+ exposes; an overridden server keeps its own copy so its `spawn` and trust
124
+ admission never reach the catalog. A copy here is not a safe container: it is
125
+ a second registry whose entries swallow every arm a caller applies to the
126
+ first (history: `HISTORY.md`, 2026-10-19).
127
+ `tests/clients/lsp/lsp-registry-trust.test.ts` pins both directions;
128
+ `scheduleIdleEviction` records `lsp-idle-eviction-declined` once per server
129
+ per session when it arms no timer.
130
+ - The server-role vocabulary and the declared trait table have one owner,
131
+ `clients/lsp/server-traits.ts` (#1488, #1756 stage 1). Ask `isAuxiliary`,
132
+ never a comparison against the role literal, and read `notifyInflightLimit`
133
+ or `replyOrdering` through `serverTraits`, never by re-deriving a default;
134
+ `LspServerRole` is declared there and nowhere else, so a second
135
+ `"primary" | "auxiliary"` is a re-fork. `LSPServerInfo.role` is
136
+ non-optional: a row declares it, or the factory and custom-server builders
137
+ apply `DEFAULT_LSP_SERVER_ROLE`. Measured-behaviour markers (`silentOnClean`
138
+ and the census siblings named by `STRATEGY_TABLE_TRAITS`) stay on
139
+ `wait-policy/strategies.ts`, which their probes and expiry tests own; the two
140
+ tables stay disjoint. The auxiliary lifecycle and wait policy lives in
141
+ `clients/lsp/auxiliary-lifecycle.ts`, the diagnostic policy in
142
+ `clients/dispatch/auxiliary-lsp.ts`. Enforced by
143
+ `tests/config/lsp-role-predicate-sweep.test.ts` (production and `scripts/`
144
+ trees at zero inlined predicates) and
145
+ `tests/config/lsp-server-trait-table.test.ts` (registered-or-fail).
146
+ - Which auxiliaries the operator's configuration switches off (a kill switch
147
+ such as `--no-opengrep` / `opengrep.enabled=false`) has one owner,
148
+ `configDisabledAuxiliaryLspServerIds` in `clients/dispatch/auxiliary-lsp.ts`.
149
+ The explicit `lsp_diagnostics` probe and `lsp_navigation workspaceDiagnostics`
150
+ pass that set as `excludeServerIds` to both the touch and `getDiagnostics`,
151
+ through the flag resolver each host injects; the session's resource degrade
152
+ is not part of it. The probe's batch cache key comes from
153
+ `buildProbeScopeKey`, never equal to the workspace sweep's key, because the
154
+ sweep records before `pi-lens-ignore` and the probe after it.
155
+ - Every diagnostics entry route starts the same server set and gives the same
156
+ confirmation verdict under each server-selecting switch (`--no-opengrep`,
157
+ `opengrep.enabled=false`, a disabled or missing primary). Enforced by
158
+ `tests/tools/diagnostics-route-switch-matrix.test.ts`, which derives the
159
+ routes from every production access to an `LSPService` diagnostics member
160
+ and fails closed on an access it cannot classify, so a new read joins the
161
+ matrix or carries a reasoned exemption keyed by its `clientScope` and
162
+ `diagnostics` options. Each cell asserts the exact lines the route shows.
163
+ - A file no primary answered for is unconfirmed, never clean, whether the
164
+ primary could not start, was still starting, or is in `lsp.disabledServers`.
165
+ The one rule is `unansweredPrimaries` (clients/lsp/index.ts), which names
166
+ the disabled ones through `disabledPrimaries`
167
+ (clients/lsp/session-roots.ts, not `config.js`, whose import surface the
168
+ test mocks mirror). A `fallbackFor` alternate standing in for a disabled
169
+ owner keeps the denial as the cause when it cannot answer either; the
170
+ cascade names such a server once per session, not per neighbour.
171
+ Every route words the cause through `primaryUnavailableCause` and
172
+ `PRIMARY_UNAVAILABLE_CAUSE` (clients/lsp/diagnostic-binding.ts), never its
173
+ own sentence. A later write of such a file prints a one-line unconfirmed
174
+ status naming the cause, never the clean line.
175
+ - LSP roots never exceed the session-cwd ceiling. Root/config discovery uses
176
+ shared marker seams. Child cwd resolution uses `resolveToolCwd` and its
177
+ caller-specific markers.
178
+ - Temporary roots (#1129) are classified once per process by
179
+ `clients/ephemeral-root.ts`, on real paths on both sides. A directory inside
180
+ a real git checkout below `os.tmpdir()` (root or subdirectory) is a normal
181
+ LSP root with the ephemeral idle window, and `getProjectDataDir` gives it
182
+ its usual slug under `<base>/.ephemeral/<pid>-<8 hex>/`: normal within the
183
+ process, never read by another one, removed by the exit hook and, for a
184
+ dead pid, by the session-start sweep. A `pi-agent-*` path below the tmpdir
185
+ that no checkout owns is declined at `resolveLspServerCwd` with one
186
+ `lsp-root-declined` record per staging root per session.
187
+ - Per-path LSP notifications serialize read/build/send/record work. Pull
188
+ cancellation blocks a same-path replacement until settlement. Waits are
189
+ deadline- and abort-bounded, and silence is never clean.
190
+ - Document line addressing has one owner, `clients/lsp/content-scan.ts`: the
191
+ `\n` count behind the `lsp_document_send` record's `contentLineCount` and the
192
+ LSP sync bound (`countLfNewlines`), the last LSP-addressable line an
193
+ Incremental change spans, and one line's text (`lineTextAt`, which the
194
+ diagnostic-conversion call sites read) all come from it. The rule it owns is
195
+ the count and the one-line read: no other module may `split("\n")` document
196
+ content to obtain a line count or a single line — a send, a bound check, and
197
+ a line read ask this owner. A module that needs the whole line array (a
198
+ multi-line table, a per-line scan of its own document) keeps its `split`; the
199
+ array is the value it consumes, never a way to count or to reach one line.
200
+ - `touchFile` fires a type-2 watched-file announcement at entry for the first
201
+ seen content hash of a path, before the owner's didChange; it reaches every
202
+ other live client of the same server across package roots through the client
203
+ watch queue. Content hashes are session-scoped and bounded (#4156).
204
+ - A capability the client advertises has a sender, or the advertisement states
205
+ why it has none. `textDocument/didSave` follows a landed didOpen/didChange
206
+ only when the server declared `textDocumentSync.save` and the caller declared
207
+ the touch a save — the post-write sync, the explicit `lsp_diagnostics` query
208
+ and the MCP analysis's first touch (`analyzeFile`, the MCP hosts' post-write
209
+ route), never a sweep warm-up, cascade or sweep touch. The touch debounce
210
+ reads one rule: skip only when the bytes the server will hold once the path's
211
+ notify queue drains are this touch's content. The evidence is the client's
212
+ own sent-content record (`getSentContent`) AND `hasNotifyInFlight`, because
213
+ that record reports what landed and a send still running lands after a skip.
214
+ `hasNotifyInFlight` counts a content send only: a save-only send
215
+ (`sendDidSaveForHeldDocument`) cannot change the bytes or remove the document,
216
+ so it leaves the record final, while a didClose always counts. A client that
217
+ cannot answer either question is pushed, never skipped: the elapsed window
218
+ that used to decide there is gone (`formal/lsp-server-content`
219
+ `GateWindowReopen` is why). Its key is (path, server): the client scope never
220
+ re-pushes bytes a server holds. The debounce never drops a save: a saved touch
221
+ whose push it skipped sends the save alone (`notify.save`), and the save mark
222
+ names the content a `didSave` LANDED for, owned by the client's document
223
+ record and written only by the send continuation. Every rebuild of that
224
+ record carries the mark with the rest of the binding: Incremental's
225
+ text-budget eviction strips the payload, never the save evidence. A failed
226
+ carried save leaves the save owed; a failed standalone save gets one bounded
227
+ retry (`GateSaveRetry`, `MutGateSaveNoRetry`) and a retry that lands for
228
+ other bytes cannot suppress the save the next saved touch owes.
229
+
230
+ - Every server-produced `WorkspaceEdit` a path applies is bound to the bytes the
231
+ server computed it from. Both rename flows take the request instant before
232
+ they ask (`rename` right before `lspService.rename`, `renameFile` right before
233
+ `workspace/willRenameFiles`) and pass `captureRenameExpectedContent`'s map as
234
+ `expectedContent`; `clients/lsp/edits.ts` compares every bound file inside
235
+ pi's mutation queue before its first write, refuses the whole edit, and
236
+ records one `lsp-edit-stale-content` row naming the file. `renameFile` has no
237
+ target (nothing read the old path), so an unopened file there is best effort
238
+ by mtime, the same remainder the `rename` path carries. The evidence a file
239
+ is compared against the sent-content records of every client that
240
+ contributed a kept edit for that file, keyed by the registry client key; a
241
+ merged edit never falls back to a different client's priority record. The
242
+ records bind the file only when every contributor holds one; a contributor
243
+ with none leaves the file on the mtime rule, and the refusal names it. One
244
+ client's failed `willRenameFiles` never discards another client's answer,
245
+ of the same server id or not. `documentVersions` is
246
+ the other binding axis, for a server-initiated `workspace/applyEdit`. A new
247
+ apply site binds the content or states why it cannot.
248
+ - `touchFile` freezes content-bound auxiliary coverage at merge time. A later
249
+ publication cannot undo a finding drop. Auxiliary gaps narrow coverage and
250
+ never turn a primary answer inconclusive. When a primary touch is
251
+ inconclusive but the merged result contains answered diagnostics, dispatch
252
+ preserves only diagnostics from content-confirmed contributors and carries
253
+ the named primary gap as unconfirmed; only an empty inconclusive result is
254
+ skipped (#4219, #4231). Auxiliaries never confirm a file alone: a touch that
255
+ acquired auxiliaries but no primary that rooted for the file is inconclusive
256
+ with `primary-unavailable`, naming those primaries, and `getDiagnostics`
257
+ records the same ids as `unavailablePrimaryServerIds` (one rule,
258
+ `unansweredPrimaries`; an auxiliary-only language is unaffected).
259
+ - A server's `window/showMessage` is observed once per distinct text per
260
+ session (`lsp_server_message`), and an error-level message reporting that the
261
+ server's own config or rules failed to load records
262
+ `lsp-server-config-load-failed`. An AUXILIARY in that state never evaluated
263
+ the bytes it reports on, so its empty publications are refused as evidence
264
+ (`lsp_publish_dropped_server_config_failed`) and empty answers already stored
265
+ are retracted; a non-empty answer still flows, and a language-role server is
266
+ recorded but never gated. A refused publication still answers its send,
267
+ the server's own `semgrep/rulesRefreshed` clears the failure, and the
268
+ touch's `lsp-scanner-coverage-gap` reason carries the failure text. It
269
+ composes with the hold of the empty publish before the rules load (table:
270
+ `tests/clients/lsp/opengrep-pre-rules-publish-4763.test.ts`). Proven by
271
+ `tests/clients/lsp/opengrep-offline-config-failure.test.ts`. The same gate
272
+ (`auxiliaryEmptyIsNotEvidence`) refuses an auxiliary's UNVERSIONED empty
273
+ publication that lands in the phase of the path's stored or pending finding:
274
+ one rules generation (`semgrep/rulesRefreshed` count) and one client send.
275
+ Opengrep's open-documents scan publishes `[]` for files it did not target, so
276
+ that empty is no scan; a new send or a rules refresh clears as before, and a
277
+ versioned or language-server publication keeps last write wins
278
+ (`lsp-auxiliary-empty-after-finding`).
279
+ - The explicit `lsp_diagnostics` read checks `exceedsLspSyncLimits` once before
280
+ warm attachment or `touchFile`; an over-bound file returns a `too_large`
281
+ result with its byte/line measurement and records
282
+ `lsp-diagnostics-file-too-large` once per file per session.
283
+ - Every new LSP server has a smoke fixture or a documented alternate/toolchain
284
+ exemption. Real LSP-spawn tests belong in the serialized `lsp-spawn-heavy`
285
+ lane.
286
+ - A `fallbackFor` family is one primary for workspace grouping: a selected
287
+ preferred server and its sequential alternate do not disable the workspace-
288
+ pull fast path merely because both registry members match the file. Measure
289
+ the alternate independently; do not attribute the preferred server's
290
+ capabilities or diagnostics to it (#3939).
291
+
292
+ </important>
@@ -0,0 +1,59 @@
1
+ <important if="touching paths, data, and operating systems rules">
2
+
3
+ ### Paths, data, and operating systems
4
+
5
+ - Use `PathKeyedMap` for path-keyed memory. Choose
6
+ `normalizeEphemeralMapKey` for process-local hot indexes and `normalizeMapKey`
7
+ for long-lived shared state. Preserve original display paths separately.
8
+ - Resolve a path's identity once, where it enters (a tool argument, a write
9
+ event, `createDispatchContext`, `FormatService`), and hand it down. The
10
+ widget, delta-baseline and finding stores key a path that is already an
11
+ identity: they keep the syntactic key and resolve nothing per write
12
+ (maintainer decision 2026-10-24; shape 1). A walk or key derived from a caller
13
+ spelling instead answers for the link's project, not the file's.
14
+ - A path a host tool was given resolves through `resolveHostToolPath` (the
15
+ base expansion) or `resolveToolCallFilePath` (base plus pi's variant
16
+ ladder), never a bare `path.resolve(base, raw)`; see shape 74.
17
+ - Windows-shaped paths use `path.win32` functions. Use `toPosix`,
18
+ `splitPathSegments`, `isUnderDir`, `isSameOrWithin`, and
19
+ `isAtOrAboveHomeDir` instead of inline separator or containment logic.
20
+ - Data and log locations follow **Data directories and logs**; never hardcode
21
+ `.pi-lens` paths in writes or user-facing text.
22
+ - Probes and child processes pin `PI_LENS_HOME`, `PILENS_DATA_DIR`, `HOME`, and
23
+ install/log/cache directories to `.probe-home` under the worktree; never the
24
+ maintainer's real home, and never via `TMPDIR`/`TMP`/`TEMP`, which moves the
25
+ vitest harness home into the checkout (#3026).
26
+ - Scratch checkouts and `mktemp -d` never land under `/tmp` (tmpfs; #3526). Use
27
+ `~/.local/share/pi-lens-orchestrator/tmp/<lane>` for orchestrator and
28
+ reviewer scratch, `<worktree>/../probes-<pr>` for probes, and
29
+ `.claude/worktrees/` for a fixer's own worktree.
30
+ - Vitest also pins `HOME`, `USERPROFILE`, `XDG_CONFIG_HOME`, `XDG_CACHE_HOME`
31
+ and `XDG_DATA_HOME` per worker, to a scratch directory under
32
+ `pi-lens-scratch`, so `os.homedir()` and every child a test spawns
33
+ resolve inside it. A test that sets `HOME` itself (`pinFixtureHome`) wins. The
34
+ real home stays reachable only as `REAL_HOME` from `tests/support/vitest-setup.ts`
35
+ (or `os.userInfo()`), and a file that spells either is a named row in
36
+ `tests/support/real-home-readers.ts` with a `// real-home: <reason>` header.
37
+ The managed bin directory refuses to resolve outside a pinned `PI_LENS_HOME`
38
+ (`assertManagedBinDirInsidePinnedHome`, `clients/installer/index.ts`).
39
+ - Vitest gives every worker its own `PI_LENS_HOME`, `<run-shared home>/worker-home-<run>-<pid>`
40
+ (#3721); log sinks bind their path at module load, so a `PI_LENS_HOME` assigned
41
+ in `beforeEach`/an `it` body moves nothing. A test process never truncates a log
42
+ under the real `~/.pi-lens` (`isTestProcessTargetingRealHome`); the first refusal
43
+ emits one `process.emitWarning` (visible on stderr) and folds a
44
+ `log-sink-truncate-refused` row into `pilens_health`. `vitest-setup.ts` also pins the orphan-backstop
45
+ directory through `resolveBackstopStateDir` (#3083) when the home IS the
46
+ run-shared one. Explicit per-case homes remain authoritative. Never bypass this
47
+ seam for its lock or stamp.
48
+ - Test tmp roots are swept by the worker that made them (#2912):
49
+ `tests/support/vitest-setup.ts` removes every `setupTestEnvironment` root at
50
+ `afterAll` and on SIGTERM; any other straggler reds its owner, so do not widen
51
+ the sweep. Registry: `tests/support/tmp-root-registry.ts`.
52
+ - Two vitest invocations may share one `TMPDIR`. An invocation judges and
53
+ sweeps only tmp entries owned by files its own workers loaded (#3314), so a
54
+ tmp fixture names its family in the prefix at its own `mkdtempSync` or
55
+ `setupTestEnvironment` call (#3306).
56
+ - New filesystem walkers use shared exclusions and ignore matching, cap
57
+ walk-down work, and use the correct home-ceiling policy for walk-up discovery.
58
+
59
+ </important>
@@ -0,0 +1,114 @@
1
+ <important if="touching session, telemetry, and delivery rules">
2
+
3
+ ### Session, telemetry, and delivery
4
+
5
+ - Registry root ownership (#3849): each holder's record in a pid entry's
6
+ `projectRootHolders` lists exactly the roots THAT holder registered (`host`
7
+ for `registerInstance`, a per-activation id for a declined secondary). Only
8
+ its own `deregisterInstanceRoot`, whole-entry removal, or cap eviction ends
9
+ a record; a root stays while any record lists it. No anonymous counts; one
10
+ settle (`settleRootHolders`) for every writer; `getInstanceRoots` reads.
11
+ - Session state is owned by the stable session identity and activation owner.
12
+ Detached callbacks resolve live emitters at delivery time and pair them with
13
+ their own activation context. Never use a process-global latest session.
14
+ - Process-global bridge dependencies and the quiet-window turn-summary holder
15
+ bind only from a live primary `SessionScope`; `clients/process-bridge.ts`
16
+ accepts only a strictly newer scope ticket, so a concurrent secondary or
17
+ stale activation cannot rebind a held bridge/task to its runtime (#4258).
18
+ - Session degradation uses the ledger's bounded once/count APIs and resets at
19
+ the correct primary session boundary. `SessionStartClassification`
20
+ (`clients/session-lifecycle.ts`): `primary` and `sequential-replacement`
21
+ (resume and reload) both run the full start and reset; only
22
+ `concurrent-secondary` skips the reset, since a subagent reset tears down the
23
+ primary's warm state. `secondary` belongs to the shutdown classification. A process-lifetime latch cannot store a
24
+ session fact without an explicit reset.
25
+ - Turn state is the turn's session's (#3613): `RuntimeCoordinator.beginTurn`
26
+ takes the ctx's stable session id and moves the coordinator's counters,
27
+ write-order turn and change window only for its own session, and per-turn
28
+ warnings are partitioned by the session that recorded them. Every
29
+ producer and reader passes that id (`tool_result`, a partial apply's
30
+ pipeline, `turn_end`). The read guard is the turn's session's too (#4942,
31
+ the half of #3613 this paragraph used to leave open):
32
+ `RuntimeCoordinator.readGuardFor(sessionId)` answers with the coordinator's
33
+ own guard for a turn with no session id of its own, and with a guard of its
34
+ own, built on first use and dropped at its shutdown or at the coordinator's
35
+ own reset, for a concurrent secondary. It keys that guard by the opaque owner
36
+ the inline blockers use
37
+ (#4921, `recordSession`), so an edit is judged by the reads and writes of
38
+ the session that edits. The coordinator's own guard is the primary's only
39
+ while the ctx's stable session id equals the pinned telemetry id
40
+ (`setSessionLifecycle`); a start that cannot read its id would leave the
41
+ primary's turns on a foreign guard, where a primary `/tree` no longer
42
+ filters their reads (a hypothesis, reproduced only as a composite probe,
43
+ #4955 review F3).
44
+ A read or write reported through the mutation or
45
+ read bridge is credited to the coordinator's guard, even when the
46
+ mutation entry names a session (`BridgeMutationEntry.sessionId` routes
47
+ only the turn state and the change log, #4955 review F11). A concurrent
48
+ secondary still shares the turn-end worklist. State `turn_end` parks
49
+ in a scope cell for a later turn lives on the activation's own scope
50
+ (`TurnEndDeps.sessionScope`, passed by `index.ts`), never on
51
+ `runtime.sessionScope`, which is the primary's during a secondary's turn
52
+ (#4154: the late dead-code scan). A turn-end drain or write-back is fenced
53
+ by the scope that owns the store, taken at entry (#4161, #4168 round 3):
54
+ the coordinator's for the coordinator and module stores a secondary
55
+ shares, the activation's for its own scope cell. One store never answers
56
+ to two scopes, and a secondary's end fences only its cell.
57
+ - The project's one turn-end delivery slot (`turn-end-findings`'s
58
+ `content`) is addressed (#4943): the composer stamps `deliverTo` with its
59
+ turn's session, a commit-gate rewrite of the content leaves it out so the
60
+ record's owner (`sessionId`) is the addressee, and the `context` hook
61
+ consumes only a record addressed to its own session (the composer's id
62
+ expression); any other request leaves it untouched and writes one
63
+ `turn-end-delivery-addressed-elsewhere` ledger record per addressee. A
64
+ record with neither field goes to whoever asks. The sibling
65
+ `test-runner-findings` slot is read with the same id
66
+ (`deliveryEligible.sessionId`): a concurrent secondary never pins the
67
+ coordinator id. The MCP host stages to one address shared by every server
68
+ process (`MCP_DELIVERY_ADDRESS`) and reads as that address, with its
69
+ coordinator id, reassigned at each session start, for a record whose rewrite
70
+ left only the owner: a restarted server still delivers what the last one
71
+ staged, and neither its Stop pass nor its acknowledge takes a pi session's
72
+ message. The exception is a record a commit-gate rewrite replaced: it holds
73
+ only the owner id, so a server whose id was reassigned since (a restart, or
74
+ a later `pilens_session_start`) skips it and leaves it in place (accepted
75
+ residual, #4973).
76
+ A staged message another writer replaces before its owner asks is not
77
+ kept; the owner's next turn end composes its unresolved blockers again,
78
+ since the dedupe's last writer was the other session, but a one-shot
79
+ advisory is not composed again.
80
+ - Every session-scope hand-off decision leaves one `latency.log` row per
81
+ lifecycle event, never one per occurrence in a loop (#3873):
82
+ `session_handoff_slot`, `session_handoff_adopt`, `session_store_action`
83
+ (a store's `restore` returns its `StoreCarry`, items in and kept),
84
+ `session_scope_transition` (`end`, `demote`) and `session_end_fence_rollup`.
85
+ `docs/pi-lens-monitor.md` lists the fields; a new session store or hand-off
86
+ branch adds its row there in the same change.
87
+ - Logger writes use `createNdjsonLogger`; flush before reading a log. Redact at
88
+ the sink. New failure records preserve the discriminating file/tool/record
89
+ identity and retain dropped counts.
90
+ - `memory_sample` remains one bounded latency record. Its heap, external,
91
+ worker-isolate, tree-sitter, and word-index fields are latest-value or O(1)
92
+ reads; sampler assembly time is recorded in `samplerDurationMs`.
93
+ - Delivery surfaces are registered in `clients/finding-delivery-gate.ts`.
94
+ Every model-facing diagnostic, blocker, advisory, widget, nudge, and snapshot
95
+ either passes the shared freshness/disposition gate or carries an explicit
96
+ bounded age label.
97
+ - The dispatcher coverage notice (`buildCoverageNotice`) latches once per
98
+ session (`coverageNoticeSeen`) for the pi push surface; pull surfaces
99
+ (`pilens_analyze`, including its warm PostToolUse hook route) pass
100
+ `dedupeCoverageNotice: false` so every call carries the notice and the push
101
+ latch stays untouched (#3791). The warm hook deliberately repeats the notice
102
+ on every edit, matching its cold hook route. A primary off in
103
+ `lsp.disabledServers` gets one "disabled in config" note per server per
104
+ session instead of the per-file notice.
105
+ - `pilens:files:touched` publishers are `clients/pipeline.ts` and
106
+ `clients/runtime-agent-end.ts`; `clients/agent-nudge.ts` is the subscriber.
107
+ `clients/lsp-mutation.ts` has an optional callback but is not a publisher until
108
+ it is wired. Update `tests/config/files-touched-bus-conformance.test.ts` for
109
+ any publisher or subscriber change.
110
+ - Deferred work has a bounded queue, wall budget, abort path, carry-forward
111
+ identity, and honest partial/deferred delivery. It never publishes a false
112
+ clean result after cutting work.
113
+
114
+ </important>