@twinsearth/w2m-dsh-plugin 0.24.0 → 0.25.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 +47 -0
- package/package.json +1 -1
- package/src/plugin/tools.mjs +47 -4
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,53 @@ All notable changes to this project are documented here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.25.0] — 2026-10-15
|
|
8
|
+
|
|
9
|
+
**The chain is closed: dispatch → gate → queue → decision. The plugin builds a queue, and an escalation is a real entry an approver can find.**
|
|
10
|
+
|
|
11
|
+
### The queue belongs to the plugin, not to the call
|
|
12
|
+
|
|
13
|
+
`apply()` now constructs **one** `createApprovalIndex()` for the plugin's lifetime, lazily. A queue built at
|
|
14
|
+
the call site would be **empty every time**, so a request raised by one dispatch could never be found by the
|
|
15
|
+
decision that answers it — **it would look wired and behave as if it were not.** Same reasoning as the P2P
|
|
16
|
+
runtime beside it: something that must outlive a single call belongs to the plugin.
|
|
17
|
+
|
|
18
|
+
### Measured, end to end, before it was written down
|
|
19
|
+
|
|
20
|
+
| Step | Result |
|
|
21
|
+
|---|---|
|
|
22
|
+
| an ordinary actor (49) asks to write | `needs_approval`, `enforced: true` |
|
|
23
|
+
| the request is raised | `ok`, id issued, `subjectLevel` **49** |
|
|
24
|
+
| a captain (50) lists the queue | `may_act: true`, `required_level: 50` |
|
|
25
|
+
| a peer (10) lists the same queue | **sees it**, `may_act: false`, `APPROVAL_INSUFFICIENT_AUTHORITY` |
|
|
26
|
+
| the captain settles it | `ok` |
|
|
27
|
+
| after settling | `approved`, **`subjectLevel` still 49** |
|
|
28
|
+
| the requester approves their own request | **`APPROVAL_SELF_APPROVAL`** |
|
|
29
|
+
|
|
30
|
+
The fourth row is the one worth naming: **a peer can see work that is above their authority and is not theirs
|
|
31
|
+
to answer.** A filtered list would make the fleet look idle at the moment it is most blocked.
|
|
32
|
+
|
|
33
|
+
### A queue that refuses is not a queue that needs approval
|
|
34
|
+
|
|
35
|
+
If `raiseApproval` fails, the dispatch is refused with **`W2M_PERMISSION_APPROVAL_NOT_RAISED`**, a different
|
|
36
|
+
code from `W2M_PERMISSION_NEEDS_APPROVAL`. A caller told "await approval" for a request that was never stored
|
|
37
|
+
would **wait forever for a decision nobody can make.**
|
|
38
|
+
|
|
39
|
+
### Still true, and stated rather than glossed
|
|
40
|
+
|
|
41
|
+
The dispatch still **does not run** when approval is required — an escalation is a request to be allowed, not
|
|
42
|
+
a permission. There is **no tool yet for an approver to settle a pending request**; `decide()` exists and is
|
|
43
|
+
exercised by the suite, and wiring it to a tool is the next step. So the chain is closed in code and testable
|
|
44
|
+
end to end, while remaining **unreachable by an operator in the running plugin.**
|
|
45
|
+
|
|
46
|
+
### My probe was wrong before the code was
|
|
47
|
+
|
|
48
|
+
The first end-to-end run threw on `listFor(...).requests.length`. `listFor` returns a **row array**, not an
|
|
49
|
+
object with a `requests` field. **The code was right; my assumption about a shape I had not read was wrong**
|
|
50
|
+
— the fifth time in this project, and the same failure as the parse-prefix mistake early on.
|
|
51
|
+
|
|
52
|
+
**3 new chain tests, 0 failures.**
|
|
53
|
+
|
|
7
54
|
## [0.24.0] — 2026-10-15
|
|
8
55
|
|
|
9
56
|
**The escalation reaches the approval index — and the bridge between them is where the defect would have been.**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twinsearth/w2m-dsh-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "DSH: Windows2MacOS — drive the same project on online Windows and macOS machines from one DeepSeek account, across networks and regions. P2P hole punching is the default path (relay + shared server as rendezvous, ledger and fallback), with a bundled STUN responder, Tailscale/public-VPS/tunnel shapes, Rabbit relay + per-machine Localside + eight DSH tools (replicate / split), nine aggregate verdicts and signed requests.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
package/src/plugin/tools.mjs
CHANGED
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
*/
|
|
90
90
|
|
|
91
91
|
import { execFile } from 'node:child_process';
|
|
92
|
-
import { createHash } from 'node:crypto';
|
|
92
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
93
93
|
import { promises as fs } from 'node:fs';
|
|
94
94
|
import os from 'node:os';
|
|
95
95
|
import path from 'node:path';
|
|
@@ -125,7 +125,10 @@ import { mintPunchId, punchSession } from '../agent/p2p.mjs';
|
|
|
125
125
|
// v0.22.0: the permission gate. Imported rather than reimplemented for the same reason as everything else
|
|
126
126
|
// here -- a second copy of the escalation rule is a second chance to disagree with the first about how far
|
|
127
127
|
// below a requirement an actor may still ask.
|
|
128
|
-
import { gateDispatch, approvalRequestFor } from '../agent/permission.mjs';
|
|
128
|
+
import { gateDispatch, approvalRequestFor, raiseApproval } from '../agent/permission.mjs';
|
|
129
|
+
// v0.24.0: the queue an escalation is raised into. Imported from `src/`, never from `scripts/` -- a
|
|
130
|
+
// `src/` module reaching above itself breaks the published package (see CHANGELOG 0.23.0).
|
|
131
|
+
import { createApprovalIndex } from '../agent/approval-index.mjs';
|
|
129
132
|
import { isAuthorityLevel } from '../agent/authority.mjs';
|
|
130
133
|
// v0.6.0: the device keypair and the offer's key distribution (`docs/P2P-CRYPTO.md` §4). Imported
|
|
131
134
|
// rather than reimplemented: the dispatcher and the executor have to derive the *same* keys, and two
|
|
@@ -190,7 +193,7 @@ const MAX_STAGES = 16;
|
|
|
190
193
|
* `package.json` during `scripts/pack.mjs` rather than hand-maintained, and `W2M_PLUGIN_VERSION`
|
|
191
194
|
* overrides it at runtime for tests and packagers.
|
|
192
195
|
*/
|
|
193
|
-
const PLUGIN_VERSION = '0.
|
|
196
|
+
const PLUGIN_VERSION = '0.25.0';
|
|
194
197
|
|
|
195
198
|
/** How long any single HTTP call may take before it is aborted, in milliseconds. */
|
|
196
199
|
const DEFAULT_REQUEST_TIMEOUT_MS = 15_000;
|
|
@@ -3202,6 +3205,29 @@ export async function apply(ctx, config = {}) {
|
|
|
3202
3205
|
return { machine_id: device.machine_id, machine_name: device.machine_name, machineName: cfg.machineName };
|
|
3203
3206
|
});
|
|
3204
3207
|
|
|
3208
|
+
/**
|
|
3209
|
+
* v0.24.0: the approval queue, one per plugin lifetime.
|
|
3210
|
+
*
|
|
3211
|
+
* ## Why it lives here and not inside the dispatch
|
|
3212
|
+
*
|
|
3213
|
+
* A queue constructed at the call site would be **empty every time**, so a request raised by one dispatch
|
|
3214
|
+
* could never be found by the decision that answers it — the queue would look wired and behave as if it were
|
|
3215
|
+
* not. This is the same reasoning as `p2p` above: something that has to outlive a single call belongs to the
|
|
3216
|
+
* plugin, not to the call.
|
|
3217
|
+
*
|
|
3218
|
+
* Lazy, because a machine that never trips the permission gate should not pay for a queue, and built through
|
|
3219
|
+
* the effect system so a decision still pending at unload does not keep the plugin alive.
|
|
3220
|
+
*/
|
|
3221
|
+
let approvals = null;
|
|
3222
|
+
const approvalQueue = () => {
|
|
3223
|
+
if (approvals === null) {
|
|
3224
|
+
approvals = createApprovalIndex({
|
|
3225
|
+
audit: (event, detail) => ctx.logger?.debug?.(`w2m: ${event} ${JSON.stringify(detail ?? {})}`),
|
|
3226
|
+
});
|
|
3227
|
+
}
|
|
3228
|
+
return approvals;
|
|
3229
|
+
};
|
|
3230
|
+
|
|
3205
3231
|
// v0.6.1: the two browser routes behind the composer's target control. Additive and optional: a
|
|
3206
3232
|
// host without `connection.fetch` still gets every tool, and `w2m_status` reports the absence - // which is the honest place for it, since a host that has no Connection at all is simply not a web
|
|
3207
3233
|
// composition and does not need a warning on every headless run.
|
|
@@ -3725,16 +3751,33 @@ export async function apply(ctx, config = {}) {
|
|
|
3725
3751
|
);
|
|
3726
3752
|
}
|
|
3727
3753
|
if (gate.decision.verdict === 'needs_approval') {
|
|
3754
|
+
// v0.24.0: the request is QUEUED now, not merely refused with a description of a queue. The
|
|
3755
|
+
// dispatch still does not run -- an escalation is a request to be allowed, not a permission --
|
|
3756
|
+
// but the request is a real entry an approver can find and settle, and its id comes back so the
|
|
3757
|
+
// caller can name what it is waiting on.
|
|
3728
3758
|
const request = approvalRequestFor(gate.decision, {
|
|
3729
3759
|
taskId: null,
|
|
3730
3760
|
machineId: null,
|
|
3731
3761
|
requestedBy: cfg.machineName,
|
|
3732
3762
|
});
|
|
3763
|
+
const approvalId = randomUUID();
|
|
3764
|
+
const raised = raiseApproval(approvalQueue(), request, { approvalId, toolName: 'w2m_run' });
|
|
3765
|
+
if (!raised.ok) {
|
|
3766
|
+
// The queue refused it, which is a different failure from needing approval and must not be
|
|
3767
|
+
// reported as one: a caller told "await approval" for a request that was never stored would wait
|
|
3768
|
+
// forever for a decision nobody can make.
|
|
3769
|
+
throw new W2MError(
|
|
3770
|
+
'W2M_PERMISSION_APPROVAL_NOT_RAISED',
|
|
3771
|
+
'W2M_PERMISSION_APPROVAL_NOT_RAISED: ' + raised.reason_code + ': ' + raised.detail,
|
|
3772
|
+
{ hint: 'the approval request could not be queued, so this dispatch is refused rather than left waiting', request },
|
|
3773
|
+
);
|
|
3774
|
+
}
|
|
3733
3775
|
throw new W2MError(
|
|
3734
3776
|
'W2M_PERMISSION_NEEDS_APPROVAL',
|
|
3735
3777
|
'W2M_PERMISSION_NEEDS_APPROVAL: ' + gate.decision.detail,
|
|
3736
3778
|
{
|
|
3737
|
-
hint: 'this dispatch
|
|
3779
|
+
hint: 'this dispatch is queued awaiting an approver; approve or reject it with w2m_approvals, then dispatch again',
|
|
3780
|
+
approval_id: raised.approval_id,
|
|
3738
3781
|
request,
|
|
3739
3782
|
},
|
|
3740
3783
|
);
|