session-peer 0.3.6 → 0.5.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.
Files changed (52) hide show
  1. package/CONTRIBUTING.md +6 -4
  2. package/PARITY.md +431 -6
  3. package/README.ja.md +14 -8
  4. package/README.ko.md +14 -8
  5. package/README.md +14 -8
  6. package/README.zh-CN.md +14 -8
  7. package/RELEASING.md +109 -0
  8. package/VALIDATION.md +806 -1
  9. package/dist/app-server.d.ts +207 -0
  10. package/dist/app-server.js +1044 -0
  11. package/dist/cli.js +229 -39
  12. package/dist/handoff-ledger.d.ts +103 -0
  13. package/dist/handoff-ledger.js +791 -0
  14. package/dist/handoff-observer-probe.d.ts +1 -0
  15. package/dist/handoff-observer-probe.js +170 -0
  16. package/dist/handoff-operations.d.ts +29 -0
  17. package/dist/handoff-operations.js +496 -0
  18. package/dist/handoff-writer-probe.d.ts +1 -0
  19. package/dist/handoff-writer-probe.js +146 -0
  20. package/dist/handoff.d.ts +112 -0
  21. package/dist/handoff.js +261 -0
  22. package/dist/help.js +18 -0
  23. package/dist/linux-native-probe.d.ts +1 -0
  24. package/dist/linux-native-probe.js +51 -0
  25. package/dist/linux-proc.d.ts +55 -0
  26. package/dist/linux-proc.js +150 -0
  27. package/dist/metadata-observation.d.ts +49 -0
  28. package/dist/metadata-observation.js +250 -0
  29. package/dist/native-profiles.d.ts +25 -0
  30. package/dist/native-profiles.js +62 -0
  31. package/dist/output.js +7 -1
  32. package/dist/process.d.ts +28 -0
  33. package/dist/process.js +284 -2
  34. package/dist/protocol.d.ts +2 -2
  35. package/dist/protocol.js +1 -1
  36. package/dist/send.d.ts +18 -1
  37. package/dist/send.js +91 -6
  38. package/dist/skill-metadata.js +7 -4
  39. package/dist/ssh-response.d.ts +11 -0
  40. package/dist/ssh-response.js +78 -2
  41. package/dist/ssh.d.ts +2 -1
  42. package/dist/ssh.js +37 -2
  43. package/dist/windows.d.ts +28 -0
  44. package/dist/windows.js +149 -1
  45. package/docs/api.md +255 -4
  46. package/docs/design/typescript-skill-compatibility.md +55 -2
  47. package/docs/guide.ja.md +36 -16
  48. package/docs/guide.ko.md +39 -19
  49. package/docs/guide.md +46 -20
  50. package/docs/guide.zh-CN.md +36 -16
  51. package/docs/shorthand.md +1 -1
  52. package/package.json +2 -2
package/dist/ssh.d.ts CHANGED
@@ -15,7 +15,8 @@ export type SshJump = {
15
15
  };
16
16
  export declare function sshJump(value: string): SshJump;
17
17
  export declare function proxyCommand(ssh: string, jump: SshJump): string;
18
- export declare function jumpOptions(ssh: string, jump: SshJump): string[];
18
+ export declare function windowsProxyCommand(ssh: string, jump: SshJump, env?: NodeJS.ProcessEnv): string;
19
+ export declare function jumpOptions(ssh: string, jump: SshJump, platform?: NodeJS.Platform): string[];
19
20
  export declare function sshConfig(ssh: string, destination: string, options: SshOptions, force?: boolean): Promise<{
20
21
  user: SshUser;
21
22
  read: boolean;
package/dist/ssh.js CHANGED
@@ -81,11 +81,46 @@ export function proxyCommand(ssh, jump) {
81
81
  '-o', 'ClearAllForwardings=yes', '-o', 'PermitLocalCommand=no', ...(jump.port ? ['-p', jump.port] : []), '-l', jump.user,
82
82
  '-W', "'[%h]:%p'", '--', jump.host].join(' ');
83
83
  }
