@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.
- package/README.md +49 -4
- package/dist/agents/backlog-groomer.md +5 -0
- package/dist/agents/ci-watcher.md +5 -0
- package/dist/agents/deployer.md +20 -2
- package/dist/agents/doer.md +38 -2
- package/dist/agents/harvester.md +12 -9
- package/dist/agents/integ-test-runner.md +5 -0
- package/dist/agents/kb-reconciler.md +6 -0
- package/dist/agents/plan-reviewer.md +5 -0
- package/dist/agents/planner.md +5 -0
- package/dist/agents/regression-test-runner.md +5 -0
- package/dist/agents/reviewer.md +67 -15
- package/dist/agents/schemas/deployer-output.json +5 -0
- package/dist/agents/schemas/doer-output.json +78 -2
- package/dist/agents/schemas/reviewer-output.json +104 -2
- package/dist/cli/auth.js +5 -1
- package/dist/cli/beads-pin.js +6 -7
- package/dist/cli/claude-mod.d.ts +75 -0
- package/dist/cli/claude-mod.js +288 -0
- package/dist/cli/dolt-install.d.ts +1 -1
- package/dist/cli/dolt-install.js +5 -1
- package/dist/cli/fleet-se-guard.d.ts +8 -0
- package/dist/cli/fleet-se-guard.js +19 -3
- package/dist/cli/install-guard.d.ts +9 -0
- package/dist/cli/install-guard.js +24 -0
- package/dist/cli/install.d.ts +12 -0
- package/dist/cli/install.js +180 -20
- package/dist/cli/kb-profile.d.ts +16 -0
- package/dist/cli/kb-profile.js +81 -0
- package/dist/cli/start.js +3 -0
- package/dist/cli/uninstall.js +13 -3
- package/dist/cli/update.d.ts +4 -0
- package/dist/cli/update.js +19 -3
- package/dist/commands/kb-server.d.ts +10 -1
- package/dist/commands/kb-server.js +285 -11
- package/dist/index.js +22 -1
- package/dist/os/git-executable.d.ts +57 -0
- package/dist/os/git-executable.js +85 -0
- package/dist/os/go-concurrency.d.ts +44 -0
- package/dist/os/go-concurrency.js +53 -0
- package/dist/os/index.d.ts +1 -0
- package/dist/os/index.js +1 -0
- package/dist/os/linux.d.ts +2 -0
- package/dist/os/linux.js +10 -1
- package/dist/os/os-commands.d.ts +25 -0
- package/dist/os/os-commands.js +2 -0
- package/dist/os/windows-executable.d.ts +53 -0
- package/dist/os/windows-executable.js +185 -0
- package/dist/os/windows-gitbash.d.ts +23 -14
- package/dist/os/windows-gitbash.js +40 -16
- package/dist/os/windows.d.ts +2 -0
- package/dist/os/windows.js +37 -6
- package/dist/paths.d.ts +10 -1
- package/dist/paths.js +19 -2
- package/dist/services/agy-project.d.ts +7 -1
- package/dist/services/agy-project.js +7 -2
- package/dist/services/auth-socket.d.ts +18 -0
- package/dist/services/auth-socket.js +30 -4
- package/dist/services/credential-store.d.ts +33 -0
- package/dist/services/credential-store.js +79 -2
- package/dist/services/http-transport.d.ts +29 -0
- package/dist/services/http-transport.js +166 -37
- package/dist/services/kb-tool-profile.d.ts +36 -0
- package/dist/services/kb-tool-profile.js +88 -0
- package/dist/services/knowledge/bible-blob-id.js +10 -1
- package/dist/services/knowledge/bible-import.d.ts +108 -0
- package/dist/services/knowledge/bible-import.js +137 -4
- package/dist/services/knowledge/file-hash.js +6 -5
- package/dist/services/knowledge/http-provider.d.ts +303 -20
- package/dist/services/knowledge/http-provider.js +795 -125
- package/dist/services/knowledge/kb-config.d.ts +65 -1
- package/dist/services/knowledge/kb-config.js +143 -3
- package/dist/services/knowledge/kb-http-auth-state.d.ts +26 -0
- package/dist/services/knowledge/kb-http-auth-state.js +40 -0
- package/dist/services/knowledge/kb-providers.d.ts +9 -2
- package/dist/services/knowledge/kb-providers.js +67 -37
- package/dist/services/knowledge/kb-removed-scope-keys.js +1 -1
- package/dist/services/knowledge/kb-self.d.ts +122 -9
- package/dist/services/knowledge/kb-self.js +196 -36
- package/dist/services/knowledge/member-bible-view.js +16 -3
- package/dist/services/knowledge/path-validation.d.ts +7 -0
- package/dist/services/knowledge/path-validation.js +11 -0
- package/dist/services/knowledge/project-slug.js +3 -2
- package/dist/services/knowledge/repository-header.d.ts +77 -0
- package/dist/services/knowledge/repository-header.js +233 -0
- package/dist/services/knowledge/require-sqlite-project.d.ts +1 -1
- package/dist/services/knowledge/require-sqlite-project.js +1 -1
- package/dist/services/knowledge/sqlite-provider.d.ts +169 -0
- package/dist/services/knowledge/sqlite-provider.js +416 -4
- package/dist/services/knowledge/types.d.ts +15 -2
- package/dist/services/member-busy.d.ts +12 -0
- package/dist/services/member-busy.js +20 -0
- package/dist/services/member-config-io.d.ts +3 -2
- package/dist/services/member-config-io.js +7 -4
- package/dist/services/member-fleet-install.js +1 -0
- package/dist/services/member-tool-allowlist.d.ts +1 -1
- package/dist/services/member-tool-allowlist.js +8 -4
- package/dist/services/port-holder.js +2 -1
- package/dist/services/service-manager/types.d.ts +17 -1
- package/dist/services/service-manager/windows.d.ts +7 -2
- package/dist/services/service-manager/windows.js +28 -11
- package/dist/services/service-notice.d.ts +7 -0
- package/dist/services/service-notice.js +19 -0
- package/dist/services/session-registry.d.ts +13 -0
- package/dist/services/session-registry.js +13 -0
- package/dist/services/session-roots.d.ts +67 -0
- package/dist/services/session-roots.js +126 -0
- package/dist/services/statusline.d.ts +21 -0
- package/dist/services/statusline.js +97 -1
- package/dist/services/supervisor-service-cleanup.js +2 -1
- package/dist/services/tool-registry.js +108 -20
- package/dist/services/tool-scope.d.ts +34 -1
- package/dist/services/tool-scope.js +27 -2
- package/dist/services/vcs/azure-devops.js +10 -0
- package/dist/services/vcs/bitbucket.d.ts +22 -1
- package/dist/services/vcs/bitbucket.js +163 -17
- package/dist/services/vcs/types.d.ts +25 -2
- package/dist/services/watch/project-resolver.js +2 -1
- package/dist/skills/pm/cost.md +5 -1
- package/dist/skills/pm/index.md +9 -9
- package/dist/skills/pm/sprint.md +2 -1
- package/dist/tools/check-status.d.ts +51 -0
- package/dist/tools/check-status.js +124 -12
- package/dist/tools/code-intelligence-freshness.js +1 -1
- package/dist/tools/code-intelligence-gitnexus.d.ts +19 -0
- package/dist/tools/code-intelligence-gitnexus.js +166 -9
- package/dist/tools/code-intelligence-readiness.d.ts +58 -1
- package/dist/tools/code-intelligence-readiness.js +93 -8
- package/dist/tools/code-intelligence-reindex.d.ts +25 -1
- package/dist/tools/code-intelligence-reindex.js +76 -4
- package/dist/tools/code-intelligence.d.ts +1 -1
- package/dist/tools/code-intelligence.js +1 -1
- package/dist/tools/execute-command.js +14 -8
- package/dist/tools/execute-prompt.js +6 -2
- package/dist/tools/fleet-snapshot.d.ts +21 -0
- package/dist/tools/fleet-snapshot.js +78 -0
- package/dist/tools/kb-bible-commit.d.ts +25 -11
- package/dist/tools/kb-bible-commit.js +142 -33
- package/dist/tools/kb-capture.d.ts +2 -2
- package/dist/tools/kb-context.js +47 -27
- package/dist/tools/kb-demote.d.ts +27 -0
- package/dist/tools/kb-demote.js +37 -0
- package/dist/tools/kb-export.d.ts +35 -3
- package/dist/tools/kb-export.js +56 -13
- package/dist/tools/kb-feedback.d.ts +2 -0
- package/dist/tools/kb-feedback.js +17 -7
- package/dist/tools/kb-harvest.js +28 -9
- package/dist/tools/kb-import.d.ts +18 -2
- package/dist/tools/kb-import.js +24 -9
- package/dist/tools/kb-invalidate.d.ts +11 -3
- package/dist/tools/kb-invalidate.js +80 -7
- package/dist/tools/kb-list.js +38 -10
- package/dist/tools/kb-promote.js +6 -4
- package/dist/tools/kb-query.d.ts +3 -0
- package/dist/tools/kb-query.js +181 -37
- package/dist/tools/kb-session-prime.d.ts +4 -4
- package/dist/tools/kb-session-prime.js +89 -9
- package/dist/tools/kb-setup.d.ts +20 -0
- package/dist/tools/kb-setup.js +149 -11
- package/dist/tools/list-members.js +1 -1
- package/dist/tools/member-detail.js +7 -3
- package/dist/tools/provision-vcs-auth.d.ts +28 -3
- package/dist/tools/provision-vcs-auth.js +53 -7
- package/dist/tools/receive-files.js +7 -4
- package/dist/tools/send-files.js +5 -4
- package/dist/tools/send-message.d.ts +3 -0
- package/dist/tools/send-message.js +15 -2
- package/dist/tools/stop-prompt.js +3 -1
- package/dist/tools/vcs-credential-exec.d.ts +45 -3
- package/dist/tools/vcs-credential-exec.js +90 -11
- package/dist/utils/process-utils.js +5 -1
- package/dist/utils/redact-known-secrets.d.ts +17 -0
- package/dist/utils/redact-known-secrets.js +70 -0
- package/dist/utils/skill-matrix.js +1 -1
- package/dist/utils/vcs-provider-detect.js +2 -2
- package/dist/workflows/auto-sprint.js +245 -9
- package/package.json +10 -7
- package/packages/apra-fleet-client/package.json +1 -1
- package/packages/apra-fleet-client/src/client/api.mjs +172 -19
- package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +35 -2
- package/packages/apra-fleet-client/src/client/transport.mjs +6 -0
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +20 -2
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +38 -2
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +12 -9
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +6 -0
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +67 -15
- package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +78 -2
- package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +104 -2
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +5 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +9 -9
- package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +2 -1
- package/packages/apra-fleet-se/bin/cli.mjs +104 -31
- package/packages/apra-fleet-se/bin/serve.mjs +46 -8
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +184 -32
- package/packages/apra-fleet-se/fleet-sprint/bd-sync-command.mjs +69 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +21 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-lock-probe.mjs +176 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-reachability.mjs +126 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +158 -1
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +82 -2
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +23 -6
- package/packages/apra-fleet-se/fleet-sprint/decision-notify.mjs +338 -0
- package/packages/apra-fleet-se/fleet-sprint/decision-wait.mjs +731 -0
- package/packages/apra-fleet-se/fleet-sprint/decisions.mjs +372 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +44 -11
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +4 -1
- package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +9 -3
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +314 -19
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +72 -4
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +7 -1
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +112 -1
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +36 -2
- package/packages/apra-fleet-se/fleet-sprint/kb.mjs +736 -101
- package/packages/apra-fleet-se/fleet-sprint/member-init-probe.mjs +1 -1
- package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +7 -1
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +49 -2
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +206 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +61 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +81 -31
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +7 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +39 -14
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +17 -1
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +18 -3
- package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +14 -1
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +32 -5
- package/packages/apra-fleet-se/fleet-sprint/runner.js +824 -98
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +4 -2
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +54 -1
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +29 -2
- package/packages/apra-fleet-se/fleet-sprint/set-aside.mjs +288 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +3 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +20 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +21 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +9 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +605 -32
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +811 -17
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +89 -1
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +225 -2
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +59 -3
- package/packages/apra-fleet-se/src/supervisor/api.mjs +148 -8
- package/packages/apra-fleet-se/src/supervisor/dashboard.mjs +6 -3
- package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +30 -10
- package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +17 -4
- package/packages/apra-fleet-se/src/supervisor/history.mjs +8 -1
- package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +92 -2
- package/packages/apra-fleet-se/src/supervisor/proxy.mjs +26 -1
- package/packages/apra-fleet-se/src/supervisor/server.mjs +151 -8
- package/packages/apra-fleet-se/src/supervisor/spawner.mjs +11 -9
- package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +7 -1
- package/packages/apra-fleet-workflow/package.json +2 -1
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +86 -5
- package/packages/apra-fleet-workflow/src/viewer/request-guard.mjs +222 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +34 -2
- package/plugins/claude-code/fleet-status/.claude-plugin/plugin.json +7 -0
- package/plugins/claude-code/fleet-status/hooks/hooks.json +1 -0
- package/plugins/claude-code/fleet-status/hooks/register.tsx +906 -0
- package/plugins/claude-code/fleet-status/types/index.d.ts +88 -0
- package/skills/fleet/auth-bitbucket.md +47 -20
- package/skills/fleet/onboarding.md +1 -1
- package/skills/fleet/skill-matrix.md +3 -3
- 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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
13
|
-
private readonly
|
|
14
|
-
readonly
|
|
15
|
-
private readonly
|
|
16
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
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
|