@apralabs/apra-fleet 0.4.4 → 0.4.5

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 (268) hide show
  1. package/README.md +49 -4
  2. package/dist/agents/backlog-groomer.md +5 -0
  3. package/dist/agents/ci-watcher.md +5 -0
  4. package/dist/agents/deployer.md +20 -2
  5. package/dist/agents/doer.md +38 -2
  6. package/dist/agents/harvester.md +12 -9
  7. package/dist/agents/integ-test-runner.md +5 -0
  8. package/dist/agents/kb-reconciler.md +6 -0
  9. package/dist/agents/plan-reviewer.md +5 -0
  10. package/dist/agents/planner.md +5 -0
  11. package/dist/agents/regression-test-runner.md +5 -0
  12. package/dist/agents/reviewer.md +67 -15
  13. package/dist/agents/schemas/deployer-output.json +5 -0
  14. package/dist/agents/schemas/doer-output.json +78 -2
  15. package/dist/agents/schemas/reviewer-output.json +104 -2
  16. package/dist/cli/auth.js +5 -1
  17. package/dist/cli/beads-pin.js +6 -7
  18. package/dist/cli/claude-mod.d.ts +75 -0
  19. package/dist/cli/claude-mod.js +288 -0
  20. package/dist/cli/dolt-install.d.ts +1 -1
  21. package/dist/cli/dolt-install.js +5 -1
  22. package/dist/cli/fleet-se-guard.d.ts +8 -0
  23. package/dist/cli/fleet-se-guard.js +19 -3
  24. package/dist/cli/install-guard.d.ts +9 -0
  25. package/dist/cli/install-guard.js +24 -0
  26. package/dist/cli/install.d.ts +12 -0
  27. package/dist/cli/install.js +180 -20
  28. package/dist/cli/kb-profile.d.ts +16 -0
  29. package/dist/cli/kb-profile.js +81 -0
  30. package/dist/cli/start.js +3 -0
  31. package/dist/cli/uninstall.js +13 -3
  32. package/dist/cli/update.d.ts +4 -0
  33. package/dist/cli/update.js +19 -3
  34. package/dist/commands/kb-server.d.ts +10 -1
  35. package/dist/commands/kb-server.js +285 -11
  36. package/dist/index.js +22 -1
  37. package/dist/os/git-executable.d.ts +57 -0
  38. package/dist/os/git-executable.js +85 -0
  39. package/dist/os/go-concurrency.d.ts +44 -0
  40. package/dist/os/go-concurrency.js +53 -0
  41. package/dist/os/index.d.ts +1 -0
  42. package/dist/os/index.js +1 -0
  43. package/dist/os/linux.d.ts +2 -0
  44. package/dist/os/linux.js +10 -1
  45. package/dist/os/os-commands.d.ts +25 -0
  46. package/dist/os/os-commands.js +2 -0
  47. package/dist/os/windows-executable.d.ts +53 -0
  48. package/dist/os/windows-executable.js +185 -0
  49. package/dist/os/windows-gitbash.d.ts +23 -14
  50. package/dist/os/windows-gitbash.js +40 -16
  51. package/dist/os/windows.d.ts +2 -0
  52. package/dist/os/windows.js +37 -6
  53. package/dist/paths.d.ts +10 -1
  54. package/dist/paths.js +19 -2
  55. package/dist/services/agy-project.d.ts +7 -1
  56. package/dist/services/agy-project.js +7 -2
  57. package/dist/services/auth-socket.d.ts +18 -0
  58. package/dist/services/auth-socket.js +30 -4
  59. package/dist/services/credential-store.d.ts +33 -0
  60. package/dist/services/credential-store.js +79 -2
  61. package/dist/services/http-transport.d.ts +29 -0
  62. package/dist/services/http-transport.js +166 -37
  63. package/dist/services/kb-tool-profile.d.ts +36 -0
  64. package/dist/services/kb-tool-profile.js +88 -0
  65. package/dist/services/knowledge/bible-blob-id.js +10 -1
  66. package/dist/services/knowledge/bible-import.d.ts +108 -0
  67. package/dist/services/knowledge/bible-import.js +137 -4
  68. package/dist/services/knowledge/file-hash.js +6 -5
  69. package/dist/services/knowledge/http-provider.d.ts +303 -20
  70. package/dist/services/knowledge/http-provider.js +795 -125
  71. package/dist/services/knowledge/kb-config.d.ts +65 -1
  72. package/dist/services/knowledge/kb-config.js +143 -3
  73. package/dist/services/knowledge/kb-http-auth-state.d.ts +26 -0
  74. package/dist/services/knowledge/kb-http-auth-state.js +40 -0
  75. package/dist/services/knowledge/kb-providers.d.ts +9 -2
  76. package/dist/services/knowledge/kb-providers.js +67 -37
  77. package/dist/services/knowledge/kb-removed-scope-keys.js +1 -1
  78. package/dist/services/knowledge/kb-self.d.ts +122 -9
  79. package/dist/services/knowledge/kb-self.js +196 -36
  80. package/dist/services/knowledge/member-bible-view.js +16 -3
  81. package/dist/services/knowledge/path-validation.d.ts +7 -0
  82. package/dist/services/knowledge/path-validation.js +11 -0
  83. package/dist/services/knowledge/project-slug.js +3 -2
  84. package/dist/services/knowledge/repository-header.d.ts +77 -0
  85. package/dist/services/knowledge/repository-header.js +233 -0
  86. package/dist/services/knowledge/require-sqlite-project.d.ts +1 -1
  87. package/dist/services/knowledge/require-sqlite-project.js +1 -1
  88. package/dist/services/knowledge/sqlite-provider.d.ts +169 -0
  89. package/dist/services/knowledge/sqlite-provider.js +416 -4
  90. package/dist/services/knowledge/types.d.ts +15 -2
  91. package/dist/services/member-busy.d.ts +12 -0
  92. package/dist/services/member-busy.js +20 -0
  93. package/dist/services/member-config-io.d.ts +3 -2
  94. package/dist/services/member-config-io.js +7 -4
  95. package/dist/services/member-fleet-install.js +1 -0
  96. package/dist/services/member-tool-allowlist.d.ts +1 -1
  97. package/dist/services/member-tool-allowlist.js +8 -4
  98. package/dist/services/port-holder.js +2 -1
  99. package/dist/services/service-manager/types.d.ts +17 -1
  100. package/dist/services/service-manager/windows.d.ts +7 -2
  101. package/dist/services/service-manager/windows.js +28 -11
  102. package/dist/services/service-notice.d.ts +7 -0
  103. package/dist/services/service-notice.js +19 -0
  104. package/dist/services/session-registry.d.ts +13 -0
  105. package/dist/services/session-registry.js +13 -0
  106. package/dist/services/session-roots.d.ts +67 -0
  107. package/dist/services/session-roots.js +126 -0
  108. package/dist/services/statusline.d.ts +21 -0
  109. package/dist/services/statusline.js +97 -1
  110. package/dist/services/supervisor-service-cleanup.js +2 -1
  111. package/dist/services/tool-registry.js +108 -20
  112. package/dist/services/tool-scope.d.ts +34 -1
  113. package/dist/services/tool-scope.js +27 -2
  114. package/dist/services/vcs/azure-devops.js +10 -0
  115. package/dist/services/vcs/bitbucket.d.ts +22 -1
  116. package/dist/services/vcs/bitbucket.js +163 -17
  117. package/dist/services/vcs/types.d.ts +25 -2
  118. package/dist/services/watch/project-resolver.js +2 -1
  119. package/dist/skills/pm/cost.md +5 -1
  120. package/dist/skills/pm/index.md +9 -9
  121. package/dist/skills/pm/sprint.md +2 -1
  122. package/dist/tools/check-status.d.ts +51 -0
  123. package/dist/tools/check-status.js +124 -12
  124. package/dist/tools/code-intelligence-freshness.js +1 -1
  125. package/dist/tools/code-intelligence-gitnexus.d.ts +19 -0
  126. package/dist/tools/code-intelligence-gitnexus.js +166 -9
  127. package/dist/tools/code-intelligence-readiness.d.ts +58 -1
  128. package/dist/tools/code-intelligence-readiness.js +93 -8
  129. package/dist/tools/code-intelligence-reindex.d.ts +25 -1
  130. package/dist/tools/code-intelligence-reindex.js +76 -4
  131. package/dist/tools/code-intelligence.d.ts +1 -1
  132. package/dist/tools/code-intelligence.js +1 -1
  133. package/dist/tools/execute-command.js +14 -8
  134. package/dist/tools/execute-prompt.js +6 -2
  135. package/dist/tools/fleet-snapshot.d.ts +21 -0
  136. package/dist/tools/fleet-snapshot.js +78 -0
  137. package/dist/tools/kb-bible-commit.d.ts +25 -11
  138. package/dist/tools/kb-bible-commit.js +142 -33
  139. package/dist/tools/kb-capture.d.ts +2 -2
  140. package/dist/tools/kb-context.js +47 -27
  141. package/dist/tools/kb-demote.d.ts +27 -0
  142. package/dist/tools/kb-demote.js +37 -0
  143. package/dist/tools/kb-export.d.ts +35 -3
  144. package/dist/tools/kb-export.js +56 -13
  145. package/dist/tools/kb-feedback.d.ts +2 -0
  146. package/dist/tools/kb-feedback.js +17 -7
  147. package/dist/tools/kb-harvest.js +28 -9
  148. package/dist/tools/kb-import.d.ts +18 -2
  149. package/dist/tools/kb-import.js +24 -9
  150. package/dist/tools/kb-invalidate.d.ts +11 -3
  151. package/dist/tools/kb-invalidate.js +80 -7
  152. package/dist/tools/kb-list.js +38 -10
  153. package/dist/tools/kb-promote.js +6 -4
  154. package/dist/tools/kb-query.d.ts +3 -0
  155. package/dist/tools/kb-query.js +181 -37
  156. package/dist/tools/kb-session-prime.d.ts +4 -4
  157. package/dist/tools/kb-session-prime.js +89 -9
  158. package/dist/tools/kb-setup.d.ts +20 -0
  159. package/dist/tools/kb-setup.js +149 -11
  160. package/dist/tools/list-members.js +1 -1
  161. package/dist/tools/member-detail.js +7 -3
  162. package/dist/tools/provision-vcs-auth.d.ts +28 -3
  163. package/dist/tools/provision-vcs-auth.js +53 -7
  164. package/dist/tools/receive-files.js +7 -4
  165. package/dist/tools/send-files.js +5 -4
  166. package/dist/tools/send-message.d.ts +3 -0
  167. package/dist/tools/send-message.js +15 -2
  168. package/dist/tools/stop-prompt.js +3 -1
  169. package/dist/tools/vcs-credential-exec.d.ts +45 -3
  170. package/dist/tools/vcs-credential-exec.js +90 -11
  171. package/dist/utils/process-utils.js +5 -1
  172. package/dist/utils/redact-known-secrets.d.ts +17 -0
  173. package/dist/utils/redact-known-secrets.js +70 -0
  174. package/dist/utils/skill-matrix.js +1 -1
  175. package/dist/utils/vcs-provider-detect.js +2 -2
  176. package/dist/workflows/auto-sprint.js +245 -9
  177. package/package.json +10 -7
  178. package/packages/apra-fleet-client/package.json +1 -1
  179. package/packages/apra-fleet-client/src/client/api.mjs +172 -19
  180. package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +35 -2
  181. package/packages/apra-fleet-client/src/client/transport.mjs +6 -0
  182. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +5 -0
  183. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +5 -0
  184. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +20 -2
  185. package/packages/apra-fleet-se/apra-pm/agents/doer.md +38 -2
  186. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +12 -9
  187. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +5 -0
  188. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +6 -0
  189. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +5 -0
  190. package/packages/apra-fleet-se/apra-pm/agents/planner.md +5 -0
  191. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +5 -0
  192. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +67 -15
  193. package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +5 -0
  194. package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +78 -2
  195. package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +104 -2
  196. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +5 -1
  197. package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +9 -9
  198. package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +2 -1
  199. package/packages/apra-fleet-se/bin/cli.mjs +104 -31
  200. package/packages/apra-fleet-se/bin/serve.mjs +46 -8
  201. package/packages/apra-fleet-se/fleet-sprint/abort.mjs +184 -32
  202. package/packages/apra-fleet-se/fleet-sprint/bd-sync-command.mjs +69 -0
  203. package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +21 -0
  204. package/packages/apra-fleet-se/fleet-sprint/beads-lock-probe.mjs +176 -0
  205. package/packages/apra-fleet-se/fleet-sprint/beads-reachability.mjs +126 -0
  206. package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +158 -1
  207. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +82 -2
  208. package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +23 -6
  209. package/packages/apra-fleet-se/fleet-sprint/decision-notify.mjs +338 -0
  210. package/packages/apra-fleet-se/fleet-sprint/decision-wait.mjs +731 -0
  211. package/packages/apra-fleet-se/fleet-sprint/decisions.mjs +372 -0
  212. package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +44 -11
  213. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +4 -1
  214. package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +9 -3
  215. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +314 -19
  216. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +72 -4
  217. package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +7 -1
  218. package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +112 -1
  219. package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +36 -2
  220. package/packages/apra-fleet-se/fleet-sprint/kb.mjs +736 -101
  221. package/packages/apra-fleet-se/fleet-sprint/member-init-probe.mjs +1 -1
  222. package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +7 -1
  223. package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +49 -2
  224. package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +206 -3
  225. package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +61 -3
  226. package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +81 -31
  227. package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +7 -3
  228. package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +39 -14
  229. package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +17 -1
  230. package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +18 -3
  231. package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +14 -1
  232. package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +32 -5
  233. package/packages/apra-fleet-se/fleet-sprint/runner.js +824 -98
  234. package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +4 -2
  235. package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +54 -1
  236. package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +29 -2
  237. package/packages/apra-fleet-se/fleet-sprint/set-aside.mjs +288 -0
  238. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +3 -2
  239. package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +20 -0
  240. package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +21 -0
  241. package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +9 -0
  242. package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +605 -32
  243. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +811 -17
  244. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +89 -1
  245. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +225 -2
  246. package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +59 -3
  247. package/packages/apra-fleet-se/src/supervisor/api.mjs +148 -8
  248. package/packages/apra-fleet-se/src/supervisor/dashboard.mjs +6 -3
  249. package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +30 -10
  250. package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +17 -4
  251. package/packages/apra-fleet-se/src/supervisor/history.mjs +8 -1
  252. package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +92 -2
  253. package/packages/apra-fleet-se/src/supervisor/proxy.mjs +26 -1
  254. package/packages/apra-fleet-se/src/supervisor/server.mjs +151 -8
  255. package/packages/apra-fleet-se/src/supervisor/spawner.mjs +11 -9
  256. package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +7 -1
  257. package/packages/apra-fleet-workflow/package.json +2 -1
  258. package/packages/apra-fleet-workflow/src/viewer/index.mjs +86 -5
  259. package/packages/apra-fleet-workflow/src/viewer/request-guard.mjs +222 -0
  260. package/packages/apra-fleet-workflow/src/workflow/index.mjs +34 -2
  261. package/plugins/claude-code/fleet-status/.claude-plugin/plugin.json +7 -0
  262. package/plugins/claude-code/fleet-status/hooks/hooks.json +1 -0
  263. package/plugins/claude-code/fleet-status/hooks/register.tsx +906 -0
  264. package/plugins/claude-code/fleet-status/types/index.d.ts +88 -0
  265. package/skills/fleet/auth-bitbucket.md +47 -20
  266. package/skills/fleet/onboarding.md +1 -1
  267. package/skills/fleet/skill-matrix.md +3 -3
  268. package/version.json +1 -1