84
+ // Win32-OpenSSH has no shell step (PowerShell/openssh-portable source; the spawn
85
+ // path reads the same in the four inspected revisions v8.1.0.0, v9.5.0.0,
86
+ // v10.0.0.0 and latestw_all d0c65f2, which is source provenance, not a test of
87
+ // them): readconf.c keeps the raw value and, except in v8.1.0.0, argv_split()s
88
+ // it first and rejects unbalanced quotes; sshconnect.c
89
+ // percent-expands "exec %s", skips "exec " and posix_spawnp()s the whole string
90
+ // as argv[0] with no arguments; misc.c build_commandline_string() passes a string
91
+ // that starts with '"' unchanged to CreateProcessW(NULL, ...) (w32fd.c, which
92
+ // then also skips its unquoted-name retry). No cmd.exe runs, so %VAR%, ^, & and |
93
+ // are inert; the ssh.exe UCRT splits the line once more. Only an absolute drive
94
+ // path ending in \ssh.exe without '"', ':' or wildcard characters is accepted:
95
+ // it is the quoted program name (read up to the next '"', no escapes), and every
96
+ // other argument is a fixed or validated token without spaces, quotes or
97
+ // backslashes, so no MSVCRT escaping is needed. "[%h]:%p" is double-quoted where
98
+ // POSIX single-quotes it; %h from a configured HostName stays the same trusted
99
+ // ssh_config boundary. SSH_TEST_ENVIRONMENT makes Win32-OpenSSH rewrite the
100
+ // path (bash_to_win_path): upstream checks atoi(value). This builder refuses
101
+ // when Number.parseInt(value, 10) is truthy; that is not a general emulation of
102
+ // C atoi, and non-ASCII, locale and overflow behavior is unqualified.
103
+ // An isolated no-connection probe with the real Win32-OpenSSH 9.5p1 ssh.exe and
104
+ // an argv-dump hop matched this exactly (VALIDATION). Not enabled: a connected
105
+ // hop and owned-process-tree cleanup of the hop grandchild are unqualified (#20,
106
+ // #131; see cli.ts).
107
+ export function windowsProxyCommand(ssh, jump, env = process.env) {
108
+ if (ssh.length > 4096 || /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/.test(ssh) ||
109
+ !/^[A-Za-z]:\\(?:[^\x00-\x1f\x7f"*:<>?|/\\]+\\)*ssh\.exe$/i.test(ssh))
110
+ throw new Refusal('ssh_jump_unsupported_ssh_path');
111
+ if (Number.parseInt(env.SSH_TEST_ENVIRONMENT ?? '', 10))
112
+ throw new Refusal('ssh_jump_unsupported_environment');
113
+ return [`"${ssh.replace(/%/g, '%%')}"`, '-T', '-o', 'BatchMode=yes', '-o', 'StrictHostKeyChecking=yes', '-o', 'UpdateHostKeys=no', '-o', 'ConnectTimeout=10',
114
+ '-o', 'ConnectionAttempts=1', '-o', 'ProxyCommand=none', '-o', 'ProxyJump=none', '-o', 'ControlPath=none', '-o', 'ForwardAgent=no',
115
+ '-o', 'ClearAllForwardings=yes', '-o', 'PermitLocalCommand=no', ...(jump.port ? ['-p', jump.port] : []), '-l', jump.user,
116
+ '-W', '"[%h]:%p"', '--', jump.host].join(' ');
117
+ }
84
118
  // Outer options for a jump: a configured ControlMaster/ControlPath could reuse
85
119
  // an existing master and bypass the hop, and ProxyUseFdpass would change how the
86
120
  // proxy hands over its connection, so all three are fixed before user options.
87
- export function jumpOptions(ssh, jump) {
88
- return ['-o', 'ControlMaster=no', '-o', 'ControlPath=none', '-o', 'ProxyUseFdpass=no', '-o', `ProxyCommand=${proxyCommand(ssh, jump)}`];
121
+ export function jumpOptions(ssh, jump, platform = process.platform) {
122
+ const command = platform === 'win32' ? windowsProxyCommand(ssh, jump) : proxyCommand(ssh, jump);
123
+ return ['-o', 'ControlMaster=no', '-o', 'ControlPath=none', '-o', 'ProxyUseFdpass=no', '-o', `ProxyCommand=${command}`];
89
124
  }
90
125
  // Like Python, ask OpenSSH which login user applies without connecting. With
91
126
  // `force`, `ssh -G` also runs for an explicit user so the caller can see a
package/dist/windows.d.ts CHANGED
@@ -9,3 +9,31 @@ export declare const START_PROBE_TIMEOUT_MS = 15000;
9
9
  export declare function inspectWindows(mode: 'identity' | 'openers', value: string): WindowsProcess[];
10
10
  export declare function windowsProcessStart(pid: number): bigint | undefined;
11
11
  export declare function postWindowsPipe(pipe: string, pid: number, text: string): Promise<void>;
12
+ export type WindowsAce = {
13
+ sid: string;
14
+ allow: boolean;
15
+ rights: number;
16
+ inherited: boolean;
17
+ inherits: boolean;
18
+ };
19
+ export type WindowsStorageEntry = {
20
+ path: string;
21
+ exists: boolean;
22
+ directory?: boolean;
23
+ reparse?: boolean;
24
+ owner?: string;
25
+ protected?: boolean;
26
+ nullDacl?: boolean;
27
+ rules?: WindowsAce[];
28
+ };
29
+ export type WindowsStorageReport = {
30
+ user: string;
31
+ tokenOwner: string;
32
+ entries: WindowsStorageEntry[];
33
+ };
34
+ export type WindowsStorageFailure = 'path_unsupported' | 'inspection_failed' | 'missing' | 'reparse_point' | 'not_directory' | 'not_file' | 'owner_mismatch' | 'acl_missing' | 'acl_inherited' | 'acl_broad';
35
+ export declare function windowsAncestors(path: string): string[] | undefined;
36
+ export declare function windowsStorageFailure(report: WindowsStorageReport, kind: 'directory' | 'file'): WindowsStorageFailure | undefined;
37
+ export declare function inspectWindowsStorage(path: string): WindowsStorageReport;
38
+ export declare function verifyWindowsPrivate(path: string, kind: 'directory' | 'file', inspect?: typeof inspectWindowsStorage): void;
39
+ export declare function createWindowsPrivateDirectory(path: string, inspect?: typeof inspectWindowsStorage): void;
package/dist/windows.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { readdirSync, readFileSync, lstatSync } from 'node:fs';
2
- import { join } from 'node:path';
2
+ import { join, win32 } from 'node:path';
3
3
  import { createConnection } from 'node:net';
4
4
  import { spawnSync } from 'node:child_process';
5
5
  import { Refusal } from './discovery.js';
@@ -197,3 +197,151 @@ export async function postWindowsPipe(pipe, pid, text) {
197
197
  });
198
198
  });
199
199
  }
