instar 1.3.142 → 1.3.143
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/dist/server/machineAuth.d.ts +8 -2
- package/dist/server/machineAuth.d.ts.map +1 -1
- package/dist/server/machineAuth.js +28 -2
- package/dist/server/machineAuth.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +2 -2
- package/upgrades/1.3.143.md +44 -0
- package/upgrades/side-effects/machineauth-shared-sequence.md +60 -0
|
@@ -46,16 +46,22 @@ export interface SignedHeaders {
|
|
|
46
46
|
'X-Sequence': string;
|
|
47
47
|
'X-Signature': string;
|
|
48
48
|
}
|
|
49
|
+
/** The next process-global machineAuth sequence (strictly increasing). */
|
|
50
|
+
export declare function nextMachineAuthSequence(): number;
|
|
49
51
|
/**
|
|
50
52
|
* Sign an outgoing request with machine credentials.
|
|
51
53
|
*
|
|
52
54
|
* @param machineId - This machine's ID
|
|
53
55
|
* @param privateKeyPem - Ed25519 private key in PEM format
|
|
54
56
|
* @param body - The request body (will be JSON stringified for hashing)
|
|
55
|
-
* @param
|
|
57
|
+
* @param _legacySequence - IGNORED. Retained for signature compatibility with
|
|
58
|
+
* existing callers. The sequence is now drawn from the process-global
|
|
59
|
+
* `nextMachineAuthSequence()` so every channel shares one monotonic counter
|
|
60
|
+
* (see the note above — per-caller counters collided on the receiver's
|
|
61
|
+
* per-machine watermark). New callers may omit it.
|
|
56
62
|
* @returns Headers to include in the request
|
|
57
63
|
*/
|
|
58
|
-
export declare function signRequest(machineId: string, privateKeyPem: string, body: unknown,
|
|
64
|
+
export declare function signRequest(machineId: string, privateKeyPem: string, body: unknown, _legacySequence?: number): SignedHeaders;
|
|
59
65
|
export interface Challenge {
|
|
60
66
|
/** Random 32-byte challenge, hex-encoded */
|
|
61
67
|
challenge: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"machineAuth.d.ts","sourceRoot":"","sources":["../../src/server/machineAuth.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,8DAA8D;IAC9D,QAAQ,IAAI,SAAS;IAUrB;;;OAGG;IACH,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAatC,mCAAmC;IACnC,OAAO,CAAC,OAAO;IASf,8BAA8B;IAC9B,OAAO,IAAI,IAAI;CAGhB"}
|
|
@@ -105,16 +105,42 @@ export function machineAuthMiddleware(deps) {
|
|
|
105
105
|
next();
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Process-global monotonic sequence for ALL machineAuth-signed outbound requests.
|
|
110
|
+
*
|
|
111
|
+
* The receiver's NonceStore tracks ONE monotonic sequence PER SENDING MACHINE
|
|
112
|
+
* (src/core/NonceStore.ts) — so EVERY signed channel from this process (lease
|
|
113
|
+
* broadcast, machine heartbeat, handoff, reply-marker, live-tail, …) MUST draw
|
|
114
|
+
* from a single shared counter. They previously each used their own
|
|
115
|
+
* `Date.now()`-seeded counter; the fast-firing heartbeat pushed the receiver's
|
|
116
|
+
* per-machine watermark high while the slow lease counter stayed low, so every
|
|
117
|
+
* lease broadcast was rejected as an out-of-order replay and the standby never
|
|
118
|
+
* learned the holder (found live 2026-05-31:
|
|
119
|
+
* `Sequence 1780200440053 <= last seen 1780200440744`). Seeding from `Date.now()`
|
|
120
|
+
* keeps it monotonic across a process restart (wall-clock only advances), so the
|
|
121
|
+
* receiver's persisted watermark from a prior run is never above our fresh seed.
|
|
122
|
+
*/
|
|
123
|
+
let __machineAuthSequence = Date.now();
|
|
124
|
+
/** The next process-global machineAuth sequence (strictly increasing). */
|
|
125
|
+
export function nextMachineAuthSequence() {
|
|
126
|
+
__machineAuthSequence += 1;
|
|
127
|
+
return __machineAuthSequence;
|
|
128
|
+
}
|
|
108
129
|
/**
|
|
109
130
|
* Sign an outgoing request with machine credentials.
|
|
110
131
|
*
|
|
111
132
|
* @param machineId - This machine's ID
|
|
112
133
|
* @param privateKeyPem - Ed25519 private key in PEM format
|
|
113
134
|
* @param body - The request body (will be JSON stringified for hashing)
|
|
114
|
-
* @param
|
|
135
|
+
* @param _legacySequence - IGNORED. Retained for signature compatibility with
|
|
136
|
+
* existing callers. The sequence is now drawn from the process-global
|
|
137
|
+
* `nextMachineAuthSequence()` so every channel shares one monotonic counter
|
|
138
|
+
* (see the note above — per-caller counters collided on the receiver's
|
|
139
|
+
* per-machine watermark). New callers may omit it.
|
|
115
140
|
* @returns Headers to include in the request
|
|
116
141
|
*/
|
|
117
|
-
export function signRequest(machineId, privateKeyPem, body,
|
|
142
|
+
export function signRequest(machineId, privateKeyPem, body, _legacySequence) {
|
|
143
|
+
const sequence = nextMachineAuthSequence();
|
|
118
144
|
const timestamp = Math.floor(Date.now() / 1000).toString();
|
|
119
145
|
const nonce = crypto.randomBytes(16).toString('hex');
|
|
120
146
|
const bodyHash = crypto.createHash('sha256')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"machineAuth.js","sourceRoot":"","sources":["../../src/server/machineAuth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAyB1D,uEAAuE;AAEvE;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAqB;IACzD,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;QAC/D,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,cAAc,CAAuB,CAAC;QACpE,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAuB,CAAC;QACnE,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAuB,CAAC;QAC3D,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,CAAuB,CAAC;QACjE,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAuB,CAAC;QAEnE,iCAAiC;Q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AC/C,IAAI,GAAG,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;gBAC9B,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IAED,8BAA8B;IAC9B,OAAO;QACL,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./builtin-manifest.schema.json",
|
|
3
3
|
"schemaVersion": 1,
|
|
4
|
-
"generatedAt": "2026-05-31T04:
|
|
5
|
-
"instarVersion": "1.3.
|
|
4
|
+
"generatedAt": "2026-05-31T04:44:08.984Z",
|
|
5
|
+
"instarVersion": "1.3.143",
|
|
6
6
|
"entryCount": 193,
|
|
7
7
|
"entries": {
|
|
8
8
|
"hook:session-start": {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Upgrade Guide — vNEXT
|
|
2
|
+
|
|
3
|
+
<!-- bump: patch -->
|
|
4
|
+
|
|
5
|
+
## What Changed
|
|
6
|
+
|
|
7
|
+
**Multi-machine: fixes the next bug blocking cross-machine session transfer.**
|
|
8
|
+
When two machines talk, each message carries an ever-increasing number so the
|
|
9
|
+
receiver can reject replayed old messages. A machine has several lines of
|
|
10
|
+
communication to its peer (the in-charge lease, the heartbeat, handoffs, the live
|
|
11
|
+
tail), and each kept its own number seeded from the clock — so they drifted apart.
|
|
12
|
+
The receiver only tracks one highest-number-seen per machine, so the fast
|
|
13
|
+
heartbeat pushed that number high and the quieter lease line's messages then
|
|
14
|
+
looked out-of-order and were dropped as replays. The standby machine therefore
|
|
15
|
+
never received the lease announcement and refused to take over a conversation.
|
|
16
|
+
This change makes every line on a machine share ONE ever-increasing number from a
|
|
17
|
+
single chokepoint, so legitimate messages are never mistaken for replays. The
|
|
18
|
+
receiver's replay protection (unique tokens + a 30-second freshness window + the
|
|
19
|
+
per-machine number) is unchanged. Single-machine agents are unaffected.
|
|
20
|
+
|
|
21
|
+
## What to Tell Your User
|
|
22
|
+
|
|
23
|
+
If you run on one machine, nothing changes. If you run one agent across two
|
|
24
|
+
machines, this fixes a hidden issue where the second machine was silently dropping
|
|
25
|
+
the messages that tell it which machine is in charge — a step toward moving a
|
|
26
|
+
conversation between machines working end to end. Nothing to configure.
|
|
27
|
+
|
|
28
|
+
## Summary of New Capabilities
|
|
29
|
+
|
|
30
|
+
| Capability | How to Use |
|
|
31
|
+
|-----------|-----------|
|
|
32
|
+
| Shared machine-auth sequence | Automatic. All of a machine's signed peer requests now share one monotonic sequence, so the lease/heartbeat/handoff/live-tail channels no longer collide on the receiver's per-machine replay watermark. No configuration. |
|
|
33
|
+
|
|
34
|
+
## Evidence
|
|
35
|
+
|
|
36
|
+
- `tests/unit/machine-auth.test.ts` (21) updated to the new chokepoint contract,
|
|
37
|
+
plus a regression: two channels signing via signRequest stay strictly monotonic
|
|
38
|
+
(no cross-transport collision), and a direct NonceStore stale-sequence-rejection
|
|
39
|
+
test (receiver behavior preserved).
|
|
40
|
+
- `tests/integration/machine-routes.test.ts` (23) green — no sequence regression.
|
|
41
|
+
- `tsc --noEmit` + repo lint clean.
|
|
42
|
+
- Live evidence that motivated it: the standby's security log showed
|
|
43
|
+
"Sequence …053 <= last seen …744" rejecting every lease broadcast.
|
|
44
|
+
- Side-effects: `upgrades/side-effects/machineauth-shared-sequence.md`.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Side-Effects Review — machineAuth shared monotonic sequence
|
|
2
|
+
|
|
3
|
+
**Version / slug:** `machineauth-shared-sequence`
|
|
4
|
+
**Date:** `2026-05-31`
|
|
5
|
+
**Author:** `echo`
|
|
6
|
+
**Second-pass reviewer:** `not required`
|
|
7
|
+
|
|
8
|
+
## Summary of the change
|
|
9
|
+
|
|
10
|
+
`signRequest` (the single function every machineAuth-signed outbound request flows
|
|
11
|
+
through) now assigns the X-Sequence from a process-global monotonic counter
|
|
12
|
+
(`nextMachineAuthSequence()`, seeded from `Date.now()`) instead of the per-caller
|
|
13
|
+
`sequence` argument (now ignored). Fixes the cross-transport replay collision: the
|
|
14
|
+
receiver tracks one monotonic sequence per sending machine, but each channel had
|
|
15
|
+
its own `Date.now()`-seeded counter, so a lower-seeded channel (the lease
|
|
16
|
+
broadcast) was rejected as out-of-order forever.
|
|
17
|
+
|
|
18
|
+
## Decision-point inventory
|
|
19
|
+
|
|
20
|
+
1. **signRequest sequence source** → always `nextMachineAuthSequence()` (global,
|
|
21
|
+
monotonic), regardless of the passed arg.
|
|
22
|
+
|
|
23
|
+
## 1. Over-block
|
|
24
|
+
|
|
25
|
+
**What legitimate inputs does this reject?** None — it makes MORE requests succeed.
|
|
26
|
+
Previously-rejected legitimate lease broadcasts now pass. The receiver's replay
|
|
27
|
+
defenses are unchanged: nonce uniqueness + 30s timestamp window + per-machine
|
|
28
|
+
monotonic sequence all still run. A genuine replay (reused nonce, or stale
|
|
29
|
+
timestamp, or a sequence below the watermark) is still rejected exactly as before.
|
|
30
|
+
|
|
31
|
+
## 2. Under-block
|
|
32
|
+
|
|
33
|
+
**What does this still miss?** Nothing new. Anti-replay strength is unchanged; the
|
|
34
|
+
fix only makes a single sender's many channels share one monotonic sequence
|
|
35
|
+
(which is what the per-machine watermark always assumed). Cross-MACHINE replay is
|
|
36
|
+
still caught (each machine has its own watermark on the receiver).
|
|
37
|
+
|
|
38
|
+
## 3. Blast radius
|
|
39
|
+
|
|
40
|
+
- `signRequest` is used by every machineAuth sender: lease broadcast, heartbeat,
|
|
41
|
+
handoff, reply-marker, live-tail, MessageRouter relay, and the `instar pair`/
|
|
42
|
+
handoff CLI. ALL now share the global counter — this is the intended fix (the
|
|
43
|
+
chokepoint guarantees no caller can bypass it).
|
|
44
|
+
- The per-caller sequence counters in server.ts / MessageRouter become inert
|
|
45
|
+
(their value is ignored); left in place to minimize churn — harmless dead args.
|
|
46
|
+
- Tests: `machine-auth.test.ts` (21) updated to the new contract + a regression
|
|
47
|
+
for the interleaved-channel monotonicity + a direct NonceStore stale-rejection
|
|
48
|
+
test. `machine-routes.test.ts` integration (23) green. tsc + lint clean.
|
|
49
|
+
|
|
50
|
+
## 4. Rollback
|
|
51
|
+
|
|
52
|
+
Pure code (no migration/config/schema). Rollback = revert the PR. The sequence
|
|
53
|
+
reverts to per-caller, re-introducing the collision (so don't revert without
|
|
54
|
+
re-introducing bug #3).
|
|
55
|
+
|
|
56
|
+
## 5. Failure modes
|
|
57
|
+
|
|
58
|
+
- Process restart → counter re-seeds from the new (higher) `Date.now()`, still
|
|
59
|
+
above any prior watermark. Monotonic across restarts by construction.
|
|
60
|
+
- Concurrency → single-threaded JS; `nextMachineAuthSequence` increments atomically.
|