@@ -23,6 +23,96 @@ export class KbBibleError extends Error {
23
23
  this.remediation = `Fix or regenerate '${biblePath}' (kb_export writes it), or restore it from git.`;
24
24
  }
25
25
  }
26
+ /** The tombstone reason a kb_demote produces; the only one that demotes on import. */
27
+ export const TOMBSTONE_DEMOTED = 'demoted';
28
+ /**
29
+ * The tombstones of an already-parsed bible value, in id order and deduped
30
+ * (last wins). Only a v3 envelope may carry them: a legacy bare array or a v2
31
+ * envelope yields none, whatever it holds. Tolerant otherwise: the field is
32
+ * OPTIONAL, and a malformed tombstone is dropped individually rather than
33
+ * failing the whole bible -- exactly how a malformed ENTRY is treated by
34
+ * importBibleEntries below. kb-export.ts's reader calls this too.
35
+ *
36
+ * Each `at` is clamped to `now` (clampBibleTimeToNow): a future-dated tombstone
37
+ * would otherwise become a future demoted_at on import, and every later
38
+ * re-promotion would count as withdrawn against it.
39
+ */
40
+ export function extractBibleDemotions(parsed, now = new Date()) {
41
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
42
+ return [];
43
+ const doc = parsed;
44
+ if (doc.version !== 3 || !Array.isArray(doc.demotions))
45
+ return [];
46
+ const byId = new Map();
47
+ for (const candidate of doc.demotions) {
48
+ if (!candidate || typeof candidate !== 'object')
49
+ continue;
50
+ const r = candidate;
51
+ if (typeof r.id !== 'string' || r.id.length === 0)
52
+ continue;
53
+ if (typeof r.at !== 'string' || r.at.length === 0)
54
+ continue;
55
+ if (typeof r.reason !== 'string' || r.reason.length === 0)
56
+ continue;
57
+ byId.set(r.id, { id: r.id, at: clampBibleTimeToNow(r.at, now), reason: r.reason });
58
+ }
59
+ return Array.from(byId.values()).sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
60
+ }
61
+ /**
62
+ * A bible-carried updated_at, clamped to `now`. A future-dated entry would
63
+ * otherwise outrank every later tombstone under standingAgainstTombstone. An
64
+ * unparseable value is returned unchanged (the standing rule reports it as
65
+ * 'unknown').
66
+ */
67
+ export function clampBibleTimeToNow(time, now = new Date()) {
68
+ const parsed = Date.parse(time);
69
+ if (Number.isNaN(parsed) || parsed <= now.getTime())
70
+ return time;
71
+ return now.toISOString();
72
+ }
73
+ export function standingAgainstTombstone(trustTime, at) {
74
+ const tombstoneTime = Date.parse(at);
75
+ if (Number.isNaN(tombstoneTime))
76
+ return 'unknown';
77
+ if (trustTime === null)
78
+ return 'withdrawn';
79
+ const rowTime = Date.parse(trustTime);
80
+ if (Number.isNaN(rowTime))
81
+ return 'unknown';
82
+ return rowTime > tombstoneTime ? 'repromoted' : 'withdrawn';
83
+ }
84
+ /** The tombstoned ids of a parsed bible, as a set for membership tests. */
85
+ export function tombstonedIds(demotions) {
86
+ return new Set(demotions.map(d => d.id));
87
+ }
88
+ /**
89
+ * Drop every entry a tombstone names from a raw bible entry array.
90
+ *
91
+ * For the READ paths that build a view of the bible rather than merging it into
92
+ * an existing KB -- the member bible view, which imports into a FRESH empty
93
+ * in-memory provider. There is no local row there for a tombstone to demote, so
94
+ * the demotion can only be honoured by not listing the entry at all.
95
+ *
96
+ * Normally a committed bible holds no entry for a tombstoned id (kb_bible_commit
97
+ * removes it when it records the tombstone), so this is belt-and-braces against
98
+ * a hand-edited or partially merged bible -- the one place where "the file says
99
+ * both" must resolve to the demotion, because a view that lists a demoted entry
100
+ * is exactly the staleness the tombstone exists to stop.
101
+ *
102
+ * Entries too malformed to carry an id are left alone; importBibleEntries
103
+ * already tolerates and skips those.
104
+ */
105
+ export function excludeTombstonedEntries(entries, demotions) {
106
+ if (demotions.length === 0)
107
+ return entries;
108
+ const dropped = tombstonedIds(demotions);
109
+ return entries.filter(e => {
110
+ if (!e || typeof e !== 'object')
111
+ return true;
112
+ const id = e.id;
113
+ return typeof id !== 'string' || !dropped.has(id);
114
+ });
115
+ }
26
116
  /**
27
117
  * Read and parse a bible file into its raw entry array. Throws KbBibleError
28
118
  * when the file is not valid JSON or not a bible shape. `label` prefixes the
@@ -37,10 +127,18 @@ export class KbBibleError extends Error {
37
127
  * must never lag the writer.
38
128
  */