200
+ const storageScript = String.raw `
201
+ $ErrorActionPreference = 'Stop'
202
+ $sid = [Security.Principal.SecurityIdentifier]
203
+ $identity = [Security.Principal.WindowsIdentity]::GetCurrent()
204
+ $user = $identity.User.Value; $tokenOwner = $identity.Owner.Value
205
+ $entries = @()
206
+ foreach ($path in $paths) {
207
+ $item = Get-Item -LiteralPath $path -Force -ErrorAction SilentlyContinue
208
+ if (!$item) { $entries += @{path=$path; exists=$false}; continue }
209
+ $entry = @{path=$path; exists=$true; directory=[bool]$item.PSIsContainer; reparse=[bool]($item.Attributes -band [IO.FileAttributes]::ReparsePoint)}
210
+ if (!$entry.reparse -and $path -eq $paths[-1]) {
211
+ $acl = $item.GetAccessControl([Security.AccessControl.AccessControlSections]'Owner, Access')
212
+ $entry.owner = $acl.GetOwner($sid).Value
213
+ $entry.protected = [bool]$acl.AreAccessRulesProtected
214
+ $entry.nullDacl = [bool]($acl.GetSecurityDescriptorSddlForm([Security.AccessControl.AccessControlSections]::Access) -match 'D:NO_ACCESS_CONTROL')
215
+ $entry.rules = @($acl.GetAccessRules($true, $true, $sid) | ForEach-Object { @{sid=$_.IdentityReference.Value;
216
+ allow=($_.AccessControlType -eq 'Allow'); rights=[int64]$_.FileSystemRights; inherited=[bool]$_.IsInherited;
217
+ inherits=($_.InheritanceFlags -ne [Security.AccessControl.InheritanceFlags]::None)} })
218
+ }
219
+ $entries += $entry
220
+ }
221
+ [Console]::Out.Write((ConvertTo-Json -InputObject @{user=$user; tokenOwner=$tokenOwner; entries=@($entries)} -Compress -Depth 5))
222
+ `;
223
+ // Every component from the drive root to the leaf, for reparse checks. UNC,
224
+ // device (\\?\, \\.\) and relative paths are not private-storage candidates.
225
+ export function windowsAncestors(path) {
226
+ if (!/^[A-Za-z]:\\/.test(path) || /[\0\r\n]/.test(path) || path.split(/[\\/]/).some(part => part === '..' || part === '.'))
227
+ return undefined;
228
+ const parts = win32.normalize(path).replace(/\\+$/, '').split('\\');
229
+ return parts.map((_, index) => index ? parts.slice(0, index + 1).join('\\') : parts[0] + '\\');
230
+ }
231
+ const sidPattern = /^S-1-[0-9]+(?:-[0-9]+){1,14}$/;
232
+ function storageReport(value, paths) {
233
+ const report = value;
234
+ if (!report || typeof report !== 'object' || typeof report.user !== 'string' || !sidPattern.test(report.user) ||
235
+ typeof report.tokenOwner !== 'string' || !sidPattern.test(report.tokenOwner) ||
236
+ !Array.isArray(report.entries) || report.entries.length !== paths.length)
237
+ return undefined;
238
+ for (const [index, entry] of report.entries.entries()) {
239
+ if (!entry || entry.path !== paths[index] || typeof entry.exists !== 'boolean')
240
+ return undefined;
241
+ if (!entry.exists)
242
+ continue;
243
+ if (typeof entry.directory !== 'boolean' || typeof entry.reparse !== 'boolean')
244
+ return undefined;
245
+ if (entry.reparse || index !== paths.length - 1)
246
+ continue;
247
+ if (typeof entry.owner !== 'string' || !sidPattern.test(entry.owner) || typeof entry.protected !== 'boolean' ||
248
+ typeof entry.nullDacl !== 'boolean' || !Array.isArray(entry.rules) || entry.rules.length > 256 ||
249
+ entry.rules.some(rule => !rule || typeof rule.sid !== 'string' || !sidPattern.test(rule.sid) || typeof rule.allow !== 'boolean' ||
250
+ !Number.isSafeInteger(rule.rights) || typeof rule.inherited !== 'boolean' || typeof rule.inherits !== 'boolean'))
251
+ return undefined;
252
+ }
253
+ return report;
254
+ }
255
+ // The leaf must be owned by the current user SID or the token's default owner
256
+ // (an elevated administrator's new files are owned by Administrators; measured
257
+ // on Windows 10 x64). A group owner is a weaker boundary: every member of that
258
+ // group may rewrite the DACL, so this is not an owner-only guarantee for an
259
+ // elevated administrator, and the non-administrator cell is unverified. Every
260
+ // allow ACE, inherited
261
+ // or inheritable included, must name that SID; a directory's DACL must be
262
+ // protected from its parent. No component may be a reparse point (symlink,
263
+ // junction, mount point or other tag), checked by attribute, not lstat.
264
+ export function windowsStorageFailure(report, kind) {
265
+ const entries = report.entries, leaf = entries.at(-1);
266
+ if (!leaf)
267
+ return 'inspection_failed';
268
+ if (entries.some(entry => entry.exists && entry.reparse))
269
+ return 'reparse_point';
270
+ if (!leaf.exists || entries.some(entry => !entry.exists))
271
+ return 'missing';
272
+ if (kind === 'directory' ? !leaf.directory : leaf.directory)
273
+ return kind === 'directory' ? 'not_directory' : 'not_file';
274
+ if (leaf.owner !== report.user && leaf.owner !== report.tokenOwner)
275
+ return 'owner_mismatch';
276
+ if (leaf.nullDacl)
277
+ return 'acl_missing';
278
+ if (leaf.rules.some(rule => rule.allow && rule.sid !== report.user))
279
+ return 'acl_broad';
280
+ if (kind === 'directory' && (!leaf.protected || leaf.rules.some(rule => rule.inherited)))
281
+ return 'acl_inherited';
282
+ return undefined;
283
+ }
284
+ export function inspectWindowsStorage(path) {
285
+ if (process.platform !== 'win32')
286
+ throw new Refusal('windows_inspection_unavailable', 1);
287
+ const paths = windowsAncestors(path);
288
+ if (!paths)
289
+ throw new Refusal('handoff_storage_untrusted', 1);
290
+ const encoded = Buffer.from(JSON.stringify(paths), 'utf8').toString('base64');
291
+ // PowerShell 5.1 emits a JSON array as one object; cast, do not wrap in @().
292
+ const code = `$paths = [string[]](ConvertFrom-Json ([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${encoded}'))))\ntry {\n${storageScript}\n} catch { exit 1 }`;
293
+ const done = spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
294
+ '$script = [Console]::In.ReadToEnd(); Invoke-Expression $script'], { input: code, encoding: 'utf8', timeout: START_PROBE_TIMEOUT_MS, maxBuffer: 1024 * 1024, windowsHide: true });
295
+ if (done.status !== 0 || done.error)
296
+ throw new Refusal('windows_owner_inspection_failed', 1);
297
+ let report;
298
+ try {
299
+ report = storageReport(JSON.parse(done.stdout), paths);
300
+ }
301
+ catch { /* Rejected below. */ }
302
+ if (!report)
303
+ throw new Refusal('windows_owner_inspection_failed', 1);
304
+ return report;
305
+ }
306
+ // Fails closed with handoff_storage_untrusted; the specific failure is not
307
+ // surfaced because it would describe local ACL layout.
308
+ export function verifyWindowsPrivate(path, kind, inspect = inspectWindowsStorage) {
309
+ if (windowsStorageFailure(inspect(path), kind))
310
+ throw new Refusal('handoff_storage_untrusted', 1);
311
+ }
312
+ // Creates only a new leaf under an existing reparse-free parent, owned by the
313
+ // current user with a protected DACL granting that user alone, inherited by its
314
+ // contents; the whole chain is inspected again afterwards. Precheck, creation
315
+ // and postcheck are separate steps, not one atomic operation: someone able to
316
+ // write the parent can race them, and only the postcheck can reject the result.
317
+ export function createWindowsPrivateDirectory(path, inspect = inspectWindowsStorage) {
318
+ if (process.platform !== 'win32')
319
+ throw new Refusal('handoff_storage_unsupported', 1);
320
+ const paths = windowsAncestors(path);
321
+ if (!paths || paths.length < 2)
322
+ throw new Refusal('handoff_storage_untrusted', 1);
323
+ if (inspect(paths.at(-2)).entries.some(entry => !entry.exists || entry.reparse))
324
+ throw new Refusal('handoff_storage_untrusted', 1);
325
+ const encoded = Buffer.from(paths.at(-1), 'utf8').toString('base64');
326
+ const code = `
327
+ $ErrorActionPreference = 'Stop'
328
+ try {
329
+ $path = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${encoded}'))
330
+ if (Test-Path -LiteralPath $path) { exit 3 }
331
+ if (!(Test-Path -LiteralPath ([IO.Path]::GetDirectoryName($path)) -PathType Container)) { exit 4 }
332
+ $user = [Security.Principal.WindowsIdentity]::GetCurrent().User
333
+ $security = New-Object Security.AccessControl.DirectorySecurity
334
+ $security.SetOwner($user)
335
+ $security.SetAccessRuleProtection($true, $false)
336
+ $security.AddAccessRule((New-Object Security.AccessControl.FileSystemAccessRule($user, 'FullControl', 'ContainerInherit, ObjectInherit', 'None', 'Allow')))
337
+ [void][IO.Directory]::CreateDirectory($path, $security)
338
+ } catch { exit 1 }
339
+ `;
340
+ const done = spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
341
+ '$script = [Console]::In.ReadToEnd(); Invoke-Expression $script'], { input: code, encoding: 'utf8', timeout: START_PROBE_TIMEOUT_MS, maxBuffer: 65536, windowsHide: true });
342
+ if (done.status === 3)
343
+ throw new Refusal('handoff_ledger_exists', 1);
344
+ if (done.status !== 0 || done.error)
345
+ throw new Refusal('handoff_storage_untrusted', 1);
346
+ verifyWindowsPrivate(paths.at(-1), 'directory', inspect);
347
+ }
package/docs/api.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # API reference
2
2
 
