@apnex/network-adapter 0.1.9 → 0.1.10
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/build-info.json
CHANGED
|
@@ -74,6 +74,17 @@ export interface ToolSurfaceReconcilerDeps {
|
|
|
74
74
|
* (this IS the level; F1). null when no cache file exists.
|
|
75
75
|
*/
|
|
76
76
|
readServedRevision: () => string | null;
|
|
77
|
+
/**
|
|
78
|
+
* idea-465 — opt into the CONSUMER-OWNED emit-only level. When true (the pi HCAP
|
|
79
|
+
* shim), `readServedRevision()` returns the consumer's last-SUCCESSFULLY-applied
|
|
80
|
+
* revision (advanced ONLY after its async apply succeeds); the emit-only path uses
|
|
81
|
+
* it directly as the level — a pure trigger with NO internal emit-dedup latch, so a
|
|
82
|
+
* failed refresh leaves served behind and re-emits (retries) rather than masking.
|
|
83
|
+
* Absent/false ⇒ the legacy emit-only latch (a STATIC host-enumerated served marker
|
|
84
|
+
* or null, with the internal latch for emit-dedup — hosts that re-enumerate on emit,
|
|
85
|
+
* e.g. opencode / the S2b oracle). Repair-capable hosts (claude) ignore this.
|
|
86
|
+
*/
|
|
87
|
+
consumerOwnedLevel?: boolean;
|
|
77
88
|
/** Emit `notifications/tools/list_changed` to the host (BEST-EFFORT; clause 3). */
|
|
78
89
|
emitListChanged: () => void;
|
|
79
90
|
/**
|
|
@@ -105,13 +116,17 @@ export declare class ToolSurfaceReconciler {
|
|
|
105
116
|
private readonly deps;
|
|
106
117
|
/**
|
|
107
118
|
* The emit baseline/marker: the revision we last emitted `list_changed` for
|
|
108
|
-
* (repair path) OR the seeded baseline (emit-only
|
|
109
|
-
* the REPAIR path this is ONLY emit-dedup and is NEVER the convergence
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
119
|
+
* (repair path) OR the seeded baseline (LEGACY emit-only latch). mission-106 (F1):
|
|
120
|
+
* in the REPAIR path this is ONLY emit-dedup and is NEVER the convergence decision
|
|
121
|
+
* — convergence there is `readServedRevision() === live` (a real disk read, every
|
|
122
|
+
* pass). idea-465: an emit-only host with an ASYNC apply (e.g. the pi HCAP shim)
|
|
123
|
+
* opts into `consumerOwnedLevel` + provides `readServedRevision()` (its CONSUMER's
|
|
124
|
+
* last-successfully-applied revision), so the level is that served revision, NOT
|
|
125
|
+
* this latch (see the emit-only branch). This latch is emit-dedup ONLY for legacy
|
|
126
|
+
* emit-only hosts (opencode / the S2b oracle) that re-enumerate on emit — safe there
|
|
127
|
+
* because there is no async apply behind it. An advance-on-emit latch for an
|
|
128
|
+
* async-apply host WOULD mask a failed refresh as converged until the next revision
|
|
129
|
+
* bump — exactly what idea-465 fixed.
|
|
115
130
|
*/
|
|
116
131
|
private appliedRevision;
|
|
117
132
|
private consecutiveRepairFailures;
|
|
@@ -51,13 +51,17 @@ export class ToolSurfaceReconciler {
|
|
|
51
51
|
deps;
|
|
52
52
|
/**
|
|
53
53
|
* The emit baseline/marker: the revision we last emitted `list_changed` for
|
|
54
|
-
* (repair path) OR the seeded baseline (emit-only
|
|
55
|
-
* the REPAIR path this is ONLY emit-dedup and is NEVER the convergence
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
54
|
+
* (repair path) OR the seeded baseline (LEGACY emit-only latch). mission-106 (F1):
|
|
55
|
+
* in the REPAIR path this is ONLY emit-dedup and is NEVER the convergence decision
|
|
56
|
+
* — convergence there is `readServedRevision() === live` (a real disk read, every
|
|
57
|
+
* pass). idea-465: an emit-only host with an ASYNC apply (e.g. the pi HCAP shim)
|
|
58
|
+
* opts into `consumerOwnedLevel` + provides `readServedRevision()` (its CONSUMER's
|
|
59
|
+
* last-successfully-applied revision), so the level is that served revision, NOT
|
|
60
|
+
* this latch (see the emit-only branch). This latch is emit-dedup ONLY for legacy
|
|
61
|
+
* emit-only hosts (opencode / the S2b oracle) that re-enumerate on emit — safe there
|
|
62
|
+
* because there is no async apply behind it. An advance-on-emit latch for an
|
|
63
|
+
* async-apply host WOULD mask a failed refresh as converged until the next revision
|
|
64
|
+
* bump — exactly what idea-465 fixed.
|
|
61
65
|
*/
|
|
62
66
|
appliedRevision = null;
|
|
63
67
|
consecutiveRepairFailures = 0;
|
|
@@ -126,12 +130,35 @@ export class ToolSurfaceReconciler {
|
|
|
126
130
|
}
|
|
127
131
|
return { emitted: false, live, repaired: false, converged: false };
|
|
128
132
|
}
|
|
129
|
-
// ── EMIT-ONLY fallback (no repair authority / no on-disk cache
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
//
|
|
133
|
+
// ── EMIT-ONLY fallback (no repair authority / no on-disk cache). ──
|
|
134
|
+
//
|
|
135
|
+
// idea-465 — CONSUMER-OWNED LEVEL (F1) for hosts that opt in (consumerOwnedLevel).
|
|
136
|
+
// `readServedRevision()` is the CONSUMER's last-SUCCESSFULLY-applied Hub revision,
|
|
137
|
+
// advanced ONLY after its async apply (fetch→applyConfig) succeeds. Read fresh
|
|
138
|
+
// every pass, it IS the level — a PURE TRIGGER with NO internal latch: emit
|
|
139
|
+
// whenever live !== served, converge only when the consumer has actually caught
|
|
140
|
+
// up. A failed/kept-prior refresh (fetch throw / poison-guard-empty / blip) leaves
|
|
141
|
+
// served BEHIND → re-emit next tick → retry → converge. This closes the
|
|
142
|
+
// premature-advance where the old latch moved to `live` on emit — BEFORE the async
|
|
143
|
+
// refresh resolved — so a failed refresh masked a stale surface as converged until
|
|
144
|
+
// the next Hub revision bump (pi's PRIMARY redeploy-propagation path; the fetch can
|
|
145
|
+
// blip right after a Hub reboot). The pi HCAP shim wires this via
|
|
146
|
+
// HubSpecSource.getLastAppliedRevision. (served may be null pre-first-apply → live
|
|
147
|
+
// !== null → emit → the emit triggers the refresh that records it.)
|
|
148
|
+
if (this.deps.consumerOwnedLevel) {
|
|
149
|
+
if (live !== served) {
|
|
150
|
+
this.log(`[tool-surface-reconcile] ${reason}: drift served=${served ?? "none"} → live=${live} — emitting tools/list_changed (consumer applies + advances)`);
|
|
151
|
+
this.safeEmit(reason);
|
|
152
|
+
return { emitted: true, live, repaired: false, converged: false };
|
|
153
|
+
}
|
|
154
|
+
return { emitted: false, live, repaired: false, converged: true };
|
|
155
|
+
}
|
|
156
|
+
// ── Legacy emit-only latch (consumerOwnedLevel absent — opencode / the S2b
|
|
157
|
+
// oracle). `readServedRevision` is a STATIC host-enumerated marker (or null) and
|
|
158
|
+
// the host RE-ENUMERATES on emit, so the internal latch is emit-dedup only. ──
|
|
159
|
+
// Seed the baseline on the first pass WITHOUT emitting (the host already
|
|
160
|
+
// enumerated live at bootstrap); emit + advance only on a genuine change. Safe
|
|
161
|
+
// here ONLY because there is no async apply behind it (idea-465 above).
|
|
135
162
|
if (this.appliedRevision === null) {
|
|
136
163
|
this.appliedRevision = served ?? live;
|
|
137
164
|
this.log(`[tool-surface-reconcile] ${reason}: baseline applied=${this.appliedRevision} (served=${served ?? "none"}, live=${live})`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-surface-reconciler.js","sourceRoot":"","sources":["../../../src/tool-manager/catalog/tool-surface-reconciler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;
|
|
1
|
+
{"version":3,"file":"tool-surface-reconciler.js","sourceRoot":"","sources":["../../../src/tool-manager/catalog/tool-surface-reconciler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAkFH,MAAM,OAAO,qBAAqB;IAoBH;IAnB7B;;;;;;;;;;;;;OAaG;IACK,eAAe,GAAkB,IAAI,CAAC;IACtC,yBAAyB,GAAG,CAAC,CAAC;IACrB,GAAG,CAAwB;IAC3B,kBAAkB,CAAS;IAE5C,YAA6B,IAA+B;QAA/B,SAAI,GAAJ,IAAI,CAA2B;Q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