@askdkc/kiokuko 0.2.7 → 0.2.8
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.ja.md +9 -22
- package/README.ko.md +8 -22
- package/README.md +14 -23
- package/README.zh-CN.md +7 -20
- package/dist/akinator/agent-task.d.ts +2 -0
- package/dist/akinator/agent-task.d.ts.map +1 -1
- package/dist/akinator/agent-task.js +62 -26
- package/dist/akinator/agent-task.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +8 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +6 -3
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/embeddings.d.ts +7 -0
- package/dist/commands/embeddings.d.ts.map +1 -1
- package/dist/commands/embeddings.js +32 -1
- package/dist/commands/embeddings.js.map +1 -1
- package/dist/config/paths.d.ts +5 -0
- package/dist/config/paths.d.ts.map +1 -1
- package/dist/config/paths.js +34 -0
- package/dist/config/paths.js.map +1 -1
- package/dist/embedding/backend.d.ts +1 -1
- package/dist/embedding/backend.d.ts.map +1 -1
- package/dist/embedding/backend.js +20 -4
- package/dist/embedding/backend.js.map +1 -1
- package/dist/embedding/config.d.ts +3 -0
- package/dist/embedding/config.d.ts.map +1 -1
- package/dist/embedding/config.js +17 -0
- package/dist/embedding/config.js.map +1 -1
- package/dist/embedding/diagnostics.d.ts +1 -1
- package/dist/embedding/diagnostics.d.ts.map +1 -1
- package/dist/embedding/diagnostics.js +20 -5
- package/dist/embedding/diagnostics.js.map +1 -1
- package/dist/embedding/document.d.ts +5 -0
- package/dist/embedding/document.d.ts.map +1 -1
- package/dist/embedding/document.js +20 -0
- package/dist/embedding/document.js.map +1 -1
- package/dist/embedding/local-model-loader.d.ts +24 -0
- package/dist/embedding/local-model-loader.d.ts.map +1 -0
- package/dist/embedding/local-model-loader.js +64 -0
- package/dist/embedding/local-model-loader.js.map +1 -0
- package/dist/embedding/local-transformers-provider.d.ts +17 -0
- package/dist/embedding/local-transformers-provider.d.ts.map +1 -0
- package/dist/embedding/local-transformers-provider.js +54 -0
- package/dist/embedding/local-transformers-provider.js.map +1 -0
- package/dist/embedding/model-download.d.ts +32 -0
- package/dist/embedding/model-download.d.ts.map +1 -0
- package/dist/embedding/model-download.js +41 -0
- package/dist/embedding/model-download.js.map +1 -0
- package/dist/embedding/model-installation.d.ts +17 -0
- package/dist/embedding/model-installation.d.ts.map +1 -0
- package/dist/embedding/model-installation.js +71 -0
- package/dist/embedding/model-installation.js.map +1 -0
- package/dist/embedding/model-manifest.d.ts +18 -0
- package/dist/embedding/model-manifest.d.ts.map +1 -0
- package/dist/embedding/model-manifest.js +86 -0
- package/dist/embedding/model-manifest.js.map +1 -0
- package/dist/embedding/presets/local-small.d.ts +8 -0
- package/dist/embedding/presets/local-small.d.ts.map +1 -0
- package/dist/embedding/presets/local-small.js +67 -0
- package/dist/embedding/presets/local-small.js.map +1 -0
- package/dist/embedding/presets/manifest.d.ts +27 -0
- package/dist/embedding/presets/manifest.d.ts.map +1 -0
- package/dist/embedding/presets/manifest.js +5 -0
- package/dist/embedding/presets/manifest.js.map +1 -0
- package/dist/embedding/profile.d.ts +6 -2
- package/dist/embedding/profile.d.ts.map +1 -1
- package/dist/embedding/profile.js +36 -0
- package/dist/embedding/profile.js.map +1 -1
- package/dist/embedding/query-cache.d.ts +6 -0
- package/dist/embedding/query-cache.d.ts.map +1 -1
- package/dist/embedding/query-cache.js +21 -0
- package/dist/embedding/query-cache.js.map +1 -1
- package/dist/embedding/runtime.d.ts +2 -1
- package/dist/embedding/runtime.d.ts.map +1 -1
- package/dist/embedding/runtime.js +39 -5
- package/dist/embedding/runtime.js.map +1 -1
- package/dist/embedding/settings.d.ts +6 -0
- package/dist/embedding/settings.d.ts.map +1 -0
- package/dist/embedding/settings.js +69 -0
- package/dist/embedding/settings.js.map +1 -0
- package/dist/embedding/setup-lock.d.ts +7 -0
- package/dist/embedding/setup-lock.d.ts.map +1 -0
- package/dist/embedding/setup-lock.js +35 -0
- package/dist/embedding/setup-lock.js.map +1 -0
- package/dist/embedding/setup-service.d.ts +53 -0
- package/dist/embedding/setup-service.d.ts.map +1 -0
- package/dist/embedding/setup-service.js +184 -0
- package/dist/embedding/setup-service.js.map +1 -0
- package/dist/embedding/store.d.ts +3 -1
- package/dist/embedding/store.d.ts.map +1 -1
- package/dist/embedding/store.js +124 -11
- package/dist/embedding/store.js.map +1 -1
- package/dist/embedding/types.d.ts +31 -2
- package/dist/embedding/types.d.ts.map +1 -1
- package/dist/mcp/bounded-stdio-transport.d.ts +3 -10
- package/dist/mcp/bounded-stdio-transport.d.ts.map +1 -1
- package/dist/mcp/bounded-stdio-transport.js +2 -89
- package/dist/mcp/bounded-stdio-transport.js.map +1 -1
- package/dist/mcp/request-deadline.d.ts +51 -0
- package/dist/mcp/request-deadline.d.ts.map +1 -0
- package/dist/mcp/request-deadline.js +155 -0
- package/dist/mcp/request-deadline.js.map +1 -0
- package/dist/mcp/runtime-owner.d.ts.map +1 -1
- package/dist/mcp/runtime-owner.js +2 -3
- package/dist/mcp/runtime-owner.js.map +1 -1
- package/dist/mcp/server.d.ts +2 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +48 -20
- package/dist/mcp/server.js.map +1 -1
- package/dist/memory/scoped-memory.d.ts +1 -1
- package/dist/memory/scoped-memory.d.ts.map +1 -1
- package/dist/memory/scoped-memory.js +5 -1
- package/dist/memory/scoped-memory.js.map +1 -1
- package/dist/server/http.d.ts +1 -1
- package/dist/server/http.d.ts.map +1 -1
- package/dist/server/http.js +6 -3
- package/dist/server/http.js.map +1 -1
- package/dist/skills/discovery-service.d.ts.map +1 -1
- package/dist/skills/discovery-service.js +10 -8
- package/dist/skills/discovery-service.js.map +1 -1
- package/dist/skills/find.d.ts +1 -0
- package/dist/skills/find.d.ts.map +1 -1
- package/dist/skills/find.js +1 -0
- package/dist/skills/find.js.map +1 -1
- package/dist/skills/materialization-authority.d.ts +1 -1
- package/dist/skills/materialization-authority.d.ts.map +1 -1
- package/dist/skills/materialization-authority.js +2 -2
- package/dist/skills/materialization-authority.js.map +1 -1
- package/dist/skills/providers/skills-sh-compat.d.ts.map +1 -1
- package/dist/skills/providers/skills-sh-compat.js +4 -2
- package/dist/skills/providers/skills-sh-compat.js.map +1 -1
- package/dist/skills/providers/skills-sh-v1.d.ts +2 -2
- package/dist/skills/providers/skills-sh-v1.d.ts.map +1 -1
- package/dist/skills/providers/skills-sh-v1.js +22 -4
- package/dist/skills/providers/skills-sh-v1.js.map +1 -1
- package/dist/skills/source/github-fetcher.d.ts.map +1 -1
- package/dist/skills/source/github-fetcher.js +8 -4
- package/dist/skills/source/github-fetcher.js.map +1 -1
- package/dist/skills/types.d.ts +3 -2
- package/dist/skills/types.d.ts.map +1 -1
- package/docs/agent-file.md +72 -0
- package/docs/agent-gateway.md +104 -0
- package/docs/architecture.md +12 -0
- package/docs/cli-contract.md +13 -0
- package/docs/client-compatibility.md +298 -0
- package/docs/database.md +11 -0
- package/docs/execution-ledger.md +89 -0
- package/docs/release-notes-0.1.18.md +103 -0
- package/docs/retrieval-evaluation.md +10 -0
- package/docs/security.md +11 -0
- package/docs/sqlite-driver-adr.md +8 -0
- package/migrations/022_embedding_setup_v2.sql +236 -0
- package/migrations/down/022_embedding_setup_v2.sql +133 -0
- package/package.json +4 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Execution ledger
|
|
2
|
+
|
|
3
|
+
The execution ledger is an append-oriented audit of agent runs. It is separate from curated memory (`entries`, `entry_revisions`, `entry_revision_tags`, `entry_links`) and from memory mutation audit (`audit_events`). A ledger event never becomes verified memory automatically.
|
|
4
|
+
|
|
5
|
+
## Storage model
|
|
6
|
+
|
|
7
|
+
Migration `004_agent_gateway.sql` adds:
|
|
8
|
+
|
|
9
|
+
- `ledger_runs`: immutable workspace/client/protocol/capture/coverage identity and mutable lifecycle cursor/status.
|
|
10
|
+
- `run_intakes`: one-to-one link from a run to an existing Akinator session, including policy/schema versions, field sources, initial profile hash, and recommended tags.
|
|
11
|
+
- `intake_feedback`: question/profile feedback with XOR target and actor/idempotency uniqueness.
|
|
12
|
+
- `ledger_events`: contiguous local sequence, source identity, canonical/source types, bounded sanitized payload, redaction metadata, and hash-chain fields.
|
|
13
|
+
- `ledger_evidence`: bounded command/test/file/diff/URL/artifact locators and digests; never binary or unlimited output.
|
|
14
|
+
- `context_deliveries` and `context_delivery_entries`: exact cursor/profile/query/policy/budget and selected immutable entry revision/rank/score/reason. The child row has a composite foreign key to `entry_revisions`, so a delivery cannot reference a missing or silently substituted revision.
|
|
15
|
+
- `context_feedback` and `run_feedback`: explicit weak ranking signals and outcome/recommendation feedback.
|
|
16
|
+
- `ledger_memory_links`: provenance from run/event/delivery to promoted candidate memory.
|
|
17
|
+
- `ledger_purge_audit`: content-free tombstones after privacy purge.
|
|
18
|
+
|
|
19
|
+
Migration `010_nudge_deliveries.sql` adds:
|
|
20
|
+
|
|
21
|
+
- `nudge_deliveries`: presentation history for selected advisory nudges. It stores the run, policy version, checkpoint identity, logical occurrence, code, sequence, priority, and bounded evidence/reference ID snapshots, but not rendered message text.
|
|
22
|
+
|
|
23
|
+
Migration `011_nudge_integrity.sql` adds database guards for the supported nudge policy, code/priority pairs, and bounded JSON snapshots.
|
|
24
|
+
|
|
25
|
+
Enno client routing writes `enno.client_bound` for the first session route and
|
|
26
|
+
`enno.client_rebound` for later route changes. The payload records the previous
|
|
27
|
+
and current client kind, session ID, and version projection; a rebound clears
|
|
28
|
+
the old version. These events audit routing changes and do not confer ownership
|
|
29
|
+
or advance the Enno contract state.
|
|
30
|
+
|
|
31
|
+
The Enno execution ledger also uses database-backed ownership rows rather than
|
|
32
|
+
process memory. Resume tokens are stored only as hashes and bind a route epoch;
|
|
33
|
+
rerouting invalidates old epochs. A WorkUnit execution lease prevents two local
|
|
34
|
+
clients from reporting the same unit and blocks rerouting while current.
|
|
35
|
+
Operation receipts and verifier runs have `started`, `completed`, `failed`, and
|
|
36
|
+
`abandoned` states with bounded leases and owner nonces. Recovery atomically
|
|
37
|
+
abandons an expired owner before one new owner claims the exact operation; a
|
|
38
|
+
losing or stale nonce cannot complete it.
|
|
39
|
+
|
|
40
|
+
Final evidence binds contract revision, mutation revision, verifier
|
|
41
|
+
specification digest, and complete repository-state digests captured before and
|
|
42
|
+
after verifier execution. A verifier-caused repository mutation marks the run
|
|
43
|
+
unacceptable, and any later HEAD/index/worktree/untracked/symlink change makes
|
|
44
|
+
the evidence stale before `enno_finish` can commit.
|
|
45
|
+
|
|
46
|
+
## Invariants
|
|
47
|
+
|
|
48
|
+
1. A run belongs to one workspace for its lifetime.
|
|
49
|
+
2. One run links to one intake session, and one intake session links to one run; their workspaces must match.
|
|
50
|
+
3. `intake → active` is valid only after the linked session is `ready` or `exhausted`.
|
|
51
|
+
4. A run's coverage declaration is preserved rather than inferred upward.
|
|
52
|
+
5. `event_id` is globally unique; events also have unique `(run_id, sequence)` and unique `(run_id, source_event_id)` when present. Exact replay may identify an event by its explicit `eventId` or its run-scoped source identity; a different sanitized body conflicts.
|
|
53
|
+
6. A batch receives contiguous local sequence numbers in one `BEGIN IMMEDIATE` transaction or writes nothing.
|
|
54
|
+
7. Corrections and task-profile revisions are new events; prior event rows and finalized intake profiles are not rewritten.
|
|
55
|
+
8. Terminal runs reject new events except exact replay of an acknowledged idempotency/source identity.
|
|
56
|
+
9. Delivery rows reference entry revisions instead of copying memory bodies.
|
|
57
|
+
10. Feedback cannot mutate entry status/trust or an existing policy/session/profile.
|
|
58
|
+
11. Promotion is explicit, creates `candidate` memory only, and records provenance.
|
|
59
|
+
|
|
60
|
+
## Canonical event types
|
|
61
|
+
|
|
62
|
+
V1 recognizes intake/run/request/constraint/decision/step/approval/tool/command/file/test/verification/error/retry/cancellation/context/memory/task-profile/correction/source event families. Unknown client event names are retained only as `sourceType` behind the canonical `source.event` type; they are not invented or silently mapped.
|
|
63
|
+
|
|
64
|
+
## Integrity chain
|
|
65
|
+
|
|
66
|
+
Before storage, Kiokuko performs strict validation, creates an owned JSON snapshot, recursively sanitizes keys/values/URLs/paths/environment data, enforces byte limits, and canonicalizes JSON. Optional hash fields are represented explicitly as `null`, so the write-time preimage is identical after a SQLite round trip. The event hash commits to run ID, local sequence, canonical event data, sanitized payload, and previous hash. The first event uses the deterministic genesis hash. `doctor` checks contiguous sequence, run cursor, hash links, and orphans.
|
|
67
|
+
|
|
68
|
+
One sanitized event payload, task snapshot, profile-hints snapshot, intake-answer snapshot, or run-metadata snapshot is limited to 64 KiB. The limit is applied after sanitization and before hashing or opening a write transaction.
|
|
69
|
+
|
|
70
|
+
The chain is tamper-evident, not a signature or remote attestation. SQLite and same-user host security still define the local trust boundary.
|
|
71
|
+
|
|
72
|
+
## Projection and evidence freshness
|
|
73
|
+
|
|
74
|
+
Projection is deterministic through a committed local sequence. It derives current task profile from the immutable intake profile plus ordered `task_profile.revised` events, unresolved failures, unknown side effects, latest mutation, and latest passing verification. Evidence state is:
|
|
75
|
+
|
|
76
|
+
- `none`: no verification evidence;
|
|
77
|
+
- `failed`: latest relevant verification failed;
|
|
78
|
+
- `fresh`: passing verification is at or after the latest mutation;
|
|
79
|
+
- `stale`: a later mutation exists.
|
|
80
|
+
|
|
81
|
+
Minimum recommendation codes are `INTAKE_INCOMPLETE`, `VERIFY_AFTER_MUTATION`, `SIDE_EFFECT_OUTCOME_UNKNOWN`, `UNRESOLVED_FAILURE`, `CONTEXT_STALE`, `CONTRADICTORY_MEMORY`, `COVERAGE_INCOMPLETE`, and `PROMOTION_CANDIDATE`. Recommendations are stored data with evidence IDs, not commands.
|
|
82
|
+
|
|
83
|
+
Recommendations describe every currently applicable deterministic condition. A nudge is a separate presentation decision: at most one eligible advisory item selected from the v1 nudge subset (`SIDE_EFFECT_OUTCOME_UNKNOWN`, `UNRESOLVED_FAILURE`, and `VERIFY_AFTER_MUTATION`). `CONTRADICTORY_MEMORY` remains a recommendation but is not a nudge because the HTTP checkpoint broker does not currently expose its complete contradiction-pair state. Nudge candidates are derived from the committed projection and final capability-gated recommendations only; fixed messages and bounded evidence/reference IDs are returned, and rate limiting never removes the corresponding recommendation.
|
|
84
|
+
|
|
85
|
+
Nudge policy version `nudges.v1` shows one logical occurrence at most once per run, permits at most three deliveries per run, and requires at least three committed ledger sequence positions between deliveries of the same code. Eligibility uses occurrence identity and ledger sequence, not wall-clock time. `nudge_deliveries` is presentation history outside `ledger_events`, so delivering a nudge cannot change the execution projection.
|
|
86
|
+
|
|
87
|
+
## Archive, backup, purge
|
|
88
|
+
|
|
89
|
+
Existing memory export remains memory-only. Ledger export/import uses a separate deterministic manifest/checksum and includes nudge delivery history. Full SQLite backup contains memory, ledger, nudge deliveries, and feedback. Purge removes bounded content under explicit confirmation while preserving only a content-free tombstone and any promoted memory that has its own lifecycle.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Kiokuko 0.1.18
|
|
2
|
+
|
|
3
|
+
## External Skills
|
|
4
|
+
|
|
5
|
+
- Added bounded provider search, commit-pinned source validation, chunk limits, snapshot idempotency, and shared discovery single-flight.
|
|
6
|
+
- Added `kiokuko skills find|import|list|show|refresh|disable|enable|prune-cache`.
|
|
7
|
+
- Manual Skill import is now create-only and accepts only an exact locally
|
|
8
|
+
reviewed catalog identity. Re-importing an existing identity is a conflict;
|
|
9
|
+
use `skills refresh` for an existing managed Skill.
|
|
10
|
+
- Akinator discovery and `kiokuko skills find` now use one shared provider-backed search operation; the temporary capability-fallback response was removed.
|
|
11
|
+
- Akinator task preparation now defaults to reference-only `official` discovery; `off` remains available and `community` remains explicit opt-in.
|
|
12
|
+
- Interactive setup now asks before enabling audited community discovery and persists the selected mode in each managed MCP client configuration; batch setup uses `--skill-discovery`.
|
|
13
|
+
- Added authenticated local Web UI/API visibility for imported external skills.
|
|
14
|
+
- Disabled, stale, blocked, and unmanaged external references are excluded from retrieval and Curator globalization.
|
|
15
|
+
- Community-mode candidates fail closed without a successful provider audit.
|
|
16
|
+
- Unknown capability catalogs now force official-only discovery; imported Skill
|
|
17
|
+
reuse requires explicit applicability and mode-compatible provenance.
|
|
18
|
+
- Multiple relevant Skills can be imported from one repository, and lifecycle
|
|
19
|
+
CLI commands resolve both internal IDs and `owner/repository/skill` paths.
|
|
20
|
+
- Task preparation replay identity now includes the effective discovery mode
|
|
21
|
+
and a bounded normalized capability-catalog hash, so changed discovery input
|
|
22
|
+
cannot reuse an older context delivery.
|
|
23
|
+
- `task_prepare` now requires a bounded client-generated `requestId`. The same
|
|
24
|
+
ID and bound input replay one run; a changed bound request under that ID
|
|
25
|
+
conflicts, while a new ID opens a distinct run even for identical task text.
|
|
26
|
+
The raw ID is not stored and `client.sessionId` is not used as a turn ID. The
|
|
27
|
+
normalized context budget is bound and must match on `task_answer`.
|
|
28
|
+
- Generated agent/setup/MCP contracts now require an available local
|
|
29
|
+
`memory-reasoning` Skill to be read before code modification and recalled
|
|
30
|
+
claims to be converted into verified premises, invariants, counterexamples,
|
|
31
|
+
and regression tests; availability alone is not compliance.
|
|
32
|
+
- A v1 provider response with exact HTTP 401 authentication failure falls back
|
|
33
|
+
once per query to the Compatibility Provider, with provider-separated
|
|
34
|
+
negative and result caches. Other authentication and protocol failures stop.
|
|
35
|
+
- Removed legacy fixed-source sync and guessed-source fallback. Bounded exact
|
|
36
|
+
verification of reviewed catalog-pinned sources remains. The ungated
|
|
37
|
+
`guide context` compatibility command was removed; task-aware ContextBroker
|
|
38
|
+
output is capability-gated.
|
|
39
|
+
|
|
40
|
+
External skills remain untrusted candidate references. Kiokuko does not install,
|
|
41
|
+
execute, verify, globalize, or register fetched skill content automatically.
|
|
42
|
+
|
|
43
|
+
## Fail-closed storage and setup
|
|
44
|
+
|
|
45
|
+
- Fixed Windows OpenCode setup writing MCP configuration, global instructions,
|
|
46
|
+
and bundled skills under `%APPDATA%\opencode`; setup now follows OpenCode's
|
|
47
|
+
XDG global directory resolution.
|
|
48
|
+
- Setup now rejects duplicate or semantically colliding JSON/TOML configuration,
|
|
49
|
+
malformed UTF-8, symlink escapes, and concurrent target changes before it can
|
|
50
|
+
silently merge or overwrite them. Exact concurrent `use` results converge once;
|
|
51
|
+
incompatible state remains an explicit conflict.
|
|
52
|
+
- Migration and repository transactions now surface rollback failures, and
|
|
53
|
+
verified pre-migration backups complete before any schema mutation.
|
|
54
|
+
- Node.js 24.16 is now the minimum runtime. Manual and pre-migration SQLite
|
|
55
|
+
backups serialize the exact already-open connection and install a verified,
|
|
56
|
+
create-only artifact; the retired pathname-reopening backup subprocess and
|
|
57
|
+
overwrite behavior were removed. `kiokuko backup` no longer initializes or
|
|
58
|
+
migrates its source.
|
|
59
|
+
- Project binding rejects the reserved global identity. Forced rebinding now
|
|
60
|
+
requires a distinct repository/workspace pair and performs an exact database
|
|
61
|
+
location compare-and-swap or fails; it never mutates a repository workspace
|
|
62
|
+
in place or silently retains the old identity. Moving `agentFile` removes
|
|
63
|
+
only the old marked block, preserves human bytes and mode, and conditionally
|
|
64
|
+
restores all owned file mutations if a later step fails. Skipping an agent
|
|
65
|
+
write rejects any stale managed block at the prospective target.
|
|
66
|
+
- Repository binding/template versions are downgrade-protected across files and
|
|
67
|
+
SQLite metadata. Missing, malformed, corrupt, or future version metadata fails
|
|
68
|
+
explicitly. An indeterminate SQLite commit is surfaced as such and retains
|
|
69
|
+
the matching installed files instead of risking split-brain compensation.
|
|
70
|
+
- Stored revision chains, hashes, structured scope, projections, and context
|
|
71
|
+
replay state are validated from their exact persisted identities. Corruption
|
|
72
|
+
fails explicitly instead of being skipped or normalized into a new identity.
|
|
73
|
+
- Migration 012 validates the persisted structural identity of released
|
|
74
|
+
`context-ranking-v2` and `context-ranking-v3` scoped deliveries during setup.
|
|
75
|
+
Original delivery IDs, policy versions, character metadata, delivery items,
|
|
76
|
+
and all historical references are preserved. Legacy preview text was not
|
|
77
|
+
persisted and is not reconstructed during upgrade. Legacy deliveries remain
|
|
78
|
+
available for audit and feedback references but are never replayed as current
|
|
79
|
+
`context-ranking-v4` context; invalid persisted legacy structure aborts the
|
|
80
|
+
migration transaction. New scoped deliveries continue to use
|
|
81
|
+
`context-ranking-v4`.
|
|
82
|
+
- Migration 009 transactionally rewrites the one exact released locale-ordered
|
|
83
|
+
revision preimage to the canonical hash and scope. Forged preimages and
|
|
84
|
+
canonical collisions abort the upgrade; runtime compatibility hashing was
|
|
85
|
+
removed completely.
|
|
86
|
+
- Workspace archive v2 is intentionally limited to revision-1 current state.
|
|
87
|
+
Import/export use one strict canonical format, bounded input, complete secret
|
|
88
|
+
scanning, snapshot-consistent reads, and create-only output. Use a full SQLite
|
|
89
|
+
backup when immutable revision history must be preserved.
|
|
90
|
+
|
|
91
|
+
## Model task boundary
|
|
92
|
+
|
|
93
|
+
- Removed the direct model-facing `memory_recall` and
|
|
94
|
+
`claude_prompt_context` MCP tools. Task memory now enters through
|
|
95
|
+
`task_prepare` / `task_answer`; checkpoint and Curator tools remain lifecycle
|
|
96
|
+
operations.
|
|
97
|
+
- Removed generic JSON `call` operations that returned memory through `read`,
|
|
98
|
+
`search`, or scoped/unscoped `recall`. Direct CLI/Web inspection remains a
|
|
99
|
+
human/operator management surface.
|
|
100
|
+
- Setup no longer installs Claude prompt hooks or the OpenCode loop guard and
|
|
101
|
+
no longer accepts their CLI options. During upgrade it removes only the exact
|
|
102
|
+
retired managed hook/guard; modified or ambiguous legacy identities fail
|
|
103
|
+
explicitly and unrelated settings are preserved.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Retrieval evaluation
|
|
2
|
+
|
|
3
|
+
The existing evaluation keeps lexical and exact-signal lanes as baselines and
|
|
4
|
+
preserves weighted reciprocal-rank fusion. Local semantic evaluation covers
|
|
5
|
+
Japanese, English, Simplified Chinese, Korean, technical identifiers, stale
|
|
6
|
+
vectors, scope boundaries, and query-cache privacy.
|
|
7
|
+
|
|
8
|
+
Run the deterministic suite with `npm run test:evaluation`. Run the installed
|
|
9
|
+
model probe with `node scripts/run-local-embedding-smoke.mjs --offline` when a
|
|
10
|
+
verified local model directory is available.
|
package/docs/security.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Embedding security
|
|
2
|
+
|
|
3
|
+
The local-small preset fixes the repository, full revision, required files,
|
|
4
|
+
sizes, and SHA-256 values. Arbitrary repositories, URLs, paths, extensions,
|
|
5
|
+
and remote code are not accepted. Files are verified before model loading;
|
|
6
|
+
staging is private and final installation is atomic.
|
|
7
|
+
|
|
8
|
+
Status, doctor, progress, and errors do not include memory text, query text,
|
|
9
|
+
credentials, redirect URLs, or absolute model paths. Legacy embedding
|
|
10
|
+
environment variables are detected by name only and are not used as runtime
|
|
11
|
+
configuration.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SQLite driver ADR
|
|
2
|
+
|
|
3
|
+
Kiokuko keeps JavaScript exact-cosine search as the portable fallback and uses
|
|
4
|
+
the package-owned sqlite-vec extension only when the configured backend is
|
|
5
|
+
`auto` or `sqlite-vec` and the extension loads successfully. The setup model
|
|
6
|
+
and embedding profile are independent of that backend choice. Extension
|
|
7
|
+
loading is disabled immediately after a successful load, and user-provided
|
|
8
|
+
native extension paths are not accepted.
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
-- Persist local embedding setup state while retaining the immutable v1
|
|
2
|
+
-- semantic projections. This migration performs no model or network I/O.
|
|
3
|
+
|
|
4
|
+
CREATE TABLE embedding_profiles_v2 (
|
|
5
|
+
profile_id TEXT PRIMARY KEY
|
|
6
|
+
CHECK (length(profile_id) = 64 AND profile_id NOT GLOB '*[^0-9a-f]*'),
|
|
7
|
+
schema_version INTEGER NOT NULL DEFAULT 1 CHECK (schema_version IN (1, 2)),
|
|
8
|
+
provider_kind TEXT NOT NULL
|
|
9
|
+
CHECK (provider_kind IN ('openai-compatible', 'local-transformers')),
|
|
10
|
+
endpoint_fingerprint TEXT
|
|
11
|
+
CHECK (endpoint_fingerprint IS NULL OR (length(endpoint_fingerprint) = 64 AND endpoint_fingerprint NOT GLOB '*[^0-9a-f]*')),
|
|
12
|
+
model TEXT NOT NULL,
|
|
13
|
+
dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
|
|
14
|
+
distance_metric TEXT NOT NULL CHECK (distance_metric = 'cosine'),
|
|
15
|
+
distance_ceiling REAL NOT NULL CHECK (distance_ceiling > 0.0 AND distance_ceiling < 2.0),
|
|
16
|
+
document_template_version INTEGER NOT NULL CHECK (document_template_version > 0),
|
|
17
|
+
query_template_version INTEGER NOT NULL CHECK (query_template_version > 0),
|
|
18
|
+
preset_id TEXT,
|
|
19
|
+
source_model TEXT,
|
|
20
|
+
artifact_repository TEXT,
|
|
21
|
+
model_revision TEXT,
|
|
22
|
+
artifact_manifest_hash TEXT
|
|
23
|
+
CHECK (artifact_manifest_hash IS NULL OR (length(artifact_manifest_hash) = 64 AND artifact_manifest_hash NOT GLOB '*[^0-9a-f]*')),
|
|
24
|
+
inference_engine TEXT,
|
|
25
|
+
inference_engine_version TEXT,
|
|
26
|
+
dtype TEXT,
|
|
27
|
+
pooling TEXT,
|
|
28
|
+
normalize INTEGER CHECK (normalize IS NULL OR normalize IN (0, 1)),
|
|
29
|
+
maximum_tokens INTEGER CHECK (maximum_tokens IS NULL OR maximum_tokens > 0),
|
|
30
|
+
input_contract TEXT,
|
|
31
|
+
query_prefix TEXT,
|
|
32
|
+
document_prefix TEXT,
|
|
33
|
+
created_at TEXT NOT NULL,
|
|
34
|
+
CHECK (
|
|
35
|
+
(schema_version = 1 AND provider_kind = 'openai-compatible'
|
|
36
|
+
AND endpoint_fingerprint IS NOT NULL
|
|
37
|
+
AND preset_id IS NULL AND source_model IS NULL AND artifact_repository IS NULL
|
|
38
|
+
AND model_revision IS NULL AND artifact_manifest_hash IS NULL
|
|
39
|
+
AND inference_engine IS NULL AND inference_engine_version IS NULL
|
|
40
|
+
AND dtype IS NULL AND pooling IS NULL AND normalize IS NULL
|
|
41
|
+
AND maximum_tokens IS NULL AND input_contract IS NULL
|
|
42
|
+
AND query_prefix IS NULL AND document_prefix IS NULL)
|
|
43
|
+
OR
|
|
44
|
+
(schema_version = 2 AND provider_kind = 'local-transformers'
|
|
45
|
+
AND endpoint_fingerprint IS NULL
|
|
46
|
+
AND preset_id IS NOT NULL AND source_model IS NOT NULL
|
|
47
|
+
AND artifact_repository IS NOT NULL AND model_revision IS NOT NULL
|
|
48
|
+
AND artifact_manifest_hash IS NOT NULL AND inference_engine IS NOT NULL
|
|
49
|
+
AND inference_engine_version IS NOT NULL AND dtype IS NOT NULL
|
|
50
|
+
AND pooling IS NOT NULL AND normalize IS NOT NULL
|
|
51
|
+
AND maximum_tokens IS NOT NULL AND input_contract IS NOT NULL
|
|
52
|
+
AND query_prefix IS NOT NULL AND document_prefix IS NOT NULL)
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
INSERT INTO embedding_profiles_v2 (
|
|
57
|
+
profile_id, schema_version, provider_kind, endpoint_fingerprint, model,
|
|
58
|
+
dimensions, distance_metric, distance_ceiling, document_template_version,
|
|
59
|
+
query_template_version, created_at
|
|
60
|
+
)
|
|
61
|
+
SELECT profile_id, 1, provider_kind, endpoint_fingerprint, model,
|
|
62
|
+
dimensions, distance_metric, distance_ceiling, document_template_version,
|
|
63
|
+
query_template_version, created_at
|
|
64
|
+
FROM embedding_profiles;
|
|
65
|
+
|
|
66
|
+
CREATE TABLE embedding_runtime_v2 (
|
|
67
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
68
|
+
active_profile_id TEXT REFERENCES embedding_profiles_v2(profile_id),
|
|
69
|
+
generation INTEGER NOT NULL CHECK (generation > 0),
|
|
70
|
+
activated_at TEXT
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
INSERT INTO embedding_runtime_v2 (singleton, active_profile_id, generation, activated_at)
|
|
74
|
+
SELECT singleton, active_profile_id, generation, activated_at
|
|
75
|
+
FROM embedding_runtime;
|
|
76
|
+
|
|
77
|
+
CREATE TABLE entry_embeddings_v2 (
|
|
78
|
+
entry_id TEXT NOT NULL,
|
|
79
|
+
profile_id TEXT NOT NULL REFERENCES embedding_profiles_v2(profile_id) ON DELETE CASCADE,
|
|
80
|
+
revision INTEGER NOT NULL CHECK (revision > 0),
|
|
81
|
+
content_hash TEXT NOT NULL,
|
|
82
|
+
document_hash TEXT NOT NULL CHECK (length(document_hash) = 64 AND document_hash NOT GLOB '*[^0-9a-f]*'),
|
|
83
|
+
dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
|
|
84
|
+
embedding BLOB NOT NULL,
|
|
85
|
+
vector_hash TEXT NOT NULL CHECK (length(vector_hash) = 64 AND vector_hash NOT GLOB '*[^0-9a-f]*'),
|
|
86
|
+
created_at TEXT NOT NULL,
|
|
87
|
+
PRIMARY KEY (entry_id, profile_id),
|
|
88
|
+
FOREIGN KEY (entry_id, revision) REFERENCES entry_revisions(entry_id, revision) ON DELETE CASCADE,
|
|
89
|
+
CHECK (length(embedding) = dimensions * 4)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
INSERT INTO entry_embeddings_v2 (
|
|
93
|
+
entry_id, profile_id, revision, content_hash, document_hash, dimensions,
|
|
94
|
+
embedding, vector_hash, created_at
|
|
95
|
+
)
|
|
96
|
+
SELECT entry_id, profile_id, revision, content_hash, document_hash, dimensions,
|
|
97
|
+
embedding, vector_hash, created_at
|
|
98
|
+
FROM entry_embeddings;
|
|
99
|
+
|
|
100
|
+
CREATE TABLE embedding_jobs_v2 (
|
|
101
|
+
entry_id TEXT NOT NULL,
|
|
102
|
+
profile_id TEXT NOT NULL REFERENCES embedding_profiles_v2(profile_id) ON DELETE CASCADE,
|
|
103
|
+
revision INTEGER NOT NULL CHECK (revision > 0),
|
|
104
|
+
content_hash TEXT NOT NULL,
|
|
105
|
+
state TEXT NOT NULL CHECK (state IN ('pending', 'leased', 'failed', 'blocked')),
|
|
106
|
+
attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts >= 0),
|
|
107
|
+
available_at TEXT NOT NULL,
|
|
108
|
+
lease_id TEXT,
|
|
109
|
+
lease_expires_at TEXT,
|
|
110
|
+
error_code TEXT CHECK (error_code IS NULL OR error_code IN (
|
|
111
|
+
'timeout', 'rate_limited', 'provider_unavailable', 'invalid_response',
|
|
112
|
+
'dimension_mismatch', 'secret_blocked', 'profile_changed', 'entry_changed'
|
|
113
|
+
)),
|
|
114
|
+
created_at TEXT NOT NULL,
|
|
115
|
+
updated_at TEXT NOT NULL,
|
|
116
|
+
PRIMARY KEY (entry_id, profile_id),
|
|
117
|
+
FOREIGN KEY (entry_id, revision) REFERENCES entry_revisions(entry_id, revision) ON DELETE CASCADE,
|
|
118
|
+
CHECK (
|
|
119
|
+
(state = 'leased' AND lease_id IS NOT NULL AND lease_expires_at IS NOT NULL)
|
|
120
|
+
OR (state <> 'leased' AND lease_id IS NULL AND lease_expires_at IS NULL)
|
|
121
|
+
)
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
INSERT INTO embedding_jobs_v2 (
|
|
125
|
+
entry_id, profile_id, revision, content_hash, state, attempts,
|
|
126
|
+
available_at, lease_id, lease_expires_at, error_code, created_at, updated_at
|
|
127
|
+
)
|
|
128
|
+
SELECT entry_id, profile_id, revision, content_hash, state, attempts,
|
|
129
|
+
available_at, lease_id, lease_expires_at, error_code, created_at, updated_at
|
|
130
|
+
FROM embedding_jobs;
|
|
131
|
+
|
|
132
|
+
CREATE TABLE query_embeddings_v2 (
|
|
133
|
+
profile_id TEXT NOT NULL REFERENCES embedding_profiles_v2(profile_id) ON DELETE CASCADE,
|
|
134
|
+
query_hash TEXT NOT NULL CHECK (length(query_hash) = 64 AND query_hash NOT GLOB '*[^0-9a-f]*'),
|
|
135
|
+
dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
|
|
136
|
+
embedding BLOB NOT NULL,
|
|
137
|
+
vector_hash TEXT NOT NULL CHECK (length(vector_hash) = 64 AND vector_hash NOT GLOB '*[^0-9a-f]*'),
|
|
138
|
+
created_at TEXT NOT NULL,
|
|
139
|
+
last_used_at TEXT NOT NULL,
|
|
140
|
+
PRIMARY KEY (profile_id, query_hash),
|
|
141
|
+
CHECK (length(embedding) = dimensions * 4)
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
INSERT INTO query_embeddings_v2 (
|
|
145
|
+
profile_id, query_hash, dimensions, embedding, vector_hash, created_at, last_used_at
|
|
146
|
+
)
|
|
147
|
+
SELECT profile_id, query_hash, dimensions, embedding, vector_hash, created_at, last_used_at
|
|
148
|
+
FROM query_embeddings;
|
|
149
|
+
|
|
150
|
+
DROP INDEX idx_query_embeddings_lru;
|
|
151
|
+
DROP TABLE query_embeddings;
|
|
152
|
+
DROP INDEX idx_embedding_jobs_claim;
|
|
153
|
+
DROP TABLE embedding_jobs;
|
|
154
|
+
DROP INDEX idx_entry_embeddings_profile_revision;
|
|
155
|
+
DROP TABLE entry_embeddings;
|
|
156
|
+
DROP TABLE embedding_runtime;
|
|
157
|
+
DROP TRIGGER embedding_profiles_immutable_update;
|
|
158
|
+
DROP TABLE embedding_profiles;
|
|
159
|
+
|
|
160
|
+
ALTER TABLE embedding_profiles_v2 RENAME TO embedding_profiles;
|
|
161
|
+
ALTER TABLE embedding_runtime_v2 RENAME TO embedding_runtime;
|
|
162
|
+
ALTER TABLE entry_embeddings_v2 RENAME TO entry_embeddings;
|
|
163
|
+
ALTER TABLE embedding_jobs_v2 RENAME TO embedding_jobs;
|
|
164
|
+
ALTER TABLE query_embeddings_v2 RENAME TO query_embeddings;
|
|
165
|
+
|
|
166
|
+
CREATE TRIGGER embedding_profiles_immutable_update
|
|
167
|
+
BEFORE UPDATE ON embedding_profiles
|
|
168
|
+
BEGIN
|
|
169
|
+
SELECT RAISE(ABORT, 'embedding_profiles are immutable');
|
|
170
|
+
END;
|
|
171
|
+
|
|
172
|
+
CREATE INDEX idx_entry_embeddings_profile_revision
|
|
173
|
+
ON entry_embeddings(profile_id, entry_id, revision);
|
|
174
|
+
CREATE INDEX idx_embedding_jobs_claim
|
|
175
|
+
ON embedding_jobs(profile_id, state, available_at, entry_id);
|
|
176
|
+
CREATE INDEX idx_query_embeddings_lru
|
|
177
|
+
ON query_embeddings(profile_id, last_used_at, query_hash);
|
|
178
|
+
|
|
179
|
+
CREATE TABLE embedding_model_installations (
|
|
180
|
+
installation_id TEXT PRIMARY KEY,
|
|
181
|
+
preset_id TEXT NOT NULL,
|
|
182
|
+
repository_id TEXT NOT NULL,
|
|
183
|
+
revision TEXT NOT NULL,
|
|
184
|
+
artifact_manifest_hash TEXT NOT NULL CHECK (length(artifact_manifest_hash) = 64 AND artifact_manifest_hash NOT GLOB '*[^0-9a-f]*'),
|
|
185
|
+
relative_path TEXT NOT NULL,
|
|
186
|
+
state TEXT NOT NULL CHECK (state IN ('staging', 'verified', 'corrupt', 'missing')),
|
|
187
|
+
total_bytes INTEGER NOT NULL CHECK (total_bytes >= 0),
|
|
188
|
+
installed_at TEXT NOT NULL,
|
|
189
|
+
verified_at TEXT,
|
|
190
|
+
last_checked_at TEXT NOT NULL
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
CREATE TABLE embedding_settings (
|
|
194
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
195
|
+
mode TEXT NOT NULL CHECK (mode IN ('off', 'optional', 'required')),
|
|
196
|
+
provider_kind TEXT CHECK (provider_kind IS NULL OR provider_kind IN ('local-transformers', 'openai-compatible', 'legacy-environment')),
|
|
197
|
+
preset_id TEXT,
|
|
198
|
+
model_installation_id TEXT REFERENCES embedding_model_installations(installation_id),
|
|
199
|
+
vector_backend TEXT NOT NULL CHECK (vector_backend IN ('auto', 'javascript', 'sqlite-vec')),
|
|
200
|
+
batch_size INTEGER NOT NULL CHECK (batch_size BETWEEN 1 AND 64),
|
|
201
|
+
timeout_ms INTEGER NOT NULL CHECK (timeout_ms BETWEEN 100 AND 120000),
|
|
202
|
+
legacy_profile_id TEXT REFERENCES embedding_profiles(profile_id),
|
|
203
|
+
setup_state TEXT NOT NULL CHECK (setup_state IN ('disabled', 'requires_setup', 'installing', 'ready', 'degraded')),
|
|
204
|
+
updated_at TEXT NOT NULL
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
INSERT INTO embedding_settings (
|
|
208
|
+
singleton, mode, provider_kind, preset_id, model_installation_id,
|
|
209
|
+
vector_backend, batch_size, timeout_ms, legacy_profile_id, setup_state, updated_at
|
|
210
|
+
)
|
|
211
|
+
SELECT 1,
|
|
212
|
+
'off',
|
|
213
|
+
CASE WHEN r.active_profile_id IS NULL THEN NULL ELSE 'legacy-environment' END,
|
|
214
|
+
NULL,
|
|
215
|
+
NULL,
|
|
216
|
+
'auto',
|
|
217
|
+
16,
|
|
218
|
+
30000,
|
|
219
|
+
r.active_profile_id,
|
|
220
|
+
CASE WHEN r.active_profile_id IS NULL THEN 'disabled' ELSE 'requires_setup' END,
|
|
221
|
+
COALESCE(r.activated_at, '1970-01-01T00:00:00.000Z')
|
|
222
|
+
FROM embedding_runtime AS r;
|
|
223
|
+
|
|
224
|
+
CREATE TABLE embedding_setup_runs (
|
|
225
|
+
setup_id TEXT PRIMARY KEY,
|
|
226
|
+
preset_id TEXT NOT NULL,
|
|
227
|
+
phase TEXT NOT NULL CHECK (phase IN ('planned', 'downloading', 'verifying', 'probing', 'activating', 'embedding', 'completed', 'failed')),
|
|
228
|
+
model_installation_id TEXT REFERENCES embedding_model_installations(installation_id),
|
|
229
|
+
active_profile_id TEXT REFERENCES embedding_profiles(profile_id),
|
|
230
|
+
initial_entry_count INTEGER NOT NULL CHECK (initial_entry_count >= 0),
|
|
231
|
+
processed_entry_count INTEGER NOT NULL CHECK (processed_entry_count >= 0),
|
|
232
|
+
failure_code TEXT,
|
|
233
|
+
started_at TEXT NOT NULL,
|
|
234
|
+
updated_at TEXT NOT NULL,
|
|
235
|
+
completed_at TEXT
|
|
236
|
+
);
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
-- Manual rollback for migration 022. Stop every Kiokuko process and make a
|
|
2
|
+
-- full SQLite backup before running this script. Local v2 profiles are not
|
|
3
|
+
-- silently converted to the v1 representation.
|
|
4
|
+
|
|
5
|
+
BEGIN IMMEDIATE;
|
|
6
|
+
|
|
7
|
+
CREATE TEMP TRIGGER embedding_setup_v2_rollback_guard
|
|
8
|
+
BEFORE DELETE ON schema_migrations
|
|
9
|
+
WHEN EXISTS (SELECT 1 FROM embedding_profiles WHERE schema_version = 2)
|
|
10
|
+
BEGIN
|
|
11
|
+
SELECT RAISE(ABORT, 'migration 022 rollback requires removing local v2 profiles explicitly');
|
|
12
|
+
END;
|
|
13
|
+
|
|
14
|
+
CREATE TABLE embedding_profiles_v1 (
|
|
15
|
+
profile_id TEXT PRIMARY KEY CHECK (length(profile_id) = 64 AND profile_id NOT GLOB '*[^0-9a-f]*'),
|
|
16
|
+
provider_kind TEXT NOT NULL CHECK (provider_kind IN ('openai-compatible')),
|
|
17
|
+
endpoint_fingerprint TEXT NOT NULL CHECK (length(endpoint_fingerprint) = 64 AND endpoint_fingerprint NOT GLOB '*[^0-9a-f]*'),
|
|
18
|
+
model TEXT NOT NULL,
|
|
19
|
+
dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
|
|
20
|
+
distance_metric TEXT NOT NULL CHECK (distance_metric = 'cosine'),
|
|
21
|
+
distance_ceiling REAL NOT NULL CHECK (distance_ceiling > 0.0 AND distance_ceiling < 2.0),
|
|
22
|
+
document_template_version INTEGER NOT NULL CHECK (document_template_version > 0),
|
|
23
|
+
query_template_version INTEGER NOT NULL CHECK (query_template_version > 0),
|
|
24
|
+
created_at TEXT NOT NULL
|
|
25
|
+
);
|
|
26
|
+
INSERT INTO embedding_profiles_v1 (
|
|
27
|
+
profile_id, provider_kind, endpoint_fingerprint, model, dimensions,
|
|
28
|
+
distance_metric, distance_ceiling, document_template_version,
|
|
29
|
+
query_template_version, created_at
|
|
30
|
+
)
|
|
31
|
+
SELECT profile_id, provider_kind, endpoint_fingerprint, model, dimensions,
|
|
32
|
+
distance_metric, distance_ceiling, document_template_version,
|
|
33
|
+
query_template_version, created_at
|
|
34
|
+
FROM embedding_profiles;
|
|
35
|
+
|
|
36
|
+
CREATE TABLE embedding_runtime_v1 (
|
|
37
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
38
|
+
active_profile_id TEXT REFERENCES embedding_profiles_v1(profile_id),
|
|
39
|
+
generation INTEGER NOT NULL CHECK (generation > 0),
|
|
40
|
+
activated_at TEXT
|
|
41
|
+
);
|
|
42
|
+
INSERT INTO embedding_runtime_v1 (singleton, active_profile_id, generation, activated_at)
|
|
43
|
+
SELECT singleton, active_profile_id, generation, activated_at FROM embedding_runtime;
|
|
44
|
+
|
|
45
|
+
CREATE TABLE entry_embeddings_v1 (
|
|
46
|
+
entry_id TEXT NOT NULL,
|
|
47
|
+
profile_id TEXT NOT NULL REFERENCES embedding_profiles_v1(profile_id) ON DELETE CASCADE,
|
|
48
|
+
revision INTEGER NOT NULL CHECK (revision > 0),
|
|
49
|
+
content_hash TEXT NOT NULL,
|
|
50
|
+
document_hash TEXT NOT NULL CHECK (length(document_hash) = 64 AND document_hash NOT GLOB '*[^0-9a-f]*'),
|
|
51
|
+
dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
|
|
52
|
+
embedding BLOB NOT NULL,
|
|
53
|
+
vector_hash TEXT NOT NULL CHECK (length(vector_hash) = 64 AND vector_hash NOT GLOB '*[^0-9a-f]*'),
|
|
54
|
+
created_at TEXT NOT NULL,
|
|
55
|
+
PRIMARY KEY (entry_id, profile_id),
|
|
56
|
+
FOREIGN KEY (entry_id, revision) REFERENCES entry_revisions(entry_id, revision) ON DELETE CASCADE,
|
|
57
|
+
CHECK (length(embedding) = dimensions * 4)
|
|
58
|
+
);
|
|
59
|
+
INSERT INTO entry_embeddings_v1 SELECT * FROM entry_embeddings;
|
|
60
|
+
|
|
61
|
+
CREATE TABLE embedding_jobs_v1 (
|
|
62
|
+
entry_id TEXT NOT NULL,
|
|
63
|
+
profile_id TEXT NOT NULL REFERENCES embedding_profiles_v1(profile_id) ON DELETE CASCADE,
|
|
64
|
+
revision INTEGER NOT NULL CHECK (revision > 0),
|
|
65
|
+
content_hash TEXT NOT NULL,
|
|
66
|
+
state TEXT NOT NULL CHECK (state IN ('pending', 'leased', 'failed', 'blocked')),
|
|
67
|
+
attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts >= 0),
|
|
68
|
+
available_at TEXT NOT NULL,
|
|
69
|
+
lease_id TEXT,
|
|
70
|
+
lease_expires_at TEXT,
|
|
71
|
+
error_code TEXT CHECK (error_code IS NULL OR error_code IN (
|
|
72
|
+
'timeout', 'rate_limited', 'provider_unavailable', 'invalid_response',
|
|
73
|
+
'dimension_mismatch', 'secret_blocked', 'profile_changed', 'entry_changed'
|
|
74
|
+
)),
|
|
75
|
+
created_at TEXT NOT NULL,
|
|
76
|
+
updated_at TEXT NOT NULL,
|
|
77
|
+
PRIMARY KEY (entry_id, profile_id),
|
|
78
|
+
FOREIGN KEY (entry_id, revision) REFERENCES entry_revisions(entry_id, revision) ON DELETE CASCADE,
|
|
79
|
+
CHECK (
|
|
80
|
+
(state = 'leased' AND lease_id IS NOT NULL AND lease_expires_at IS NOT NULL)
|
|
81
|
+
OR (state <> 'leased' AND lease_id IS NULL AND lease_expires_at IS NULL)
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
INSERT INTO embedding_jobs_v1 SELECT * FROM embedding_jobs;
|
|
85
|
+
|
|
86
|
+
CREATE TABLE query_embeddings_v1 (
|
|
87
|
+
profile_id TEXT NOT NULL REFERENCES embedding_profiles_v1(profile_id) ON DELETE CASCADE,
|
|
88
|
+
query_hash TEXT NOT NULL CHECK (length(query_hash) = 64 AND query_hash NOT GLOB '*[^0-9a-f]*'),
|
|
89
|
+
dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
|
|
90
|
+
embedding BLOB NOT NULL,
|
|
91
|
+
vector_hash TEXT NOT NULL CHECK (length(vector_hash) = 64 AND vector_hash NOT GLOB '*[^0-9a-f]*'),
|
|
92
|
+
created_at TEXT NOT NULL,
|
|
93
|
+
last_used_at TEXT NOT NULL,
|
|
94
|
+
PRIMARY KEY (profile_id, query_hash),
|
|
95
|
+
CHECK (length(embedding) = dimensions * 4)
|
|
96
|
+
);
|
|
97
|
+
INSERT INTO query_embeddings_v1 SELECT * FROM query_embeddings;
|
|
98
|
+
|
|
99
|
+
DELETE FROM schema_migrations WHERE version = 22 AND name = '022_embedding_setup_v2.sql';
|
|
100
|
+
DROP TRIGGER embedding_setup_v2_rollback_guard;
|
|
101
|
+
|
|
102
|
+
DROP TABLE embedding_setup_runs;
|
|
103
|
+
DROP TABLE embedding_settings;
|
|
104
|
+
DROP TABLE embedding_model_installations;
|
|
105
|
+
DROP INDEX idx_query_embeddings_lru;
|
|
106
|
+
DROP TABLE query_embeddings;
|
|
107
|
+
DROP INDEX idx_embedding_jobs_claim;
|
|
108
|
+
DROP TABLE embedding_jobs;
|
|
109
|
+
DROP INDEX idx_entry_embeddings_profile_revision;
|
|
110
|
+
DROP TABLE entry_embeddings;
|
|
111
|
+
DROP TABLE embedding_runtime;
|
|
112
|
+
DROP TRIGGER embedding_profiles_immutable_update;
|
|
113
|
+
DROP TABLE embedding_profiles;
|
|
114
|
+
|
|
115
|
+
ALTER TABLE embedding_profiles_v1 RENAME TO embedding_profiles;
|
|
116
|
+
ALTER TABLE embedding_runtime_v1 RENAME TO embedding_runtime;
|
|
117
|
+
ALTER TABLE entry_embeddings_v1 RENAME TO entry_embeddings;
|
|
118
|
+
ALTER TABLE embedding_jobs_v1 RENAME TO embedding_jobs;
|
|
119
|
+
ALTER TABLE query_embeddings_v1 RENAME TO query_embeddings;
|
|
120
|
+
|
|
121
|
+
CREATE TRIGGER embedding_profiles_immutable_update
|
|
122
|
+
BEFORE UPDATE ON embedding_profiles
|
|
123
|
+
BEGIN
|
|
124
|
+
SELECT RAISE(ABORT, 'embedding_profiles are immutable');
|
|
125
|
+
END;
|
|
126
|
+
CREATE INDEX idx_entry_embeddings_profile_revision
|
|
127
|
+
ON entry_embeddings(profile_id, entry_id, revision);
|
|
128
|
+
CREATE INDEX idx_embedding_jobs_claim
|
|
129
|
+
ON embedding_jobs(profile_id, state, available_at, entry_id);
|
|
130
|
+
CREATE INDEX idx_query_embeddings_lru
|
|
131
|
+
ON query_embeddings(profile_id, last_used_at, query_hash);
|
|
132
|
+
|
|
133
|
+
COMMIT;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askdkc/kiokuko",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Model-agnostic external memory for AI coding agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"dist/",
|
|
17
17
|
"migrations/",
|
|
18
18
|
"skills/",
|
|
19
|
+
"docs/",
|
|
19
20
|
"templates/",
|
|
20
21
|
"README.md",
|
|
21
22
|
"README.ja.md",
|
|
@@ -53,6 +54,8 @@
|
|
|
53
54
|
"zod": "^4.4.3"
|
|
54
55
|
},
|
|
55
56
|
"optionalDependencies": {
|
|
57
|
+
"@huggingface/hub": "2.16.1",
|
|
58
|
+
"@huggingface/transformers": "4.2.0",
|
|
56
59
|
"sqlite-vec": "0.1.9"
|
|
57
60
|
},
|
|
58
61
|
"devDependencies": {
|