3
- This reference describes source/package version **0.3.6**. Check registry availability and review the selected release before installation. Dated release evidence is recorded in [VALIDATION.md](../VALIDATION.md); before publication use a reviewed source artifact.
3
+ This reference describes source/package version **0.5.0**. Check registry availability and review the selected release before installation. Dated release evidence is recorded in [VALIDATION.md](../VALIDATION.md); before publication use a reviewed source artifact.
4
4
 
5
5
  [Back to README](../README.md) · [User guide](guide.md)
6
6
 
7
7
  The package exposes a small ESM API with TypeScript declarations. Install it
8
- locally with `npm install --ignore-scripts session-peer@0.3.6` before importing it.
8
+ locally with `npm install --ignore-scripts session-peer@0.5.0` before importing it.
9
9
  Importing the package does not execute the CLI or submit a message.
10
10
 
11
11
  ```js
12
12
  import { VERSION, VERSION_LINE, reply, envelope } from 'session-peer';
13
13
 
14
- console.log(VERSION); // 0.3.6
15
- console.log(VERSION_LINE); // session-peer 0.3.6 (typescript)
14
+ console.log(VERSION); // 0.5.0
15
+ console.log(VERSION_LINE); // session-peer 0.5.0 (typescript)
16
16
  const address = 'session-peer://v1/reply?agent=claude&session=12345&transport=local';
17
17
  console.log(reply(address)); // { to: '12345' }
18
18
  console.log(envelope('Please review and reply.', true, address));
@@ -33,3 +33,254 @@ not package subpath exports. Use the [CLI guide](guide.md#use) for sending and
33
33
 
34
34
 
35
35
  The ordinary SSH response correction is documented separately as the [0.3.3 ordinary SSH response correction](design/ordinary-ssh-responses.md); its internal parser is not a package-root export.
36
+
37
+ <a id="unreleased-opt-in-handoff-cli--040-work"></a>
38
+
39
+ ## Opt-in handoff CLI — 0.4.0
40
+
41
+ 0.4.0 includes an explicit private POSIX sender ledger. Default sends retain
42
+ their native status, optional fields and exit behavior. The frozen design is tracked in #69;
43
+ this implementation does not change its exact vendored document or fixture.
44
+
45
+ Initialize once with `session-peer handoff init --json`. The optional absolute
46
+ `SESSION_PEER_HANDOFF_HOME` selects its directory; commands never auto-initialize
47
+ missing or corrupt history. `handoff prepare --to TARGET --message-file FILE
48
+ --json` reserves a fresh correlation ID without sending. Use a private regular
49
+ UTF-8 file (POSIX mode 0600), then pass the retained ID with
50
+ `send --correlation-id UUID --message-file FILE --json`. A changed destination,
51
+ original generation or message binding is rejected. An unknown supplied ID is
52
+ not accepted. Ordinary opted-in sends can automatically prepare a fresh ID.
53
+
54
+ Only opted-in results add `handoff`. The inert correlation metadata in a native
55
+ message is not authentication. Durable intent is fenced before native effect;
56
+ crash recovery, `handoff status`, `handoff wait`, `ack` and `handoff confirm`
57
+ never submit again. Retention/quota limits preserve epoch-bound fences rather
58
+ than evicting old authority. Clone/rollback protection assumes intact, retained,
59
+ non-rolled-back history. Native local/SSH retry permission remains false.
60
+
61
+ Keep `ledger.key` with the private ledger: the journal stores an authenticated
62
+ encrypted message-binding digest, using that separate mode-0600 key. The raw
63
+ digest is not stored in the journal. Missing, changed or untrusted keys and old
64
+ plaintext journals fail closed; commands do not regenerate a key or migrate
65
+ history automatically. This does not protect against a same-user reader who
66
+ can obtain both files. Lost history never authorizes resubmission.
67
+
68
+ `--request-ack`, `--observe-delivery` and `--wait-for delivered|acknowledged`
69
+ select separate evidence goals. A required unsupported goal refuses before
70
+ submission; best-effort mode may submit while reporting the channel unsupported.
71
+ `--wait-timeout` is an ASCII integer 1..60 (default 30); its total operation
72
+ budget includes a 5-second cleanup reserve. Budgets 1..5 are syntactically valid
73
+ but cannot authorize an effect. A successful submission is preserved when
74
+ subsequent ledger/evidence operations fail. Best-effort sends keep their native
75
+ success exit and may add `handoffWarning: persistence_failed`; required waits
76
+ fail without erasing independently established native submission facts. No body, transcript, raw native
77
+ stderr, payload digest or receipt secret appears in handoff JSON.
78
+
79
+ Automated receipt producer/bootstrap, Windows ledger and original-sender SSH
80
+ receipt collectors remain unsupported. `ack --receipt -` and `handoff confirm
81
+ --receipt -` consume at most 4096 raw UTF-8 bytes from private stdin; no receipt
82
+ secret is accepted in argv/URI/environment. Receipt ACK means receipt only, not
83
+ ownership, completed work or permission to act. Operator confirmation is
84
+ explicitly labeled and must match retained original context. No arbitrary
85
+ message/transcript scan manufactures ACK. Ordinary generated Reply-To stays v1.
86
+
87
+
88
+ <a id="unreleased-destination-side-ssh-handoff"></a>
89
+
90
+ ### Destination-side SSH handoff
91
+
92
+ POSIX opt-in `send --host HOST` performs an exact-version preflight and a
93
+ no-effect preparation before one destination-side send. Both ends must contain
94
+ the same reviewed 0.5.0 implementation. This workflow was introduced in
95
+ 0.4.0; a 0.3.x banner does not establish the capability. Initialize the destination's private ledger explicitly; no command
96
+ auto-installs a handler or initializes missing history. The origin does not
97
+ create a local receipt collector. Reconcile with `handoff status`/`wait` on the
98
+ destination that owns the retained intent, without another send.
99
+
100
+ Preparation fixes the canonical destination target/home, original generation,
101
+ epoch and correlation ID. A supplied ID must already be unattempted/prepared
102
+ there. Fanout uses a distinct ID per destination, is limited to 32 destinations,
103
+ and rejects one caller-supplied ID for multiple hosts. An incomplete preparation
104
+ refuses before effect. After a possible effect, partial/malformed/oversized
105
+ responses remain unknown and are never replayed. Complete request-matched native
106
+ facts survive SSH 255/timeout; malformed optional handoff cannot create ACK or
107
+ erase separately valid submission facts. Ordinary opt-out discards unsolicited
108
+ handoff/query/warning fields.
109
+
110
+ The origin retains its original monotonic deadline. Each private request carries
111
+ only remaining duration, repeated in a private numeric argv selector. The
112
+ destination establishes its input timeout and owned-process cleanup watchdog
113
+ before reading the frame, requires the two durations to match, and charges
114
+ normal Node bootstrap/frame-read time to the same budget. An indefinitely blocked
115
+ static import before handler startup is outside this in-process watchdog; the
116
+ origin still has its own hard transport deadline. Transit delay is
117
+ not measurable across independent monotonic clocks: this is not a synchronized
118
+ cross-host cutoff guarantee. The source deadline is never renewed, and 5 seconds
119
+ of cleanup reserve remain inside each per-destination budget. Fake-SSH fixtures
120
+ exercise the actual destination handler and a recording socket, including the
121
+ watchdog's group cleanup; they do not constitute an actual network SSH or remote
122
+ native-agent qualification.
123
+
124
+ Each fanout destination starts its own total budget; sequential fanout can take
125
+ up to the sum of those budgets (at most 32 × 60 seconds), rather than one shared
126
+ invocation deadline. No setup, preparation or wait renews a destination's
127
+ deadline. Transport loss can return unknown before a delayed destination effect
128
+ has finished; it is not evidence of non-delivery and never authorizes a retry.
129
+
130
+ Original-sender ACK collector/bootstrap and Windows SSH handoff remain
131
+ unsupported. Required acknowledged wait refuses before submission; best-effort
132
+ request-ack reports unsupported. Destination-native observation retains the
133
+ same exact Codex version/platform/home/generation gates as local observation.
134
+
135
+
136
+ <a id="unreleased-bounded-app-server-mechanics--040-work"></a>
137
+
138
+ ## Bounded app-server mechanics — 0.4.0
139
+
140
+ `dist/app-server.js` is an internal opt-in module, not a new public package
141
+ export or a change to ordinary CLI submission. `nativeQueueOnce` requires an
142
+ absolute executable, exact home/thread/original generation, bounded owner
143
+ verifier and durable `beforeEffect` callback. Exact Codex 0.160.1 and 0.162.1
144
+ queue mechanics were tested on macOS arm64 in network-denied synthetic homes;
145
+ other platform or version tuples fail before an effect. There is no minor-range
146
+ or latest-version inference. The caller owns proof of original
147
+ writer/home and any resources used by its verifier.
148
+
149
+ Only initialize, initialized and one thread/queue/add are used. Queue receipt
150
+ returns IDs only. Body-returning observation APIs, transcript reading, resume,
151
+ wake and new model turns are not implemented. The native process is an owned
152
+ queue transport, not an inferred existing session owner. Possible write marks
153
+ outcome uncertain even when the subsequent response is malformed. No automatic
154
+ fallback follows a possible effect. Fixture-only metadata ports are not native
155
+ observation qualification. See [source evidence](../PARITY.md#unreleased-bounded-app-server-foundation--71).
156
+
157
+ The 0.162.1 qualification uses source `092d3acd6bec3e3a14bdc7e7a2810ab628ab759d`
158
+ and generated schema hashes, with all 84 native notifications opted out before
159
+ the effect (0.160.1 retains its exact 83-method list). A saved synthetic thread
160
+ remained unloaded before and after one queue request; its own echoed input and
161
+ queue/thread/client IDs were checked. A separate native API fixture verified
162
+ owned SQLite descriptor binding and durable-guard refusal with zero queue rows.
163
+ Neither fixture proves a live writer's generation, actual delivery, receipt ACK
164
+ or a body-free native observer. Linux and Windows native mechanics remain
165
+ unqualified. The initial qualification harness had echo-shape and temporary-home
166
+ mapping failures; each subsequent probe used a distinct home/thread/client ID,
167
+ and no attempted submission was replayed. Details are retained in the
168
+ `test/fixtures/app-server-schema-evidence.json` source fixture.
169
+
170
+
171
+ The queue-only SDK pins both environment and CLI SQLite home, then verifies
172
+ opened state/queue DB paths on its OWN native app-server PID before authorizing
173
+ the effect. Config precedes the environment and exact managed requirements can
174
+ supersede the CLI in the qualified versions, so initialize's home echo alone is insufficient.
175
+ Missing/mismatched descriptor proof refuses without queue/fallback. Direct
176
+ native binaries are qualified; launcher wrappers without this PID/storage proof
177
+ remain unsupported. Native bootstrap may create state/cache files according to
178
+ managed policy before binding refusal; zero queue is the guarantee, not zero
179
+ bootstrap filesystem activity. Observers still open only read-only warm stores.
180
+
181
+
182
+ <a id="unreleased-local-delivery-observation--72"></a>
183
+
184
+ ## Local delivery observation — #72
185
+
186
+ A narrower qualified source path combines #71 queue mechanics with a warm
187
+ Codex 0.160.1 or 0.162.1 metadata store on macOS arm64. `--observe-delivery` checks once
188
+ (best effort); `--wait-for delivered` polls within the original remaining
189
+ budget. The native client ID is the reserved correlation ID. A positive native
190
+ receipt remains `status: queued`, `submitted: true`, `consumptionConfirmed:
191
+ false` even when the explicit wait fails. The separate handoff describes the
192
+ requested evidence goal. After any possible RPC write, no legacy fallback or
193
+ second submission occurs.
194
+
195
+ Selection is by the exact host platform/architecture and native version.
196
+ The 0.5.0 source records a Linux arm64 Codex 0.162.1 candidate (pinned musl
197
+ executable, procfs storage binding, `/proc/locks` writer-owner check) but does
198
+ not activate it. Linux and any other unlisted platform/version have no
199
+ profile, so required delivery refuses before effect and best-effort uses the
200
+ ordinary queue.
201
+
202
+ Before an opted-in native effect, original saved thread/home/writer evidence,
203
+ default SQLite storage, exact native version and a warm supported metadata
204
+ schema are checked. Required unsupported observation refuses before effect.
205
+ Best-effort chooses legacy queue only if qualification failed before any native
206
+ app-server attempt. The sender fences its intent durably before queue/add.
207
+ A fresh queue transport is not treated as the owner of another process's thread.
208
+
209
+ The observer never reads rollouts or calls history, queue/list, thread/resume,
210
+ turn/start or full item/turn notification APIs. SQLite itself projects only
211
+ `clientId`, thread/turn IDs and an allowlisted status. Recent row keys are bounded
212
+ to 256; cells over 256 KiB are excluded before JSON extraction. Temporary SQLite
213
+ storage is memory-only and materializes keys/bounded scalars. Body/error columns
214
+ are never returned to JavaScript. SQLite internally evaluates body-bearing
215
+ `item_json` cells to project metadata; this is not a guarantee that message-body
216
+ bytes are never accessed inside the SQLite engine. Only an already-warm original store is used;
217
+ there is no migration, warm-up/backfill, new model turn or wake. Existing WAL/SHM
218
+ must already be trusted; SQLite read-only readers can participate in transient
219
+ SHM read locks. DB/WAL bytes and sidecar creation remain unchanged in fixtures.
220
+
221
+ File/schema/inode checks and queries run in owned deadline-bounded children.
222
+ An inherited-group owner verifier compares the ORIGINAL selected fingerprint
223
+ before/after each read. Wrong client ID, schema drift, owner restart or an
224
+ ambiguous row cannot advance delivery. Unknown native turn statuses remain
225
+ unknown. Queue deletion or turn completion alone never creates injection/ACK.
226
+ Each wait keeps its own operation ID/cutoff and immutable terminal record;
227
+ concurrent later waits do not replace the originating send's result. An explicit
228
+ SIGINT-stopped wait returns exit 130 when its matching stopped record is proven,
229
+ retaining independently known submission facts and never retracting/resending.
230
+
231
+ `handoff wait --correlation-id UUID --wait-for delivered` starts a new operation
232
+ over a retained, positively submitted intent. Native observation is read-only;
233
+ the operation persists private wait/terminal records. It preserves the original
234
+ home/thread/writer generation and private, exact version/source/platform
235
+ qualification. Missing qualification is unsupported; today's PATH or matching
236
+ schema never reconstructs it. A new wait has its own cutoff and never rewrites
237
+ an old terminal wait. Other processes' pending waits remain untouched and each
238
+ owner classifies its own deadline. No native executable, queue request, transcript
239
+ API or model turn is started by status/wait. Ledger contention is retried only
240
+ inside the existing total budget. A persistence failure returns the last verified
241
+ operation and known submission facts with `handoff_persistence_failed`; it does
242
+ not claim that a terminal record was written.
243
+
244
+ Qualification boundaries: the combined native CLI route is macOS arm64/Codex
245
+ 0.160.1 or 0.162.1, each with an exact pinned source profile. Dedicated new
246
+ 0.162.1 TUI sessions demonstrated one native queue attempt and exact client-ID
247
+ injection in the original thread/home using bounded metadata projections.
248
+ Synthetic tests separately cover independent-process resume, timeout, SIGINT,
249
+ concurrent waits, owner change and persistence failure. Neither completion nor
250
+ visible response establishes machine ACK. A separate voluntary matching reply
251
+ was explicitly recorded with `handoff confirm --receipt -` before any wait:
252
+ `operator_confirmed`, retained ACK and a later acknowledged wait succeeded.
253
+ A prior test that started a delivered wait before confirmation correctly refused
254
+ unprovable cross-process ordering; its intent was not resubmitted. This is manual
255
+ operator attestation, not automatic token-possession receipt collection. Dedicated Claude Code 2.1.296 tests
256
+ confirmed correlated socket delivery and best-effort ACK remaining unsupported;
257
+ a required unsupported ACK refused before posting.
258
+
259
+ The qualified native app-server queue/observation route is unsupported on
260
+ Linux/Windows. Ordinary Codex queue submission and explicit operator confirmation
261
+ on supported POSIX ledgers are separate capabilities, demonstrated by the KR/US
262
+ checks in VALIDATION. Windows private ledger and automated receipt
263
+ collector/bootstrap remain unsupported. Other native versions are not
264
+ inferred from a minor range. The original-sender SSH collector is not provided.
265
+ These source checks do not by themselves establish package publication or
266
+ a completed milestone. Exact evidence and limits are in [VALIDATION](../VALIDATION.md).
267
+
268
+
269
+
270
+
271
+
272
+ <a id="040-candidate-scope"></a>
273
+
274
+ ## 0.4.0 implementation scope
275
+
276
+ The 0.5.0 source preserves this supported handoff scope; its Linux and Windows
277
+ groundwork does not enable additional platform or ACK support.
278
+
279
+ The 0.4.0 implementation includes the qualified macOS arm64 observer and explicit
280
+ `operator_confirmed` receipts on supported POSIX ledgers. Other platforms do not
281
+ inherit that qualification. Linux observation [#130](https://github.com/abruption/session-peer-ts/issues/130),
282
+ Windows observation/private storage [#131](https://github.com/abruption/session-peer-ts/issues/131) and
283
+ voluntary receipt producer/authenticated collector bootstrap [#132](https://github.com/abruption/session-peer-ts/issues/132)
284
+ are future extensions. An automatic collector would still require an explicit
285
+ receiver receipt; it must never infer ACK from messages or turn completion.
286
+ Unsupported required goals refuse before effect; no post-attempt fallback or resend.
@@ -2,7 +2,60 @@
2
2
 
3
3
  This document retains the original TS source proposal and dated design review for [#118](https://github.com/abruption/session-peer-ts/issues/118), based on the companion [Draft #20 at `963c3d7`](https://github.com/abruption/session-peer-skill/blob/963c3d748a11b1164013ee26c9c0ef285c52b285/docs/typescript-compatibility.md). Companion [design acceptance at `699a325`](https://github.com/abruption/session-peer-skill/blob/699a3251830c30c62d0f812363faf4d0eb0c8e0c/docs/typescript-compatibility.md) records the full static review of the exact candidates below on 2026-10-09. This design-only acceptance does not authorize runtime merge/release, successor skill metadata/publication, installation or pin changes, content authenticity, or live delivery support.
4
4
 
5
- ## 0.3.6 finite row
5
+ ## 0.5.0 finite row — release preparation
6
+
7
+ The 0.5.0 source candidate explicitly carries forward the same four exact skill
8
+ profiles as public 0.4.0: 0.1.0, 0.2.0, 0.2.1 and 0.3.0. The 0.3.0 profile
9
+ retains its `runtime-min-version: 0.1.0`, `runtime-full-version: 0.4.0`,
10
+ `runtime-implementation: typescript` and `runtime-capability-policy: probe-help`;
11
+ there is no new skill metadata or range-based acceptance. Compiled/default,
12
+ explicit `undefined`, explicit 0.5.0 and outer `inspectSkill` use that finite row.
13
+ Historical rows, parser/reader behavior, mismatch/unknown envelopes and the
14
+ immutable complete-file review fixtures stay unchanged. Unreviewed 0.5.1 and
15
+ 0.6.0 identities remain incompatible, while malformed runtime identities remain
16
+ unknown with no verification field. Compatibility remains `metadata_only`, not
17
+ content authentication, feature qualification, send permission or ACK evidence.
18
+
19
+ This source change does not establish npm publication or install/update a skill.
20
+ The four-language guidance continues to use the published skill 0.2.1 source
21
+ `0f494cabd05901c03161dc91792dcf89f8e96631` and SHA-256
22
+ `8c3520f95e0d6807303be96bfa06df69887ddaf76be05f1905505d0a956820c3`.
23
+ Acceptance of the existing 0.3.0 metadata profile does not adopt a new installation
24
+ pin. Linux/Windows native observation and automatic ACK support are unaffected.
25
+
26
+ ## Public 0.4.0 guard verification — 2026-10-18 KST
27
+
28
+ The public 0.4.0 tarball from source
29
+ `dde3923efe116f87f38b1639b29b889d2b832e44` has verified registry integrity
30
+ `sha512-mMNJ118atoflhpFTkf2+DtO7MRf7FQnPK3lKWbq/vd8Xvb5DsjUtAgydIBOcd3Xj9BCYGqM50aFhzUr4dDGHSw==`.
31
+ An isolated, version-specific npm installation ran its actual bundled pure
32
+ validator against published skill 0.2.1 and the complete companion Draft #37
33
+ candidate at `a969260cd511b7b81631884ff856edaf0d0d457b` (22,973 raw UTF-8 bytes,
34
+ SHA-256 `7571c79fb7ac164002daf0bf3aa7c5ba40ca8d99f5610a04d7860eee7b27df68`).
35
+ Compiled default, explicit undefined, explicit 0.4.0 and outer `inspectSkill`
36
+ returned exactly compatible/skill_contract_compatible/metadata_only. Historical
37
+ 0.3.2–0.3.6 identities rejected the new profile, and unreviewed 0.3.7/0.4.1
38
+ identities remained incompatible. Supplying a historical identity to this new
39
+ helper is not execution of a historical CLI.
40
+
41
+ These are bounded metadata checks: candidate instructions were not executed,
42
+ and no native delivery, model or ACK test was added. The isolated installation
43
+ was removed. The candidate remains a separately approved skill-publication
44
+ step, not an installed skill or adopted pin. Existing published 0.2.1 source
45
+ and hash remain unchanged. The earlier fixture/checkpoint records below retain
46
+ their original exact bytes and scope.
47
+
48
+ ## 0.4.0 finite row
49
+
50
+ TS source/package 0.4.0 preserves the three reviewed profiles accepted by public 0.3.6 (skill 0.1.0, 0.2.0 and published 0.2.1) and adds exactly `0.3.0 / typescript / min 0.1.0 / full 0.4.0 / probe-help` for runtime 0.4.0 only. Compiled default, explicit `undefined`, explicit 0.4.0 and outer `inspectSkill` use this finite row. All historical runtime/profile verdicts remain unchanged; old runtime identities reject the new profile, and 0.3.7, 0.4.1 and other unreviewed runtime identities remain incompatible. Parser/reader behavior and malformed/unsupported envelopes are unchanged. This is a finite row, not a SemVer range or a skill publication.
51
+
52
+ ### Exact companion 0.3.0 candidate review — 2026-10-18 KST
53
+
54
+ The complete companion [Draft PR #37 checkpoint `b8ff909ffc5fe1e5b22c66a5c302be8332a76038`](https://github.com/abruption/session-peer-skill/blob/b8ff909ffc5fe1e5b22c66a5c302be8332a76038/docs/candidates/session-peer-ts-0.3.0.md) is retained as `test/fixtures/ts-skill-0.3.0-candidate.md`: **20,162 raw UTF-8 bytes**, SHA-256 `1ae3690cb5d03777bf448cf06496fed27e4a9329deb03741d6d956a3b13c5ed4`. Exact-content review found no normative blocker and accepted this profile direction at design level only. The helper fixtures check exact bytes/hash, fatal UTF-8, compiled default/undefined/explicit 0.4.0 and outer inspection, with historical, future and malformed runtime rejection. The fixture is excluded from the npm package and its instructions are never executed by these checks.
55
+
56
+ This is candidate-specific design/content review, not approval to install or publish the skill. The retained candidate still names its older feature checkpoint and review-only status; that source text is not evidence that its final guidance has been reviewed against the eventual published runtime. After actual supporting-runtime publication, final skill content and metadata require a fresh exact-head/whole-byte review and separate human publication approval. Runtime publication does not publish or install a skill. Existing four-language guidance retains the published 0.2.1 immutable source/hash below until a separately approved skill release is actually public; only then may a later guidance change adopt its immutable pin.
57
+
58
+ ## 0.3.6 finite row — historical checkpoint
6
59
 
7
60
  TS source/package 0.3.6 explicitly carries the same three reviewed skill profiles as public 0.3.5: 0.1.0, 0.2.0 and published 0.2.1. The immutable 0.2.1 source/hash below are unchanged. Default/undefined/outer inspection use compiled VERSION=0.3.6; an explicit 0.3.5 helper still returns its historical reviewed verdict. 0.3.7 and other unreviewed identities remain incompatible. Parser/reader behavior and all malformed/unsupported envelopes remain unchanged; this is an explicit finite row, not a SemVer range or a new skill release.
8
61
 
@@ -18,7 +71,7 @@ The published bytes are retained as an offline guidance fixture, distinct from t
18
71
 
19
72
  The skill repository tag, Python skill revision, TS skill revision, and npm runtime version are independent. `runtime-min-version` describes the skill's baseline CLI compatibility floor; `runtime-full-version` describes its documented published CLI feature coverage reference. Neither is a security recommendation, a doctor-acceptance rule, permission to send, or evidence of platform/native compatibility. Optional operations still need their actual resolved TS executable's version/help and prerequisites.
20
73
 
21
- The published 0.3.4 checkpoint at [`afed4a5a8945012faf1b23d52cffecb70470a5b3`](https://github.com/abruption/session-peer-ts/tree/afed4a5a8945012faf1b23d52cffecb70470a5b3) has the following finite runtime/profile matrix. The current 0.3.6 source/package row is documented above; the dated 0.3.5 successor rollout below is historical and does not change that immutable published artifact:
74
+ The published 0.3.4 checkpoint at [`afed4a5a8945012faf1b23d52cffecb70470a5b3`](https://github.com/abruption/session-peer-ts/tree/afed4a5a8945012faf1b23d52cffecb70470a5b3) has the following finite runtime/profile matrix. The 0.4.0 candidate row and historical 0.3.6 row are documented above; the dated 0.3.5 successor rollout below is historical and does not change that immutable published artifact:
22
75
 
23
76
  | Inspecting runtime | Skill version | Implementation | Minimum | Full | Policy | Verdict |
24
77
  |---|---|---|---|---|---|---|