39
129
  export function readBibleEntries(biblePath, label) {
40
- return parseBibleText(fs.readFileSync(biblePath, 'utf-8'), biblePath, label);
130
+ return readBibleDocument(biblePath, label).entries;
41
131
  }
42
132
  /** Parse bible text already in memory (e.g. fetched from a remote member). */
43
133
  export function parseBibleText(raw, biblePath, label) {
134
+ return parseBibleDocument(raw, biblePath, label).entries;
135
+ }
136
+ /** Entries AND tombstones of a bible file. Same parse, same refusals. */
137
+ export function readBibleDocument(biblePath, label) {
138
+ return parseBibleDocument(fs.readFileSync(biblePath, 'utf-8'), biblePath, label);
139
+ }
140
+ /** Entries AND tombstones of bible text already in memory. */
141
+ export function parseBibleDocument(raw, biblePath, label) {
44
142
  if (raw.charCodeAt(0) === 0xfeff)
45
143
  raw = raw.slice(1);
46
144
  let parsed;
@@ -58,7 +156,8 @@ export function parseBibleText(raw, biblePath, label) {
58
156
  if (entries === null) {
59
157
  throw new KbBibleError(`${label}: bible file is not a JSON array of entries: ${biblePath}`, biblePath);
60
158
  }
61
- return entries;
159
+ // A legacy bare array carries no demotions field; extract returns [] for it.
160
+ return { entries, demotions: extractBibleDemotions(parsed) };
62
161
  }
63
162
  const VALID_TYPES = ['context-cache', 'learning', 'knowledge', 'runbook', 'user-directive'];
64
163
  const VALID_CONFIDENCE = ['CONFIRMED', 'INFERRED', 'UNVERIFIED'];
@@ -132,7 +231,23 @@ export async function importBibleEntries(provider, bibleEntries, options = {}) {
132
231
  let linked = 0;
133
232
  let flagged = 0;
134
233
  let rejected = 0;
135
- for (const candidate of bibleEntries) {
234
+ let demoted = 0;
235
+ // A bible that carries BOTH an entry and a tombstone for the same id is
236
+ // self-contradictory, and "the file says both" must resolve to the DEMOTION
237
+ // -- the same rule the member bible view applies (excludeTombstonedEntries is
238
+ // called at member-bible-view.ts buildView for the local and the remote path).
239
+ // Without this filter a tombstoned id with NO local row is CREATED by the
240
+ // entry loop below, because the tombstone loop never creates a row: the import
241
+ // would resurrect, as a fresh CONFIRMED row, exactly the entry the tombstone
242
+ // withdrew trust from. A freshly imported row's created_at is import time, not
243
+ // evidence that the id was re-promoted after the tombstone, so the tombstone
244
+ // loop cannot undo it either.
245
+ //
246
+ // For every bible kb_bible_commit actually writes this is a no-op: recording a
247
+ // tombstone removes the entry. It is belt-and-braces against a hand-edited or
248
+ // partially merged bible.
249
+ const importable = excludeTombstonedEntries(bibleEntries, options.demotions ?? []);
250
+ for (const candidate of importable) {
136
251
  // Malformed entry -> tolerate and skip individually.
137
252
  if (!isValidBibleEntry(candidate)) {
138
253
  skipped++;
@@ -183,6 +298,7 @@ export async function importBibleEntries(provider, bibleEntries, options = {}) {
183
298
  preferredId: entry.id,
184
299
  verbatim: options.verbatim === true,
185
300
  carriedBasis: carriedBasisOf(entry),
301
+ carriedUpdatedAt: typeof entry.updated_at === 'string' && entry.updated_at.length > 0 ? clampBibleTimeToNow(entry.updated_at) : undefined,
186
302
  }));
187
303
  }
188
304
  catch (err) {
@@ -206,6 +322,23 @@ export async function importBibleEntries(provider, bibleEntries, options = {}) {
206
322
  else if (audn_decision === 'flagged')
207
323
  flagged++;
208
324
  }
209
- return { imported, skipped, linked, flagged, rejected };
325
+ // TOMBSTONES, applied AFTER the entry loop. The entry loop can no longer have
326
+ // introduced a row for any id named here -- those entries were filtered out
327
+ // above -- so this loop only ever judges rows that ALREADY existed locally,
328
+ // which is the only population a tombstone is allowed to act on. The provider
329
+ // holds every rule -- never create, standingAgainstTombstone, no ownerTag
330
+ // check -- in applyBibleDemotion; this loop only counts what it changed.
331
+ // Only a 'demoted' tombstone lowers a row: another removal reason keeps the
332
+ // entry out of the bible without saying anything about this clone's trust.
333
+ //
334
+ // Note what is NOT here: nothing walks the local rows looking for ids missing
335
+ // from the bible. Only an id with an EXPLICIT tombstone is ever touched.
336
+ for (const tombstone of options.demotions ?? []) {
337
+ if (tombstone.reason !== TOMBSTONE_DEMOTED)
338
+ continue;
339
+ if (provider.applyBibleDemotion(tombstone.id, tombstone.at))
340
+ demoted++;
341
+ }
342
+ return { imported, skipped, linked, flagged, rejected, demoted };
210
343
  }
211
344
  //# sourceMappingURL=bible-import.js.map
@@ -3,6 +3,7 @@ import { createHash } from 'node:crypto';
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import { logWarn } from '../../utils/log-helpers.js';
6
+ import { gitExecutable } from '../../os/git-executable.js';
6
7
  // T3.1 (D4 fold-in, Phase 2 review MEDIUM yashr-d8b): computeFileHashBatch
7
8
  // gains an optional { cwd } anchor so a caller resolving a bible/basis against
8
9
  // a DIFFERENT repo root (e.g. kb_import's --repo) never needs to mutate the
@@ -31,7 +32,7 @@ export async function computeFileHash(filePath) {
31
32
  if (!fs.existsSync(filePath))
32
33
  return null;
33
34
  try {
34
- const { stdout } = await execFileAsync('git', ['hash-object', filePath]);
35
+ const { stdout } = await execFileAsync(gitExecutable(), ['hash-object', filePath]);
35
36
  const hash = stdout.trim();
36
37
  if (hash.length > 0) {
37
38
  return { hash, type: 'git' };
@@ -66,7 +67,7 @@ export async function computeFileHashBatch(filePaths, opts) {
66
67
  for (const chunk of chunkByArgvLength(existing, resolvePath)) {
67
68
  let gitSucceeded = false;
68
69
  try {
69
- const { stdout } = await execFileAsync('git', ['hash-object', ...chunk.map(resolvePath)], root ? { cwd: root } : undefined);
70
+ const { stdout } = await execFileAsync(gitExecutable(), ['hash-object', ...chunk.map(resolvePath)], root ? { cwd: root } : undefined);
70
71
  const lines = stdout.trim().split('\n');
71
72
  if (lines.length === chunk.length) {
72
73
  for (let i = 0; i < chunk.length; i++) {
@@ -170,7 +171,7 @@ export class KbHeadHashError extends Error {
170
171
  }
171
172
  function gitWithStdin(args, cwd, input) {
172
173
  return new Promise((resolve, reject) => {
173
- const child = spawn('git', args, { cwd, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
174
+ const child = spawn(gitExecutable(), args, { cwd, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
174
175
  const out = [];
175
176
  const err = [];
176
177
  child.stdout.on('data', (d) => out.push(d));
@@ -209,7 +210,7 @@ export async function computeHeadFileHashBatch(filePaths, opts) {
209
210
  // folder always fails loud rather than quietly admitting nothing.
210
211
  let prefix;
211
212
  try {
212
- const { stdout } = await execFileAsync('git', ['rev-parse', '--is-inside-work-tree', '--show-prefix'], { cwd });
213
+ const { stdout } = await execFileAsync(gitExecutable(), ['rev-parse', '--is-inside-work-tree', '--show-prefix'], { cwd });
213
214
  const lines = stdout.split('\n');
214
215
  if (lines[0].trim() !== 'true')
215
216
  throw new Error('not inside a work tree');
@@ -223,7 +224,7 @@ export async function computeHeadFileHashBatch(filePaths, opts) {
223
224
  for (const p of filePaths)
224
225
  result[p] = null;
225
226
  try {
226
- await execFileAsync('git', ['rev-parse', '--verify', '--quiet', 'HEAD^{commit}'], { cwd });
227
+ await execFileAsync(gitExecutable(), ['rev-parse', '--verify', '--quiet', 'HEAD^{commit}'], { cwd });
227
228
  }
228
229
  catch {
229
230
  return result; // unborn HEAD: nothing is committed, so nothing matches
@@ -1,39 +1,323 @@
1
- import { SqliteProvider } from './sqlite-provider.js';
1
+ import type { SqliteProvider } from './sqlite-provider.js';
2
2
  import type { MemoryProvider, KBEntry, KBEntryInput, QueryOptions, EntryTrustFilter, KBResult, FileContextResult, PrimeOptions, PrimedContext, SyncOptions, SyncResult, AudnDecision, Confidence, ProviderStats, DiscardResult, RetireOptions } from './types.js';
3
- type QueuedOperation = {
4
- op: 'capture';
5
- input: KBEntryInput;
6
- } | {
7
- op: 'invalidate';
8
- files: string[];
3
+ import { DEFAULT_REQUEST_TIMEOUT_MS } from './kb-config.js';
4
+ import { type RepositoryIdentity } from './repository-header.js';
5
+ export { DEFAULT_REQUEST_TIMEOUT_MS };
6
+ /**
7
+ * Optional settings for HttpKbProvider. An options object rather than more
8
+ * positional parameters, so new settings can be added without changing the
9
+ * constructor signature.
10
+ */
11
+ export interface HttpKbProviderOptions {
12
+ /** Socket idle timeout per request, in ms; absent means DEFAULT_REQUEST_TIMEOUT_MS. */
13
+ requestTimeoutMs?: number;
14
+ /**
15
+ * Project slug sent as the X-KB-Project header on every request, so a KB
16
+ * server serving a different project refuses with 409 instead of answering
17
+ * with that project's KB. Absent means no header is sent.
18
+ */
19
+ projectSlug?: string;
20
+ /**
21
+ * The repository every request is about, sent as the X-Repository,
22
+ * X-Repository-Commit and X-Repository-Branch headers. Filled only from
23
+ * fleet's resolved KB anchor (kb-providers.ts), never from tool input.
24
+ * Absent: none of these headers is sent.
25
+ */
26
+ repository?: RepositoryIdentity;
27
+ }
28
+ /**
29
+ * Where the bearer token comes from. A string is a literal token fixed for the
30
+ * provider's lifetime (the behaviour before named secrets). `{ secretName }`
31
+ * names a fleet secret that is looked up on EVERY request, so a secret updated
32
+ * outside fleet is used by the very next call with no restart.
33
+ */
34
+ export type KbHttpTokenSource = string | {
35
+ secretName: string;
9
36
  };
37
+ export type KbHttpAuthReason = 'missing' | 'expired' | 'rejected' | 'unreadable';
38
+ /**
39
+ * E-KB-HTTP-AUTH: the remote KB's token comes from a named fleet secret and
40
+ * that secret is missing, expired, unreadable, or was rejected by the server
41
+ * (HTTP 401) on the request and on one retry after re-reading it. The message
42
+ * names the secret and the reason, never the value. Nothing is queued: the
43
+ * caller decides whether to repeat the operation once the secret is fixed.
44
+ */
45
+ export declare class KbHttpAuthError extends Error {
46
+ readonly code: "E-KB-HTTP-AUTH";
47
+ readonly secretName: string;
48
+ readonly reason: KbHttpAuthReason;
49
+ readonly remediation: string;
50
+ /** The problem sentence, without the code prefix and remediation. */
51
+ readonly problem: string;
52
+ constructor(secretName: string, reason: KbHttpAuthReason, problem: string);
53
+ }
54
+ /**
55
+ * What HttpKbProvider.feedback returns: the remote server's response body as
56
+ * is. The client never invents confidence/stale fields.
57
+ */
58
+ export type HttpKbFeedbackResult = Record<string, unknown>;
59
+ /** Longest server error text carried into a tool result. */
60
+ export declare const MAX_ERROR_TEXT_CHARS = 300;
61
+ /**
62
+ * Server error text made safe for a tool result: markup stripped, whitespace
63
+ * collapsed, and capped at MAX_ERROR_TEXT_CHARS (a proxy or a crashed server
64
+ * can answer with a whole HTML page).
65
+ */
66
+ export declare function boundErrorText(text: string): string;
67
+ /** `url` with any user:password removed, for error text. */
68
+ export declare function redactUrlUserinfo(url: string): string;
69
+ /**
70
+ * E-KB-HTTP-UNREACHABLE: the KB server could not be reached (connection
71
+ * refused, DNS failure, timeout, reset), its capabilities read answered a
72
+ * 5xx or 429 (so the request itself was never sent), or the request itself
73
+ * was answered 429 or 503 (refused before it was handled). Over http the server is
74
+ * the only source of truth, so nothing is answered from a local store or the
75
+ * checkout bible instead. Nothing is queued: the error is retryable, and the
76
+ * caller decides whether to repeat the call (the sprint engine keeps its own
77
+ * KB write queued and repeats it on its next flush).
78
+ */
79
+ export declare class KbHttpUnreachableError extends Error {
80
+ readonly code: "E-KB-HTTP-UNREACHABLE";
81
+ /** The connection error text (e.g. "connect ECONNREFUSED ..."). */
82
+ readonly causeText: string;
83
+ constructor(serverUrl: string, operation: string, causeText: string);
84
+ }
85
+ /**
86
+ * E-KB-HTTP-SERVER-ERROR: the KB server (or a gateway in front of it) answered
87
+ * a request itself with a 5xx other than 503. For a write the request reached
88
+ * the server, so whether the write took effect is unknown (a 502 or 504 can
89
+ * follow a stored write). It is not retried and nothing is queued: repeating
90
+ * it blindly could apply it twice, and a server that always answers 500 would
91
+ * be retried forever. For a read nothing was read, and no local store or
92
+ * bible answers instead.
93
+ */
94
+ export declare class KbHttpServerError extends Error {
95
+ readonly code: "E-KB-HTTP-SERVER-ERROR";
96
+ constructor(serverUrl: string, operation: string, answer: string, kind?: 'write' | 'read');
97
+ }
98
+ /**
99
+ * Typed refusal for an operation the http KB provider does not support (and
100
+ * deliberately does not emulate through a local store).
101
+ */
102
+ export declare class KbHttpUnsupportedError extends Error {
103
+ readonly code = "E-KB-HTTP-UNSUPPORTED";
104
+ constructor(operation: string, outcome?: string, remediation?: string);
105
+ }
106
+ /**
107
+ * Typed refusal for a KB server that serves a different project than the one
108
+ * the request is for (HTTP 409). Never answered from a local store: the
109
+ * server is reachable, it is just the wrong one.
110
+ */
111
+ export declare class KbHttpProjectMismatchError extends Error {
112
+ readonly code = "E-KB-HTTP-PROJECT-MISMATCH";
113
+ constructor(serverUrl: string, serverProject: string, clientProject: string);
114
+ }
115
+ /** Routes every contract KB server serves. */
116
+ export declare const KB_REQUIRED_ROUTES: readonly ["capture", "query", "promote"];
117
+ /** Routes a contract KB server may leave out; it lists the ones it serves in its capabilities. */
118
+ export declare const KB_OPTIONAL_ROUTES: readonly ["context", "prime", "invalidate", "feedback", "list", "demote"];
119
+ export type KbRoute = typeof KB_REQUIRED_ROUTES[number] | typeof KB_OPTIONAL_ROUTES[number];
120
+ /** GET /api/kb/capabilities: what a KB server serves. */
121
+ export interface KbServerCapabilities {
122
+ /** Contract version the server implements, e.g. "v1". */
123
+ contract: string;
124
+ /** The routes it serves (route names, not paths). */
125
+ routes: KbRoute[];
126
+ /** True when the server keeps entries per branch (X-Repository-Branch decides what is true). */
127
+ branch_aware: boolean;
128
+ }
129
+ /**
130
+ * Assumed for a server that does not serve GET /api/kb/capabilities (404 or
131
+ * 501): the route set servers had before capabilities existed. demote is not
132
+ * in it.
133
+ */
134
+ export declare const KB_DEFAULT_CAPABILITIES: Readonly<KbServerCapabilities>;
135
+ /** kb_list options, shared with SqliteProvider.list so both halves of a split list take one shape. */
136
+ export type KbListOptions = Parameters<SqliteProvider['list']>[0];
137
+ /** Header carrying the project slug on every request (checked by kb-server). */
138
+ export declare const KB_PROJECT_HEADER = "X-KB-Project";
10
139
  export declare class HttpKbProvider implements MemoryProvider {
11
140
  private baseUrl;
12
- private readonly token;
13
- private readonly fallback;
14
- readonly offlineQueue: QueuedOperation[];
15
- private readonly beforeExitHandler;
16
- constructor(url: string, token: string, fallback?: SqliteProvider);
141
+ /** baseUrl with any user:password removed: the only form put in error text. */
142
+ private readonly displayUrl;
143
+ private readonly tokenSource;
144
+ private readonly projectSlug;
145
+ private readonly requestTimeoutMs;
146
+ private readonly repository;
147
+ /**
148
+ * The server's capabilities, read once per connection: cleared when a
149
+ * request finds the server unreachable, so the first request after a
150
+ * reconnect reads them again.
151
+ */
152
+ private capabilitiesRead;
153
+ constructor(url: string, token: KbHttpTokenSource, options?: HttpKbProviderOptions);
17
154
  dispose(): void;
18
- private enqueue;
155
+ private repositoryHeaders;
156
+ /**
157
+ * The token to send now. A literal is returned as is. A secret name is
158
+ * looked up (server-side lookup: allowedMembers does not apply, an expired
159
+ * record is reported and kept) and a missing/expired/unreadable secret
160
+ * raises E-KB-HTTP-AUTH before any request is sent.
161
+ */
162
+ private resolveToken;
163
+ /**
164
+ * One authenticated request. Literal token: exactly the old behaviour (a
165
+ * 401 is thrown as the plain HTTP_401 error, no retry). Secret name: the
166
+ * secret is looked up for this request; on 401 it is looked up once more
167
+ * and the request retried once; a second 401 raises E-KB-HTTP-AUTH.
168
+ * Records the last success / last 401 for fleet_status either way.
169
+ */
170
+ private request;
19
171
  private rawRequest;
20
- private tryFlushQueue;
172
+ /**
173
+ * GET /api/kb/capabilities, read once per connection (again after a
174
+ * reconnect). A server without the route is assumed to serve
175
+ * KB_DEFAULT_CAPABILITIES: it answers 404 or 501, or (a catch-all handler)
176
+ * a body carrying none of contract/routes/branch_aware. Auth,
177
+ * project-mismatch and connection errors are thrown as they are for any
178
+ * route; a body that carries some of those fields but not all, well typed,
179
+ * is E-KB-HTTP-UNSUPPORTED.
180
+ */
181
+ capabilities(): Promise<KbServerCapabilities>;
182
+ private readCapabilities;
183
+ /**
184
+ * A failed capabilities read as the typed error callers see. A 401 (literal
185
+ * token) and the already-typed errors pass through as on any route. Any
186
+ * other HTTP status is never a raw HTTP error: a 5xx or 429 (a restarting or
187
+ * rate-limiting server, a gateway with no backend) is E-KB-HTTP-UNREACHABLE
188
+ * naming the status (the caller's own request was never sent, so it is safe
189
+ * to retry); any other status (403/405 from a gateway) is
190
+ * E-KB-HTTP-UNSUPPORTED naming the capabilities read.
191
+ */
192
+ private capabilitiesHttpError;
193
+ /**
194
+ * E-KB-HTTP-UNREACHABLE for a 5xx or 429 answer to the capabilities read,
195
+ * or a 429 or 503 answer to `operation` itself: the server's state
196
+ * (restarting, rate limiting, a gateway with no backend), never the fault
197
+ * of the request.
198
+ */
199
+ private serverUnavailableError;
200
+ /** E-KB-HTTP-UNSUPPORTED naming `route`: the server does not serve it. */
201
+ private routeUnsupported;
202
+ /** Throws E-KB-HTTP-UNSUPPORTED naming `route` unless the server's capabilities list it. */
203
+ private requireRoute;
204
+ /** True when the server's capabilities list `route`. */
205
+ servesRoute(route: KbRoute): Promise<boolean>;
206
+ /**
207
+ * One request to a route: refused before sending when the server's
208
+ * capabilities do not list it. For an optional route a 404 or 501 also means
209
+ * "not served" and becomes E-KB-HTTP-UNSUPPORTED, never a raw HTTP error --
210
+ * except a 404 whose body code says the ENTRY is unknown (ENTRY_NOT_FOUND /
211
+ * E-ENTRY-NOT-FOUND), which is passed on for the caller to report.
212
+ */
213
+ private routeRequest;
21
214
  init(): Promise<void>;
215
+ /**
216
+ * One write request (capture, invalidate with files, feedback, promote,
217
+ * demote). Nothing is queued. Never a raw HTTP error:
218
+ * - a 429 or 503 answering the write is E-KB-HTTP-UNREACHABLE naming the
219
+ * status: the server refused it before handling it, so the caller may
220
+ * repeat it;
221
+ * - any other 5xx is E-KB-HTTP-SERVER-ERROR: the request reached the
222
+ * server, so whether it took effect is unknown and it must not be
223
+ * retried blindly;
224
+ * - a server that cannot be reached (or whose capabilities read answers
225
+ * 5xx/429, so the write is never sent) is E-KB-HTTP-UNREACHABLE, thrown
226
+ * as is for the caller to retry.
227
+ */
228
+ private writeRequest;
229
+ /**
230
+ * One read request (query, context, prime, list). A 5xx or 429 answering it
231
+ * is never a raw HTTP error: 429 and 503 are E-KB-HTTP-UNREACHABLE naming
232
+ * the status, any other 5xx is E-KB-HTTP-SERVER-ERROR naming the status.
233
+ * Nothing is answered from a local store or the bible instead.
234
+ */
235
+ private readRequest;
236
+ /** A 5xx or 429 answering `operation` as its typed error; any other error as is. */
237
+ private answeredError;
22
238
  capture(input: KBEntryInput): Promise<{
23
239
  id: string;
24
240
  audn_decision: AudnDecision;
25
241
  }>;
26
242
  query(opts: QueryOptions): Promise<KBResult>;
27
- context(files: string[], confidence?: Confidence[], excludeDisputed?: boolean): Promise<FileContextResult[]>;
243
+ context(files: string[], confidence?: Confidence[], excludeDisputed?: boolean, ownerTag?: string): Promise<FileContextResult[]>;
28
244
  discard(_ids: string[], _opts?: RetireOptions): Promise<DiscardResult>;
29
245
  invalidate(files: string[]): Promise<{
30
246
  invalidated: number;
31
247
  }>;
32
- getLinked(id: string): Promise<KBEntry[]>;
33
- touch(ids: string[]): Promise<number>;
34
- relatedClaims(ids: string[], limit?: number, filter?: EntryTrustFilter): Promise<KBEntry[]>;
248
+ /**
249
+ * kb_feedback over the remote KB: POST /api/kb/feedback with the
250
+ * memory-contract v1 kb_feedback request body {id, reason, role} (role
251
+ * carries the already-validated author). The server owns the entry, so the
252
+ * server decides stale/flagged; this method returns its response as is and
253
+ * never writes or invents confidence, and never touches a local store.
254
+ * Nothing is queued: an unreachable server or a 429/503 answer
255
+ * (E-KB-HTTP-UNREACHABLE), any other 5xx answer (E-KB-HTTP-SERVER-ERROR)
256
+ * or a refused token
257
+ * (E-KB-HTTP-AUTH) is thrown for the caller to handle.
258
+ */
259
+ feedback(id: string, reason: string, author: string): Promise<HttpKbFeedbackResult>;
260
+ getLinked(_id: string): Promise<KBEntry[]>;
261
+ touch(_ids: string[]): Promise<number>;
262
+ getLiveConfirmedState(_ids: string[]): Map<string, boolean>;
263
+ relatedClaims(_ids: string[], _limit?: number, _filter?: EntryTrustFilter): Promise<KBEntry[]>;
35
264
  prime(opts: PrimeOptions): Promise<PrimedContext>;
36
- promote(id: string, reason?: string): Promise<{
265
+ promote(id: string, reason?: string, opts?: {
266
+ ownerTag?: string;
267
+ }): Promise<{
268
+ id: string;
269
+ confidence_before: Confidence;
270
+ confidence_after: Confidence;
271
+ }>;
272
+ /**
273
+ * GET /api/kb/list, an optional route: a server that does not list it, or
274
+ * answers it 404/501, is E-KB-HTTP-UNSUPPORTED rather than a bare HTTP error.
275
+ */
276
+ private listRequest;
277
+ /**
278
+ * Every live entry the server holds with `ownerTag`, any tier. Reads the
279
+ * no-bump list route, so an ownership check is not counted as a retrieval.
280
+ * Asks the server to narrow on the tag and re-checks each entry, so a server
281
+ * that ignores the tag parameter cannot widen the result. Throws
282
+ * KbHttpUnsupportedError when the server returns entries without a tags
283
+ * array: ownership cannot be decided then.
284
+ */
285
+ private ownedEntries;
286
+ private ownedIds;
287
+ /**
288
+ * kb_list over the server's no-bump GET /api/kb/list route, with the same
289
+ * options as SqliteProvider.list. A MEMBER own-scope read (owner_tag) asks
290
+ * the server to narrow on that tag when the caller set no tag of its own,
291
+ * and is re-filtered on the entries' tags either way. Remote-only: the
292
+ * listing is not answered from a local store when the server is down.
293
+ */
294
+ list(opts: KbListOptions): Promise<KBEntry[]>;
295
+ /**
296
+ * Query results restricted to entries carrying ownerTag (and the caller's
297
+ * own tag filter, when it set one). Filtering happens after the server's
298
+ * limit, so a member can get fewer results than it asked for.
299
+ */
300
+ private keepOwned;
301
+ /**
302
+ * Context summaries carry only an entry id, so ownership is decided against
303
+ * the caller's own entry ids. A summary from another member's entry, or one
304
+ * with no entry id (ownership unknown), is reported as missing for that
305
+ * file, as the SQLite provider does when the caller has no entry for it.
306
+ */
307
+ private keepOwnedSummaries;
308
+ /**
309
+ * POST /api/kb/demote {id, reason, evidence_files}: an OPTIONAL route. Only
310
+ * sent when the server's capabilities list demote; otherwise (or on a 404 /
311
+ * 501 from the route) E-KB-HTTP-UNSUPPORTED naming the route, and nothing
312
+ * is changed. Like promote(), sent by id with no fleet-side tag check: the
313
+ * server enforces which ids the caller may demote (opts.ownerTag is not
314
+ * sent). An entry the server does not know is "Entry not found".
315
+ * The server validates evidence_files (spec 2.9.1); fleet checks first that
316
+ * each is repo-relative with no '..' segment and sends nothing otherwise.
317
+ */
318
+ demote(id: string, reason: string, evidenceFiles: string[], _opts?: {
319
+ ownerTag?: string;
320
+ }): Promise<{
37
321
  id: string;
38
322
  confidence_before: Confidence;
39
323
  confidence_after: Confidence;
@@ -43,5 +327,4 @@ export declare class HttpKbProvider implements MemoryProvider {
43
327
  symbols?: string[];
44
328
  }): Promise<ProviderStats>;
45
329
  }
46
- export {};
47
330
  //# sourceMappingURL=http-provider.d.ts.map