pi-tuck 1.1.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/index.d.ts +2 -6
- package/dist/index.js +16 -111
- package/dist/src/build-id.d.ts +1 -1
- package/dist/src/build-id.js +1 -1
- package/dist/src/compaction.d.ts +2 -103
- package/dist/src/compaction.js +20 -140
- package/dist/src/diagnostic-replay.js +2 -2
- package/dist/src/diagnostics.d.ts +3 -2
- package/dist/src/diagnostics.js +30 -9
- package/dist/src/history-tools.js +3 -3
- package/dist/src/kept-reads.d.ts +2 -2
- package/dist/src/kept-reads.js +144 -8
- package/dist/src/ledger.d.ts +1 -1
- package/dist/src/ledger.js +5 -3
- package/dist/src/legacy-cleanup.d.ts +3 -0
- package/dist/src/legacy-cleanup.js +190 -0
- package/dist/src/notify.d.ts +3 -0
- package/dist/src/notify.js +13 -0
- package/dist/src/omissions.d.ts +1 -1
- package/dist/src/omissions.js +3 -3
- package/dist/src/path-key.d.ts +3 -0
- package/dist/src/path-key.js +8 -0
- package/dist/src/request-capacity.js +1 -1
- package/dist/src/run.d.ts +1 -3
- package/dist/src/run.js +3 -5
- package/dist/src/source-export.d.ts +1 -1
- package/dist/src/source-export.js +1 -1
- package/dist/src/status.d.ts +0 -6
- package/dist/src/status.js +1 -6
- package/dist/src/tuck/core/content.js +6 -9
- package/dist/src/tuck/core/keyword-query.d.ts +2 -2
- package/dist/src/tuck/core/keyword-query.js +1 -1
- package/dist/src/tuck/core/search-entries.js +5 -5
- package/dist/src/tuck/core/transcript.js +2 -1
- package/dist/src/tuck.js +390 -394
- package/dist/src/windows-private-storage.d.ts +9 -0
- package/dist/src/windows-private-storage.js +90 -0
- package/index.ts +18 -82
- package/package.json +5 -8
- package/src/build-id.ts +1 -1
- package/src/compaction.ts +19 -107
- package/src/diagnostic-replay.ts +2 -2
- package/src/diagnostics.ts +24 -9
- package/src/history-tools.ts +3 -3
- package/src/kept-reads.ts +78 -10
- package/src/ledger.ts +5 -3
- package/src/legacy-cleanup.ts +134 -0
- package/src/notify.ts +10 -0
- package/src/omissions.ts +3 -3
- package/src/path-key.ts +9 -0
- package/src/request-capacity.ts +1 -1
- package/src/run.ts +4 -6
- package/src/source-export.ts +1 -1
- package/src/status.ts +1 -10
- package/src/tuck/core/content.ts +5 -10
- package/src/tuck/core/keyword-query.ts +2 -2
- package/src/tuck/core/search-entries.ts +5 -5
- package/src/tuck/core/transcript.ts +2 -1
- package/src/tuck.ts +329 -335
- package/src/windows-private-storage.ts +94 -0
- package/dist/src/assets.d.ts +0 -58
- package/dist/src/assets.js +0 -80
- package/dist/src/eligibility-cache.d.ts +0 -19
- package/dist/src/eligibility-cache.js +0 -33
- package/dist/src/semantic-recall.d.ts +0 -422
- package/dist/src/semantic-recall.js +0 -1386
- package/dist/src/setup.d.ts +0 -3
- package/dist/src/setup.js +0 -191
- package/scripts/eg2-runtime.py +0 -307
- package/scripts/provision-eg2.py +0 -139
- package/scripts/semantic-worker.py +0 -234
- package/src/assets.ts +0 -92
- package/src/eligibility-cache.ts +0 -43
- package/src/semantic-recall.ts +0 -592
- package/src/setup.ts +0 -163
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { mkdir } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
|
|
5
|
+
// Node's Windows mode/uid fields cannot prove private storage. Check the native DACL instead.
|
|
6
|
+
// Pass paths as data, never PowerShell source; SID comparisons also work on non-English hosts.
|
|
7
|
+
const CHECK_ACL = `
|
|
8
|
+
$ErrorActionPreference = 'Stop'
|
|
9
|
+
try {
|
|
10
|
+
$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value
|
|
11
|
+
$trusted = @($user, 'S-1-5-18', 'S-1-5-32-544')
|
|
12
|
+
foreach ($path in (ConvertFrom-Json -InputObject $env:PI_TUCK_STORAGE_PATHS)) {
|
|
13
|
+
$item = Get-Item -LiteralPath $path -Force
|
|
14
|
+
if ($item.Attributes -band [System.IO.FileAttributes]::ReparsePoint) { throw 'Recorder reparse point' }
|
|
15
|
+
$acl = Get-Acl -LiteralPath $path
|
|
16
|
+
if ($trusted -notcontains $acl.GetOwner([System.Security.Principal.SecurityIdentifier]).Value) { throw 'Recorder owner' }
|
|
17
|
+
$rules = $acl.GetAccessRules($true, $true, [System.Security.Principal.SecurityIdentifier])
|
|
18
|
+
if ($rules.Count -eq 0) { throw 'Recorder missing DACL' }
|
|
19
|
+
foreach ($rule in $rules) {
|
|
20
|
+
if ($rule.AccessControlType -ne [System.Security.AccessControl.AccessControlType]::Allow) { continue }
|
|
21
|
+
$sid = $rule.IdentityReference.Value
|
|
22
|
+
if ($trusted -contains $sid) { continue }
|
|
23
|
+
if ($sid -eq 'S-1-3-0' -and ($rule.PropagationFlags -band [System.Security.AccessControl.PropagationFlags]::InheritOnly)) { continue }
|
|
24
|
+
throw 'Recorder non-private DACL'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
} catch { [Console]::Error.WriteLine('Recorder requires private Windows storage'); exit 1 }
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
// Build a fresh protected DACL, dropping both inherited and explicit foreign entries.
|
|
31
|
+
// Directories pass this security descriptor at creation, including missing ancestors;
|
|
32
|
+
// existing directories are returned unchanged by Directory.CreateDirectory.
|
|
33
|
+
const PRIVATE_DACL = `
|
|
34
|
+
$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().User
|
|
35
|
+
$acl.SetOwner($user)
|
|
36
|
+
$acl.SetAccessRuleProtection($true, $false)
|
|
37
|
+
foreach ($sid in @($user.Value, 'S-1-5-18', 'S-1-5-32-544')) {
|
|
38
|
+
$identity = [System.Security.Principal.SecurityIdentifier]::new($sid)
|
|
39
|
+
$rule = [System.Security.AccessControl.FileSystemAccessRule]::new($identity, [System.Security.AccessControl.FileSystemRights]::FullControl, $inheritance, [System.Security.AccessControl.PropagationFlags]::None, [System.Security.AccessControl.AccessControlType]::Allow)
|
|
40
|
+
$acl.AddAccessRule($rule)
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
const CREATE_DIRECTORY = `
|
|
44
|
+
$ErrorActionPreference = 'Stop'
|
|
45
|
+
try {
|
|
46
|
+
$acl = [System.Security.AccessControl.DirectorySecurity]::new()
|
|
47
|
+
$inheritance = [System.Security.AccessControl.InheritanceFlags]'ContainerInherit, ObjectInherit'
|
|
48
|
+
${PRIVATE_DACL}
|
|
49
|
+
foreach ($path in (ConvertFrom-Json -InputObject $env:PI_TUCK_STORAGE_PATHS)) {
|
|
50
|
+
[void][System.IO.Directory]::CreateDirectory($path, $acl)
|
|
51
|
+
}
|
|
52
|
+
} catch { [Console]::Error.WriteLine('Recorder could not create private Windows directory'); exit 1 }
|
|
53
|
+
`;
|
|
54
|
+
const PROTECT_FILE = `
|
|
55
|
+
$ErrorActionPreference = 'Stop'
|
|
56
|
+
try {
|
|
57
|
+
$acl = [System.Security.AccessControl.FileSecurity]::new()
|
|
58
|
+
$inheritance = [System.Security.AccessControl.InheritanceFlags]::None
|
|
59
|
+
${PRIVATE_DACL}
|
|
60
|
+
foreach ($path in (ConvertFrom-Json -InputObject $env:PI_TUCK_STORAGE_PATHS)) {
|
|
61
|
+
$item = Get-Item -LiteralPath $path -Force
|
|
62
|
+
if ($item.PSIsContainer -or ($item.Attributes -band [System.IO.FileAttributes]::ReparsePoint)) { throw 'Recorder file type' }
|
|
63
|
+
Set-Acl -LiteralPath $path -AclObject $acl
|
|
64
|
+
}
|
|
65
|
+
} catch { [Console]::Error.WriteLine('Recorder could not protect Windows file'); exit 1 }
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
function runAclCommand(script: string, paths: readonly string[]): Promise<void> {
|
|
69
|
+
const powershell = join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
execFile(powershell, ['-NoLogo', '-NoProfile', '-NonInteractive', '-Command', script], {
|
|
72
|
+
env: { ...process.env, PI_TUCK_STORAGE_PATHS: JSON.stringify(paths) }, windowsHide: true, timeout: 10_000, maxBuffer: 16_384,
|
|
73
|
+
}, error => error ? reject(error) : resolve());
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Create private storage without changing any pre-existing directory's permissions.
|
|
78
|
+
* Callers must still verify existing storage before using it. */
|
|
79
|
+
export async function createPrivateDirectory(directory: string): Promise<void> {
|
|
80
|
+
if (process.platform === 'win32') await runAclCommand(CREATE_DIRECTORY, [directory]);
|
|
81
|
+
else await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Only call for an empty file we just created exclusively inside verified private storage.
|
|
85
|
+
* The recorder retains its handle, protects the file, then verifies it before writing content. */
|
|
86
|
+
export function protectWindowsIncidentFile(path: string): Promise<void> {
|
|
87
|
+
return runAclCommand(PROTECT_FILE, [path]);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Only the current user, SYSTEM and local administrators may receive access.
|
|
91
|
+
* No ACLs are changed: shared/custom storage fails closed before content is written. */
|
|
92
|
+
export function assertWindowsPrivateStorage(paths: readonly string[]): Promise<void> {
|
|
93
|
+
return runAclCommand(CHECK_ACL, paths);
|
|
94
|
+
}
|
package/dist/src/assets.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export interface Download {
|
|
2
|
-
url: string;
|
|
3
|
-
sha256: string;
|
|
4
|
-
size: number;
|
|
5
|
-
}
|
|
6
|
-
/** Where pi-tuck keeps the runtime, its downloads and the indexes: one folder, so deleting it removes all of them. */
|
|
7
|
-
export declare const defaultRoot: () => string;
|
|
8
|
-
/** A relocatable CPython for macOS arm64; the runtime's virtual environment is made from it and keeps pointing at it. */
|
|
9
|
-
export declare const PYTHON: Download & {
|
|
10
|
-
version: string;
|
|
11
|
-
name: string;
|
|
12
|
-
};
|
|
13
|
-
/** EmbeddingGemma-2, 8-bit GGUF. */
|
|
14
|
-
export declare const MODEL: Download;
|
|
15
|
-
/** The model's own tokenizer: passages are split on its token offsets. */
|
|
16
|
-
export declare const TOKENIZER: Download;
|
|
17
|
-
/** llama.cpp release b11476 (commit 988190680d5a). `files` are the server and the libraries it loads from its own folder; the archive
|
|
18
|
-
* names most libraries through symlinks, which the runtime refuses, so each is copied as a plain file under the name the server loads. */
|
|
19
|
-
export declare const LLAMA: Download & {
|
|
20
|
-
folder: string;
|
|
21
|
-
files: Record<string, string>;
|
|
22
|
-
license: string;
|
|
23
|
-
};
|
|
24
|
-
/** The tokenizer library and its declared dependencies, installed offline with hash checking. */
|
|
25
|
-
export declare const WHEELS: Record<string, Download>;
|
|
26
|
-
/** What scripts/eg2-runtime.py checks the runtime against: the model, its encoding contract and the native build. */
|
|
27
|
-
export declare const PINS: {
|
|
28
|
-
embedding: {
|
|
29
|
-
model: string;
|
|
30
|
-
revision: string;
|
|
31
|
-
dimensions: number;
|
|
32
|
-
maxTokens: number;
|
|
33
|
-
queryInstruction: string;
|
|
34
|
-
documentInstruction: string;
|
|
35
|
-
pooling: string;
|
|
36
|
-
dtype: string;
|
|
37
|
-
textOnly: boolean;
|
|
38
|
-
};
|
|
39
|
-
runtime: {
|
|
40
|
-
tokenizers: string;
|
|
41
|
-
python: string;
|
|
42
|
-
};
|
|
43
|
-
backend: {
|
|
44
|
-
name: string;
|
|
45
|
-
commit: string;
|
|
46
|
-
artifact: string;
|
|
47
|
-
computePrecision: string;
|
|
48
|
-
gpuLayers: number;
|
|
49
|
-
compute: string;
|
|
50
|
-
modelRepository: string;
|
|
51
|
-
modelRevision: string;
|
|
52
|
-
modelSHA256: string;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
/** A digest of every pinned input: a changed pin provisions a new runtime beside the old one instead of mutating it. */
|
|
56
|
-
export declare const RUNTIME_ID: string;
|
|
57
|
-
/** The provisioned runtime's configuration, written last by provisioning: its presence means the runtime is complete. */
|
|
58
|
-
export declare const runtimeConfigPath: (root: string) => string;
|
package/dist/src/assets.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// Everything semantic recall's local runtime is built from: a public source and its SHA-256 for each file. setup.ts downloads and
|
|
2
|
-
// verifies these, and a change to any of them gives the runtime a new id, so an update provisions beside the old runtime, never over it.
|
|
3
|
-
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
/** Where pi-tuck keeps the runtime, its downloads and the indexes: one folder, so deleting it removes all of them. */
|
|
7
|
-
export const defaultRoot = () => join(getAgentDir(), "pi-tuck");
|
|
8
|
-
const MODEL_REVISION = "031f0d4b35536f69ab3509d4893c923264fcf253", TOKENIZER_REVISION = "914f7f89142e33e77833254d9c9b90c3cef7303b";
|
|
9
|
-
const LLAMA_COMMIT = "988190680d5a89fce97de3c20df2c2813731fd61";
|
|
10
|
-
/** A relocatable CPython for macOS arm64; the runtime's virtual environment is made from it and keeps pointing at it. */
|
|
11
|
-
export const PYTHON = {
|
|
12
|
-
name: "cpython-3.13.18+20261026", version: "3.13", size: 25394044,
|
|
13
|
-
url: "https://github.com/astral-sh/python-build-standalone/releases/download/20261026/cpython-3.13.18%2B20261026-aarch64-apple-darwin-install_only.tar.gz",
|
|
14
|
-
sha256: "e5af2fde6a937a0e0c795a0c595c4efb70578d57463a2657c819992b9b9acbac",
|
|
15
|
-
};
|
|
16
|
-
/** EmbeddingGemma-2, 8-bit GGUF. */
|
|
17
|
-
export const MODEL = {
|
|
18
|
-
url: `https://huggingface.co/unsloth/embeddinggemma-2-GGUF/resolve/${MODEL_REVISION}/embeddinggemma-2-Q8_0.gguf`,
|
|
19
|
-
sha256: "6f1bd4ac6c5df7444f9cca7ca36cafe6cfa34cd6f49fefb1e0b4be8143aed8bc", size: 309855520,
|
|
20
|
-
};
|
|
21
|
-
/** The model's own tokenizer: passages are split on its token offsets. */
|
|
22
|
-
export const TOKENIZER = {
|
|
23
|
-
url: `https://huggingface.co/google/embeddinggemma-2/resolve/${TOKENIZER_REVISION}/tokenizer.json`,
|
|
24
|
-
sha256: "4d777ef5bdc1aa36227abdfb77c3e49e7b9c892d16e1b6bda41c393504828be4", size: 32170510,
|
|
25
|
-
};
|
|
26
|
-
/** llama.cpp release b11476 (commit 988190680d5a). `files` are the server and the libraries it loads from its own folder; the archive
|
|
27
|
-
* names most libraries through symlinks, which the runtime refuses, so each is copied as a plain file under the name the server loads. */
|
|
28
|
-
export const LLAMA = {
|
|
29
|
-
url: "https://github.com/ggml-org/llama.cpp/releases/download/b11476/llama-b11476-bin-macos-arm64.tar.gz",
|
|
30
|
-
sha256: "577634a1b8a59e8dabe02ba10de1e610be0574dfaf1cf3020e6dd42853ed877e", size: 12012019,
|
|
31
|
-
folder: "llama-b11476",
|
|
32
|
-
files: {
|
|
33
|
-
"llama-server": "1bf5602a2be50097c44282a6ecc63234d94ee8f96d39fd45fed6eff4e74b6b41",
|
|
34
|
-
"libllama-server-impl.dylib": "d699e1d7f0b3d5c63c9e7cd88c50e37c96cbf64802dbcefdc784983565a29608",
|
|
35
|
-
"libllama-common.0.dylib": "e90e6f5bba4ff114f7fb9ed1328171b1c4eceac71ee8923178f5d417310b0d4e",
|
|
36
|
-
"libmtmd.0.dylib": "c87488222bc71275f75da743e8cc628b014b59d051bc0e303c444e96f54762a7",
|
|
37
|
-
"libllama.0.dylib": "423bd595e045f0bb8225ad721571d5ab9842815f1b975f2462d2c7c8e0594bd7",
|
|
38
|
-
"libggml.0.dylib": "85ac40d540a5cc86f28a70270ddcdde677e92eb585c3bacd1b7e82270fe8934b",
|
|
39
|
-
"libggml-cpu.0.dylib": "937073375f79a187d8fda2e3900a9095e979593b691d6bbb146956743ceddd82",
|
|
40
|
-
"libggml-blas.0.dylib": "6526259e8f70a5b3a394df3ba082050c290d7653846efbdc84b3710b22fb4eac",
|
|
41
|
-
"libggml-metal.0.dylib": "a40058fab152c973339e40e80df900c1b311e06bcfb4c1c473cb169c7ee88a5c",
|
|
42
|
-
"libggml-rpc.0.dylib": "48c13b7c2c56e2b569b636e6a28d1c0853ad2d1db1980c0afd374651c6e897d0",
|
|
43
|
-
"libggml-base.0.dylib": "6fba8bb7fb529801d1b73782ac1707b653b1ea4caf53f667b85bc801e2883326",
|
|
44
|
-
},
|
|
45
|
-
license: "94f29bbed6a22c35b992c5c6ebf0e7c92f13b836b90f36f461c9cf2f0f1d010d",
|
|
46
|
-
};
|
|
47
|
-
const pypi = (path, sha256, size) => ({ url: "https://files.pythonhosted.org/packages/" + path, sha256, size });
|
|
48
|
-
/** The tokenizer library and its declared dependencies, installed offline with hash checking. */
|
|
49
|
-
export const WHEELS = {
|
|
50
|
-
"anyio-4.15.1-py3-none-any.whl": pypi("12/b8/4bd346e22b28902df4d651910f5242c28d84e4a5c2435ca5c3f797ed7e2e/anyio-4.15.1-py3-none-any.whl", "6152fdbbf9a77fdec97731721bebf7c4c44f7c29b424b0065826173efc7ed101", 132079),
|
|
51
|
-
"certifi-2026.7.22-py3-none-any.whl": pypi("0b/a7/71ac2cff56fec219ed242bb11b8efb69fcc4bec75db06fb7bfe35de520e6/certifi-2026.7.22-py3-none-any.whl", "62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775", 136983),
|
|
52
|
-
"click-8.5.0-py3-none-any.whl": pypi("58/50/6c0d534c5f134586a8e1ba4e330569e32f057e33372ae556463212fb4cd3/click-8.5.0-py3-none-any.whl", "255bc9599cf7748b4b1a446ccc735421bd08a2ae529a8b88597d3de5664ee360", 125251),
|
|
53
|
-
"filelock-4.0.12-py3-none-any.whl": pypi("da/a1/b047e1c486a2c66283633b7dbb73872ca16ca1ce6a426f70d4d037fc8e1c/filelock-4.0.12-py3-none-any.whl", "5f17ee83ecee8a6f3e389c75822fb70a1c2f0506b99438a6dffa1d56793588c8", 111732),
|
|
54
|
-
"fsspec-2026.9.0-py3-none-any.whl": pypi("6c/c0/a98505f18594f1bce828bb159cec0fcf9860562f1a2c85913409fc8f3d9e/fsspec-2026.9.0-py3-none-any.whl", "8dd6e646e99ea382bd85f97a45e6b526a442d79423a7dc673f1e2756d05fcb5f", 221738),
|
|
55
|
-
"h11-0.16.0-py3-none-any.whl": pypi("04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", "63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", 37515),
|
|
56
|
-
"hf_xet-1.7.0-cp38-abi3-macosx_11_0_arm64.whl": pypi("c3/47/a26ebdce7056a61e931f228439bc0ab08cbec239d1690f965e5e637cba79/hf_xet-1.7.0-cp38-abi3-macosx_11_0_arm64.whl", "59fba37039233c7fcbe196817d6cdcf1b40dfb17b410f229d85b0cf0a1848da4", 3560352),
|
|
57
|
-
"httpcore-1.0.9-py3-none-any.whl": pypi("7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", "2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", 78784),
|
|
58
|
-
"httpx-0.28.1-py3-none-any.whl": pypi("2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", "d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", 73517),
|
|
59
|
-
"huggingface_hub-1.33.0-py3-none-any.whl": pypi("fc/16/963096d224b80909432dc16561a615fd33d2d13beef3ce4c63fa25e40867/huggingface_hub-1.33.0-py3-none-any.whl", "04e434b06e100eddbce9a6e817d72693a7884b10a79bd67ab48080d5c07eb899", 846435),
|
|
60
|
-
"idna-3.20-py3-none-any.whl": pypi("58/a2/bb081bab032533a855d44de1d56f8e8426114ff1ba5d1f07a438a0a654f8/idna-3.20-py3-none-any.whl", "ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c", 69583),
|
|
61
|
-
"packaging-26.3-py3-none-any.whl": pypi("63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", "d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", 129956),
|
|
62
|
-
"pyyaml-6.0.3-cp313-cp313-macosx_11_0_arm64.whl": pypi("b1/16/95309993f1d3748cd644e02e38b75d50cbc0d9561d21f390a76242ce073f/pyyaml-6.0.3-cp313-cp313-macosx_11_0_arm64.whl", "2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1", 173252),
|
|
63
|
-
"tokenizers-0.23.2-cp310-abi3-macosx_11_0_arm64.whl": pypi("67/49/22da045a91732384d3a3771816bf188dc5a1f702c32e635afa7c679c0bef/tokenizers-0.23.2-cp310-abi3-macosx_11_0_arm64.whl", "986670e43691469dcee610ea0f846f91a8f84e91fc6f7a48d4c064414c0ec2bf", 3101593),
|
|
64
|
-
"tqdm-4.70.1-py3-none-any.whl": pypi("a7/03/921a3d3c75785aca9ebfbfcabfbc3a1be12e2ab5265deb026d55a5a3f83e/tqdm-4.70.1-py3-none-any.whl", "c293e525e6fef9c20e8728fd4612df02a0aa31bb5fe91ecd93e123b1b7bffa73", 80199),
|
|
65
|
-
"typing_extensions-4.16.0-py3-none-any.whl": pypi("49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", "481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", 45571),
|
|
66
|
-
};
|
|
67
|
-
/** What scripts/eg2-runtime.py checks the runtime against: the model, its encoding contract and the native build. */
|
|
68
|
-
export const PINS = {
|
|
69
|
-
embedding: { model: "google/embeddinggemma-2", revision: TOKENIZER_REVISION, dimensions: 768, maxTokens: 8192,
|
|
70
|
-
queryInstruction: "task: search result | query: ", documentInstruction: "title: none | text: ",
|
|
71
|
-
pooling: "mask-aware mean including prompt, projected token states, then float32 L2", dtype: "Q8_0", textOnly: true },
|
|
72
|
-
runtime: { tokenizers: "0.23.2", python: PYTHON.version },
|
|
73
|
-
backend: { name: "llama.cpp", commit: LLAMA_COMMIT, artifact: "Q8_0", computePrecision: "float32", gpuLayers: 0,
|
|
74
|
-
compute: "CPU float32 with f32 KV; quantized weights where selected", modelRepository: "unsloth/embeddinggemma-2-GGUF",
|
|
75
|
-
modelRevision: MODEL_REVISION, modelSHA256: MODEL.sha256 },
|
|
76
|
-
};
|
|
77
|
-
/** A digest of every pinned input: a changed pin provisions a new runtime beside the old one instead of mutating it. */
|
|
78
|
-
export const RUNTIME_ID = createHash("sha256").update(JSON.stringify({ PYTHON, MODEL, TOKENIZER, LLAMA, WHEELS, PINS })).digest("hex").slice(0, 16);
|
|
79
|
-
/** The provisioned runtime's configuration, written last by provisioning: its presence means the runtime is complete. */
|
|
80
|
-
export const runtimeConfigPath = (root) => join(root, "runtime", RUNTIME_ID, "semantic-recall.json");
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ExtensionContext } from '@earendil-works/pi-coding-agent';
|
|
2
|
-
import type { RecallPolicy } from './recall.js';
|
|
3
|
-
import { semanticEligibleSources } from './semantic-recall.js';
|
|
4
|
-
type Context = Pick<ExtensionContext, 'sessionManager' | 'cwd'>;
|
|
5
|
-
type Snapshot = ReturnType<typeof semanticEligibleSources>;
|
|
6
|
-
/** The one place that decides when the snapshot stored for a session manager and policy is still the snapshot a rebuild would give, and when `tuck_search` must rerun its lexical offer after its await: Pi entries
|
|
7
|
-
* are append-only, so a new entry changes the entry count, and a branch switch changes the leaf. Change what invalidates it here and nowhere else.
|
|
8
|
-
* The lexical recheck in `tuck_search` relies on the same contract: `tuckRecall` is pure in (entries, branch, input, policy) whenever it returns (its only clock use is a 3 s abort that throws), so an unchanged key across the await means an unchanged
|
|
9
|
-
* lexical offer and the second pass is skipped (`eligibilityKeyMoved`). An entry edited in place
|
|
10
|
-
* after it was appended, a `readAttemptMarker` with hidden state, or a policy mutated after install is outside this contract for both uses. */
|
|
11
|
-
export declare function eligibilityKey(ctx: Context): readonly unknown[];
|
|
12
|
-
/** Whether the session moved since `since` was taken from `eligibilityKey(ctx)`. */
|
|
13
|
-
export declare const eligibilityKeyMoved: (ctx: Context, since: readonly unknown[]) => boolean;
|
|
14
|
-
/** `semanticEligibleSources` for an unchanged session without the rebuild. `access()` runs on every call, hits included, and a throw is
|
|
15
|
-
* the same `SemanticAccessError` that `semanticEligibleSources` raises (the mapping below is that function's first statement, verbatim).
|
|
16
|
-
* The policy is trusted by identity, so it must not change after install: a policy object mutated in place (a type added to
|
|
17
|
-
* `privateCustomTypes`) or a `readAttemptMarker` with hidden state is not noticed until the history changes. */
|
|
18
|
-
export declare function memoizedEligibleSources(ctx: Context, policy: RecallPolicy | undefined, access: () => void, pendingKeptId?: string): Snapshot;
|
|
19
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { semanticEligibleSources } from './semantic-recall.js';
|
|
2
|
-
const cache = new WeakMap();
|
|
3
|
-
/** The one place that decides when the snapshot stored for a session manager and policy is still the snapshot a rebuild would give, and when `tuck_search` must rerun its lexical offer after its await: Pi entries
|
|
4
|
-
* are append-only, so a new entry changes the entry count, and a branch switch changes the leaf. Change what invalidates it here and nowhere else.
|
|
5
|
-
* The lexical recheck in `tuck_search` relies on the same contract: `tuckRecall` is pure in (entries, branch, input, policy) whenever it returns (its only clock use is a 3 s abort that throws), so an unchanged key across the await means an unchanged
|
|
6
|
-
* lexical offer and the second pass is skipped (`eligibilityKeyMoved`). An entry edited in place
|
|
7
|
-
* after it was appended, a `readAttemptMarker` with hidden state, or a policy mutated after install is outside this contract for both uses. */
|
|
8
|
-
export function eligibilityKey(ctx) {
|
|
9
|
-
const manager = ctx.sessionManager;
|
|
10
|
-
return [manager.getSessionId(), ctx.cwd, manager.getLeafId(), manager.getBranch().length, manager.getEntries().length];
|
|
11
|
-
}
|
|
12
|
-
const same = (a, b) => a.length === b.length && a.every((value, i) => Object.is(value, b[i]));
|
|
13
|
-
/** Whether the session moved since `since` was taken from `eligibilityKey(ctx)`. */
|
|
14
|
-
export const eligibilityKeyMoved = (ctx, since) => !same(since, eligibilityKey(ctx));
|
|
15
|
-
/** `semanticEligibleSources` for an unchanged session without the rebuild. `access()` runs on every call, hits included, and a throw is
|
|
16
|
-
* the same `SemanticAccessError` that `semanticEligibleSources` raises (the mapping below is that function's first statement, verbatim).
|
|
17
|
-
* The policy is trusted by identity, so it must not change after install: a policy object mutated in place (a type added to
|
|
18
|
-
* `privateCustomTypes`) or a `readAttemptMarker` with hidden state is not noticed until the history changes. */
|
|
19
|
-
export function memoizedEligibleSources(ctx, policy, access, pendingKeptId) {
|
|
20
|
-
try {
|
|
21
|
-
access();
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
throw Object.assign(new Error(error instanceof Error ? error.message : 'Source access denied'), { name: 'SemanticAccessError' });
|
|
25
|
-
}
|
|
26
|
-
const key = [...eligibilityKey(ctx), pendingKeptId ?? null], held = cache.get(ctx.sessionManager);
|
|
27
|
-
if (held && held.policy === policy && same(held.key, key))
|
|
28
|
-
return { ...held.stored, units: [], complete: false, indexed: new Set() };
|
|
29
|
-
// Access was checked on the line above with nothing awaited in between, so the rebuild does not check it a second time.
|
|
30
|
-
const built = semanticEligibleSources(ctx, policy ?? {}, () => { }, pendingKeptId);
|
|
31
|
-
cache.set(ctx.sessionManager, { policy, key, stored: { id: built.id, session: built.session, project: built.project, sources: built.sources, throughEntryId: built.throughEntryId, viewStart: built.viewStart } });
|
|
32
|
-
return built;
|
|
33
|
-
}
|