@antelopejs/interface-core 0.2.4 → 0.2.5

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 (38) hide show
  1. package/dist/index.js +0 -13
  2. package/dist/index.js.map +1 -1
  3. package/dist/internal.d.ts +14 -2
  4. package/dist/internal.js +17 -1
  5. package/dist/internal.js.map +1 -1
  6. package/dist/proxies.d.ts +10 -6
  7. package/dist/proxies.js +74 -78
  8. package/dist/proxies.js.map +1 -1
  9. package/dist/tests/module-ownership-context.test.js +3 -3
  10. package/dist/tests/module-ownership-context.test.js.map +1 -1
  11. package/dist/tests/ownership-call-chain.test.js +261 -0
  12. package/dist/tests/ownership-call-chain.test.js.map +1 -0
  13. package/docs/1.introduction.md +29 -3
  14. package/docs/2.proxies.md +40 -20
  15. package/docs/3.decorators.md +25 -1
  16. package/docs/4.metadata.md +25 -1
  17. package/docs/5.modules.md +18 -1
  18. package/docs/6.logging.md +42 -20
  19. package/docs/7.configuration.md +31 -12
  20. package/docs/8.runtime.md +15 -0
  21. package/docs/assets/proxy-lifecycles.svg +21 -0
  22. package/package.json +1 -1
  23. package/skills/core-interface/SKILL.md +3 -4
  24. package/dist/caller-binding.d.ts +0 -12
  25. package/dist/caller-binding.js +0 -105
  26. package/dist/caller-binding.js.map +0 -1
  27. package/dist/responsible-module.d.ts +0 -23
  28. package/dist/responsible-module.js +0 -56
  29. package/dist/responsible-module.js.map +0 -1
  30. package/dist/tests/caller-context.test.js +0 -154
  31. package/dist/tests/caller-context.test.js.map +0 -1
  32. package/dist/tests/provider-context.test.d.ts +0 -1
  33. package/dist/tests/provider-context.test.js +0 -109
  34. package/dist/tests/provider-context.test.js.map +0 -1
  35. package/dist/tests/responsible-module.test.d.ts +0 -1
  36. package/dist/tests/responsible-module.test.js +0 -109
  37. package/dist/tests/responsible-module.test.js.map +0 -1
  38. /package/dist/tests/{caller-context.test.d.ts → ownership-call-chain.test.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"module-ownership-context.test.js","sourceRoot":"","sources":["../../src/tests/module-ownership-context.test.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAE9B,0CAAuC;AACvC,sCAAiD;AACjD,wCAA0D;AAC1D,0BAOY;AAEZ,SAAS,WAAW,CAAC,MAAc,EAAE,QAAoB;IACvD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAA,4BAAwB,EAAC,MAAM,EAAE,GAAG,EAAE;YACpC,YAAY,CAAC,GAAG,EAAE;gBAChB,IAAI,CAAC;oBACH,QAAQ,EAAE,CAAC;oBACX,OAAO,CAAC,SAAS,CAAC,CAAC;gBACrB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,CAAC;gBACjB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,YAAqB,CAAC;IAE1B,UAAU,CAAC,GAAG,EAAE;QACd,YAAY,GAAG,mBAAQ,CAAC,YAAY,CAAC;QACrC,mBAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QAC5B,mBAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,mBAAQ,CAAC,YAAY,GAAG,YAAY,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,CAAC;QAClD,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,KAAK,CAAC,iBAAiB,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE;YACpC,QAAQ,IAAI,CAAC,CAAC;YACd,iBAAiB,CAAC,GAAG,IAAI,CAAC,CA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AAC,CAAC,CAAC"}
1
+ {"version":3,"file":"module-ownership-context.test.js","sourceRoot":"","sources":["../../src/tests/module-ownership-context.test.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAE9B,0CAAuC;AACvC,sCAAiD;AACjD,wCAA0D;AAC1D,0BAOY;AAEZ,SAAS,WAAW,CAAC,MAAc,EAAE,QAAoB;IACvD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAA,4BAAwB,EAAC,MAAM,EAAE,GAAG,EAAE;YACpC,YAAY,CAAC,GAAG,EAAE;gBAChB,IAAI,CAAC;oBACH,QAAQ,EAAE,CAAC;oBACX,OAAO,CAAC,SAAS,CAAC,CAAC;gBACrB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,CAAC;gBACjB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,YAAqB,CAAC;IAE1B,UAAU,CAAC,GAAG,EAAE;QACd,YAAY,GAAG,mBAAQ,CAAC,YAAY,CAAC;QACrC,mBAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QAC5B,mBAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,mBAAQ,CAAC,YAAY,GAAG,YAAY,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,CAAC;QAClD,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,KAAK,CAAC,iBAAiB,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE;YACpC,QAAQ,IAAI,CAAC,CAAC;YACd,iBAAiB,CAAC,G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IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const modules_1 = require("../modules");
5
+ const __1 = require("..");
6
+ function inModule(module, owner, callback) {
7
+ return (0, modules_1.RunWithModuleContext)({ module, owner }, callback);
8
+ }
9
+ function destroy(module, owner) {
10
+ inModule(module, owner, () => modules_1.Events.ModuleDestroyed.emit(module));
11
+ }
12
+ function attachRegistry(proxy, entries, module, owner) {
13
+ inModule(module, owner, () => proxy.onHandlers((id) => entries.add(id), (id) => entries.delete(id)));
14
+ }
15
+ function deferred() {
16
+ let resolve;
17
+ const promise = new Promise((done) => {
18
+ resolve = done;
19
+ });
20
+ return { promise, resolve };
21
+ }
22
+ function outcomeOf(promise) {
23
+ return promise.then(() => "resolved", (error) => error);
24
+ }
25
+ describe("call chain: a module serving a call owns what it registers", () => {
26
+ it("keeps a registration made by B's provider when A is destroyed, and drops it with B", async () => {
27
+ const b = new __1.AsyncProxy();
28
+ const c = new __1.RegisteringProxy();
29
+ const entries = new Set();
30
+ attachRegistry(c, entries, "c", "c#1");
31
+ inModule("b", "b#1", () => b.onCall(() => c.register("from-b")));
32
+ await inModule("a", "a#1", () => b.call());
33
+ destroy("a", "a#1");
34
+ (0, chai_1.expect)([...entries]).to.deep.equal(["from-b"]);
35
+ destroy("b", "b#1");
36
+ (0, chai_1.expect)([...entries]).to.deep.equal([]);
37
+ });
38
+ it("forwards A's registration through B, replays it to B's next generation, and removes it with A", () => {
39
+ const b = new __1.RegisteringProxy();
40
+ const c = new __1.RegisteringProxy();
41
+ const entries = new Set();
42
+ attachRegistry(c, entries, "c", "c#2");
43
+ const attachForwarder = (owner) => inModule("b", owner, () => b.onHandlers((id) => c.register(`c:${id}`), (id) => c.unregister(`c:${id}`)));
44
+ attachForwarder("b#2");
45
+ inModule("a", "a#2", () => b.register("x"));
46
+ (0, chai_1.expect)([...entries]).to.deep.equal(["c:x"]);
47
+ destroy("b", "b#2");
48
+ (0, chai_1.expect)([...entries]).to.deep.equal([]);
49
+ attachForwarder("b#3");
50
+ (0, chai_1.expect)([...entries]).to.deep.equal(["c:x"]);
51
+ destroy("a", "a#2");
52
+ (0, chai_1.expect)([...entries]).to.deep.equal([]);
53
+ });
54
+ });
55
+ describe("call chain: queued calls", () => {
56
+ it("runs a call queued before the provider attached in the provider's context", async () => {
57
+ const proxy = new __1.AsyncProxy();
58
+ const pending = inModule("a", "a#3", () => proxy.call());
59
+ inModule("b", "b#4", () => proxy.onCall(() => (0, __1.GetResponsibleModule)()));
60
+ (0, chai_1.expect)(await pending).to.equal("b");
61
+ });
62
+ it("rejects a queued call whose caller was destroyed before the provider attached", async () => {
63
+ const proxy = new __1.AsyncProxy();
64
+ let served = 0;
65
+ const pending = outcomeOf(inModule("a", "a#4", () => proxy.call()));
66
+ destroy("a", "a#4");
67
+ inModule("b", "b#5", () => proxy.onCall(() => {
68
+ served += 1;
69
+ return "served";
70
+ }));
71
+ (0, chai_1.expect)(await pending).to.be.instanceOf(__1.ModuleContextInvalidatedError);
72
+ (0, chai_1.expect)(served).to.equal(0);
73
+ });
74
+ });
75
+ describe("call chain: context at each crossing", () => {
76
+ it("runs a provider callback in the provider's context, across an await", async () => {
77
+ const proxy = new __1.AsyncProxy();
78
+ inModule("b", "b#6", () => proxy.onCall(async () => {
79
+ const before = (0, __1.GetResponsibleModule)();
80
+ await Promise.resolve();
81
+ return [before, (0, __1.GetResponsibleModule)()];
82
+ }));
83
+ const seen = await inModule("a", "a#5", () => proxy.call());
84
+ (0, chai_1.expect)(seen).to.deep.equal(["b", "b"]);
85
+ });
86
+ it("runs register, unregister and replay handlers in the provider's context", () => {
87
+ const proxy = new __1.RegisteringProxy();
88
+ const seen = [];
89
+ const attach = (owner) => inModule("b", owner, () => proxy.onHandlers(() => seen.push((0, modules_1.GetModuleContext)()?.owner), () => seen.push((0, modules_1.GetModuleContext)()?.owner)));
90
+ attach("b#7");
91
+ inModule("a", "a#6", () => proxy.register("x"));
92
+ attach("b#8");
93
+ inModule("a", "a#6", () => proxy.unregister("x"));
94
+ (0, chai_1.expect)(seen).to.deep.equal(["b#7", "b#8", "b#8"]);
95
+ });
96
+ it("runs an event handler in the context it was registered in", () => {
97
+ const event = new __1.EventProxy();
98
+ const seen = [];
99
+ inModule("a", "a#7", () => event.register(() => seen.push((0, __1.GetResponsibleModule)())));
100
+ inModule("emitter", "emitter#1", () => event.emit());
101
+ (0, chai_1.expect)(seen).to.deep.equal(["a"]);
102
+ });
103
+ it("runs a handler registered outside any context in the emitter's context", () => {
104
+ const event = new __1.EventProxy();
105
+ const seen = [];
106
+ event.register(() => seen.push((0, __1.GetResponsibleModule)()));
107
+ inModule("emitter", "emitter#2", () => event.emit());
108
+ (0, chai_1.expect)(seen).to.deep.equal(["emitter"]);
109
+ });
110
+ it("lets an unregister handler schedule work that enters a module context during the registrant's release", async () => {
111
+ const proxy = new __1.RegisteringProxy();
112
+ let scheduled;
113
+ inModule("d", "d#1", () => proxy.onHandlers(() => undefined, () => {
114
+ scheduled = new Promise((resolve) => {
115
+ setImmediate(() => {
116
+ try {
117
+ (0, modules_1.RunWithModuleContext)({ module: "d-sync" }, () => undefined);
118
+ resolve("entered");
119
+ }
120
+ catch (error) {
121
+ resolve(error);
122
+ }
123
+ });
124
+ });
125
+ }));
126
+ inModule("a", "a#8", () => proxy.register("page"));
127
+ destroy("a", "a#8");
128
+ (0, chai_1.expect)(await scheduled).to.equal("entered");
129
+ });
130
+ });
131
+ describe("call chain: an interface's own context", () => {
132
+ const INTERFACE = {
133
+ module: "interface-x",
134
+ owner: "interface-x@p#instance",
135
+ kind: "interface",
136
+ };
137
+ it("keeps the interface's context for its own timers and event handlers", async () => {
138
+ const event = new __1.EventProxy();
139
+ const handled = [];
140
+ const timer = (0, modules_1.RunWithModuleContext)(INTERFACE, () => {
141
+ event.register(() => handled.push((0, __1.GetResponsibleModule)()));
142
+ return new Promise((resolve) => {
143
+ setTimeout(() => resolve((0, modules_1.GetModuleContext)()?.owner), 0);
144
+ });
145
+ });
146
+ inModule("emitter", "emitter#3", () => event.emit());
147
+ (0, chai_1.expect)(await timer).to.equal(INTERFACE.owner);
148
+ (0, chai_1.expect)(handled).to.deep.equal(["interface-x"]);
149
+ });
150
+ it("runs callbacks it attaches in the caller's context, so what they forward is the caller's", async () => {
151
+ const call = new __1.AsyncProxy();
152
+ const handlers = new __1.RegisteringProxy();
153
+ const c = new __1.RegisteringProxy();
154
+ const entries = new Set();
155
+ attachRegistry(c, entries, "c", "c#3");
156
+ (0, modules_1.RunWithModuleContext)({ ...INTERFACE, owner: "interface-y#instance" }, () => {
157
+ call.onCall(() => (0, __1.GetResponsibleModule)());
158
+ handlers.onHandlers((id) => c.register(`c:${id}`), (id) => c.unregister(`c:${id}`));
159
+ });
160
+ (0, chai_1.expect)(await inModule("a", "a#9", () => call.call())).to.equal("a");
161
+ inModule("a", "a#9", () => handlers.register("x"));
162
+ (0, chai_1.expect)([...entries]).to.deep.equal(["c:x"]);
163
+ destroy("a", "a#9");
164
+ (0, chai_1.expect)([...entries]).to.deep.equal([]);
165
+ });
166
+ it("replays a call queued before it attaches in the caller's context, so what it forwards is the caller's", async () => {
167
+ const call = new __1.AsyncProxy();
168
+ const c = new __1.RegisteringProxy();
169
+ const entries = new Set();
170
+ attachRegistry(c, entries, "c", "c#5");
171
+ const pending = inModule("a", "a#16", () => call.call());
172
+ (0, modules_1.RunWithModuleContext)({ ...INTERFACE, owner: "interface-q#instance" }, () => call.onCall(() => {
173
+ c.register("queued");
174
+ return (0, __1.GetResponsibleModule)();
175
+ }));
176
+ (0, chai_1.expect)(await pending).to.equal("a");
177
+ (0, chai_1.expect)([...entries]).to.deep.equal(["queued"]);
178
+ destroy("a", "a#16");
179
+ (0, chai_1.expect)([...entries]).to.deep.equal([]);
180
+ });
181
+ it("replays a call queued outside any context with no context", async () => {
182
+ const call = new __1.AsyncProxy();
183
+ const pending = call.call();
184
+ (0, modules_1.RunWithModuleContext)({ ...INTERFACE, owner: "interface-r#instance" }, () => call.onCall(() => (0, __1.GetResponsibleModule)()));
185
+ (0, chai_1.expect)(await pending).to.equal(undefined);
186
+ });
187
+ it("releases only the interface's own work when its owner is released", () => {
188
+ const own = new __1.RegisteringProxy();
189
+ const handlers = new __1.RegisteringProxy();
190
+ const ownEntries = new Set();
191
+ const forwarded = new Set();
192
+ const owner = "interface-z#instance";
193
+ attachRegistry(own, ownEntries, "c", "c#4");
194
+ attachRegistry(handlers, forwarded, "c", "c#4");
195
+ (0, modules_1.RunWithModuleContext)({ ...INTERFACE, owner }, () => own.register("interface-entry"));
196
+ inModule("a", "a#10", () => handlers.register("a-entry"));
197
+ (0, modules_1.ReleaseOwner)(owner);
198
+ (0, chai_1.expect)([...ownEntries]).to.deep.equal([]);
199
+ (0, chai_1.expect)([...forwarded]).to.deep.equal(["a-entry"]);
200
+ });
201
+ });
202
+ describe("call chain: values cross unchanged", () => {
203
+ class Value {
204
+ }
205
+ const handler = () => undefined;
206
+ const object = { handler };
207
+ const array = [handler];
208
+ const values = [Value, handler, object, array];
209
+ it("hands call arguments to the provider as the very same values", async () => {
210
+ const proxy = new __1.AsyncProxy();
211
+ inModule("b", "b#9", () => proxy.onCall((...received) => received));
212
+ const received = await inModule("a", "a#11", () => proxy.call(...values));
213
+ received.forEach((value, index) => (0, chai_1.expect)(value).to.equal(values[index]));
214
+ });
215
+ it("hands register arguments to the provider as the very same values", () => {
216
+ const proxy = new __1.RegisteringProxy();
217
+ let received = [];
218
+ inModule("b", "b#10", () => proxy.onHandlers((_id, ...args) => {
219
+ received = args;
220
+ }, () => undefined));
221
+ inModule("a", "a#12", () => proxy.register("x", ...values));
222
+ received.forEach((value, index) => (0, chai_1.expect)(value).to.equal(values[index]));
223
+ });
224
+ it("unregisters an event handler by the reference it was registered with", () => {
225
+ const event = new __1.EventProxy();
226
+ const received = [];
227
+ const listener = (value) => received.push(value);
228
+ inModule("a", "a#13", () => event.register(listener));
229
+ event.emit(object);
230
+ inModule("a", "a#13", () => event.unregister(listener));
231
+ event.emit(object);
232
+ (0, chai_1.expect)(received).to.have.length(1);
233
+ (0, chai_1.expect)(received[0]).to.equal(object);
234
+ });
235
+ });
236
+ describe("call chain: fence on a destroyed generation", () => {
237
+ it("rejects a call made from a destroyed generation without throwing", async () => {
238
+ const proxy = new __1.AsyncProxy();
239
+ inModule("b", "b#11", () => proxy.onCall(() => "served"));
240
+ const gate = deferred();
241
+ const outcome = inModule("a", "a#14", async () => {
242
+ await gate.promise;
243
+ return outcomeOf(proxy.call());
244
+ });
245
+ destroy("a", "a#14");
246
+ gate.resolve();
247
+ (0, chai_1.expect)(await outcome).to.be.instanceOf(__1.ModuleContextInvalidatedError);
248
+ });
249
+ it("throws on a register made from a destroyed generation", async () => {
250
+ const proxy = new __1.RegisteringProxy();
251
+ const gate = deferred();
252
+ const outcome = inModule("a", "a#15", async () => {
253
+ await gate.promise;
254
+ proxy.register("late");
255
+ });
256
+ destroy("a", "a#15");
257
+ gate.resolve();
258
+ (0, chai_1.expect)(await outcomeOf(outcome)).to.be.instanceOf(__1.ModuleContextInvalidatedError);
259
+ });
260
+ });
261
+ //# sourceMappingURL=ownership-call-chain.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ownership-call-chain.test.js","sourceRoot":"","sources":["../../src/tests/ownership-call-chain.test.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAE9B,wCAKoB;AACpB,0BAMY;AAIZ,SAAS,QAAQ,CAAI,MAAc,EAAE,KAAa,EAAE,QAAiB;IACnE,OAAO,IAAA,8BAAoB,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,OAAO,CAAC,MAAc,EAAE,KAAa;IAC5C,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CA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,GAAG,IAAI,oBAAgB,EAAY,CAAC;QAC/C,MAAM,IAAI,GAAG,QAAQ,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE;YAC/C,MAAM,IAAI,CAAC,OAAO,CAAC;YACnB,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,IAAA,aAAM,EAAC,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAC/C,iCAA6B,CAC9B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,8 +1,21 @@
1
- # Interface Core Documentation
1
+ # Connect modules through interfaces
2
2
 
3
3
  ## Overview
4
4
 
5
- `@antelopejs/interface-core` provides the foundational building blocks for the AntelopeJS interface system. It defines the core primitives that enable type-safe, module-aware communication between decoupled components.
5
+ `@antelopejs/interface-core` lets one module call a contract implemented by another. The caller imports the interface rather than the provider, so the runtime can connect modules and replace a provider without changing the caller's imports.
6
+
7
+ If you only need application logs, start with [logging](./6.logging.md). If you are using HTTP routes or authentication, start with those interfaces; you do not need to build a proxy first.
8
+
9
+ ## Start with your role
10
+
11
+ | You are… | Start here | You own… |
12
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------- |
13
+ | Calling an existing interface | Its package documentation, then [connection lookup](./2.proxies.md#getinterfaceinstances-and-getinterfaceinstance) | The consuming module and its provider binding. |
14
+ | Defining a new contract | [How interfaces work](#how-interfaces-work), then [proxies](./2.proxies.md) | Typed declarations shared by consumers and providers. |
15
+ | Implementing a contract | [`ImplementInterface`](./2.proxies.md#implementinterface) | Every declared function and registration callback. |
16
+ | Integrating a module loader | [Runtime](./8.runtime.md) and [module lifecycle](./5.modules.md) | Ownership contexts, generations, and cleanup. |
17
+
18
+ Application modules normally import an existing interface rather than construct proxies themselves. The AntelopeJS runtime supplies module context and connections; these primitives do not configure a project or choose a provider for you.
6
19
 
7
20
  The package exports several key categories of functionality:
8
21
 
@@ -70,7 +83,17 @@ ImplementInterface(UserInterface, {
70
83
  });
71
84
  ```
72
85
 
73
- The proxy system ensures that calls to `GetUser` before the implementation is attached are automatically queued and resolved once the implementation becomes available. When the implementing module is unloaded, the proxy detaches and resumes queuing.
86
+ The proxy queues calls to `GetUser` until an implementation attaches. When the implementing module unloads, the proxy detaches and queues new calls again. The queue is bounded (1,000 pending calls by default), and test stub mode rejects missing providers instead of waiting. See [proxy failure modes](./2.proxies.md#other-public-errors) before relying on this behavior during startup.
87
+
88
+ ## Choose a communication primitive
89
+
90
+ | Need | Primitive | Without an attached provider or listener |
91
+ | ------------------------------------------ | ---------------------------------- | --------------------------------------------------------- |
92
+ | Ask for a result | `InterfaceFunction` / `AsyncProxy` | Calls queue, subject to the queue limit and stub mode. |
93
+ | Notify current listeners | `EventProxy` | Emissions are not retained for future listeners. |
94
+ | Keep declarations available across reloads | `RegisteringProxy` | Entries remain available for replay when handlers attach. |
95
+
96
+ Do not use an event for a registration that a replacement provider must recover. Use the registering proxy's paired `onHandlers` attachment when replay needs both registration and unregistration callbacks.
74
97
 
75
98
  ## Next steps
76
99
 
@@ -78,3 +101,6 @@ The proxy system ensures that calls to `GetUser` before the implementation is at
78
101
  - [Decorators](./3.decorators.md) - Build type-safe decorator factories
79
102
  - [Modules](./5.modules.md) - Understand module lifecycle events
80
103
  - [Logging](./6.logging.md) - Use the structured logging system
104
+ - [Metadata](./4.metadata.md) - Read inherited metadata
105
+ - [Configuration](./7.configuration.md) - Define project configuration
106
+ - [Runtime](./8.runtime.md) - Integrate ownership and loader behavior
package/docs/2.proxies.md CHANGED
@@ -2,9 +2,23 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- Proxies are the backbone of cross-module communication in AntelopeJS. They provide module-aware abstractions for function calls, event handling, and registration patterns. Each proxy type automatically tracks the module that attaches callbacks and detaches them when that module is unloaded, preventing memory leaks and dangling references.
5
+ Choose a proxy by what must survive a provider change: a pending call, nothing from a past event, or a retained registration. The proxy tracks module ownership so the runtime can remove that module's callbacks and registrations when it is destroyed. You still own resources such as sockets and timers created by those callbacks.
6
6
 
7
- A proxy has a single provider and keeps its state on the proxy object itself. When a project has several providers of one interface, the core evaluates a separate instance of the interface package for each provider, so each instance's proxies reach exactly one provider; no call selects a provider at run time.
7
+ An async or registering proxy has one provider attachment; an event proxy has multiple listeners. State lives on each proxy object. When a project has several providers of one interface, the core evaluates a separate instance of the interface package for each provider, so each instance's calls reach one provider; no call selects a provider at run time.
8
+
9
+ For an ordinary request/response contract, start with [`InterfaceFunction`](#interfacefunction) and [`ImplementInterface`](#implementinterface). Direct attachment, leases, and ownership contexts below are for provider or loader authors who need lifecycle control.
10
+
11
+ ## Read the lifecycle before choosing a proxy
12
+
13
+ ![Async calls wait for a provider, events reach only current listeners, and registrations remain available for replay after provider replacement.](./assets/proxy-lifecycles.svg){width="480"}
14
+
15
+ | Situation | Async call | Event | Registration |
16
+ | ------------------ | ---------------------- | --------------------------------------- | -------------------------------------------------------------------- |
17
+ | No attachment | Queues up to the limit | No listener receives it | Entry is retained |
18
+ | Attachment arrives | Pending calls run | Future emissions reach listeners | Stored entries replay |
19
+ | Attachment leaves | New calls queue again | Removed listener stops receiving events | Entries remain until explicitly removed or their owner is cleaned up |
20
+
21
+ This table describes normal runtime behavior. [Test stub mode](#missingprovidererror) rejects missing providers. Detaching an async callback does not cancel work already running; detaching registration callbacks does not release provider resources.
8
22
 
9
23
  ## `AsyncProxy`
10
24
 
@@ -20,7 +34,7 @@ const proxy = new AsyncProxy<(name: string) => string>();
20
34
  // Calls made before attachment are queued
21
35
  const result = proxy.call("Alice"); // returns Promise<string>
22
36
 
23
- // Attach an implementation - queued calls resolve immediately
37
+ // Attach an implementation - queued calls now invoke it
24
38
  proxy.onCall((name: string) => {
25
39
  return `Hello, ${name}!`;
26
40
  });
@@ -33,7 +47,7 @@ const greeting = await proxy.call("Bob"); // "Hello, Bob!"
33
47
 
34
48
  Attaches the provider's callback to the proxy, replacing any callback attached before, so a provider's new generation takes over from the old one. The proxy automatically tracks the calling module and detaches the callback when that module is unloaded; releasing an older generation never detaches a newer one. Pass `manualDetach: true` to disable automatic cleanup.
35
49
 
36
- When attachment occurs inside `RunWithModuleContext`, calls execute in the captured provider context rather than the consumer context. The captured module and owner generation remain available across nested calls and `await`. Calls reject with `ModuleContextInvalidatedError` if the captured owner has been destroyed.
50
+ The callback runs in the context it was attached in, the provider's, whichever module calls: `GetModuleContext` reports the provider, across nested calls and `await`, and what the callback registers belongs to the provider. A callback attached in an interface package's own context runs in the caller's context instead (see [Ownership](#ownership)).
37
51
 
38
52
  ```ts
39
53
  // Automatic cleanup (default) - detaches when the module unloads
@@ -59,11 +73,11 @@ const greeting: string = await proxy.call(); // "current"
59
73
  proxy.detach(currentLease);
60
74
  ```
61
75
 
62
- Manual detachment disables automatic attachment cleanup, not context capture or invalidation. A callback captured under a destroyed owner still rejects when invoked.
76
+ Manual detachment disables automatic attachment cleanup only. A callback attached by a generation that is later destroyed still runs when invoked, in that generation's context, so reading the module context or registering from inside it throws `ModuleContextInvalidatedError`.
63
77
 
64
78
  ### `call(...args)`
65
79
 
66
- Invokes the attached callback. If no callback is attached, the call returns a `Promise` that resolves once a callback is provided. In test stub mode, unattached calls reject with a [`MissingProviderError`](#missingprovidererror).
80
+ Invokes the attached callback. If no callback is attached, the call returns a `Promise` that resolves once a callback is provided; the queued call then runs as if it had just been made, and rejects with `ModuleContextInvalidatedError` if the caller's generation was destroyed in the meantime. A call made from a destroyed generation rejects with `ModuleContextInvalidatedError`. In test stub mode, unattached calls reject with a [`MissingProviderError`](#missingprovidererror).
67
81
 
68
82
  ### `detach()`
69
83
 
@@ -110,7 +124,7 @@ onUserCreated.emit("u-1", "Alice");
110
124
 
111
125
  ### `register(func)`
112
126
 
113
- Registers a handler for the event. Duplicate handlers (same function reference) are ignored. The proxy tracks the calling module and removes the handler when that module is unloaded. The handler runs in the context of the module that registered it, whichever module emits the event.
127
+ Registers a handler for the event. Duplicate handlers (same function reference) are ignored. The proxy tracks the calling module and removes the handler when that module is unloaded. The handler runs in the context it was registered in, whichever module emits the event. A handler registered outside any context runs in the emitter's context.
114
128
 
115
129
  ### `emit(...args)`
116
130
 
@@ -157,17 +171,17 @@ Replay reports synchronous registration failures and continues to the next store
157
171
 
158
172
  Attaches only the register callback and returns its own lease. Any previously registered entries replay through this callback immediately. Automatic module-aware detachment applies unless `manualDetach` is `true`. An existing unregister callback remains attached.
159
173
 
160
- Register replay and direct registration execute in the provider context captured when the callback attaches.
174
+ Direct registration and replay run in the context the callback was attached in, the provider's.
161
175
 
162
176
  ### `onUnregister(callback)`
163
177
 
164
178
  Attaches only the unregister callback and returns a separate lease. It shares the owner and manual-detach setting of an existing attachment belonging to the active owner when available. Without an explicit context, it uses the existing unregister attachment, then the register attachment, if present. Otherwise it resolves ownership normally and enables automatic cleanup. It does not replay registrations or replace the register callback.
165
179
 
166
- Unregistration executes in the context captured when this callback attaches.
180
+ Unregistration runs in the context this callback was attached in, also when it is triggered by the release of the module that registered the entry.
167
181
 
168
182
  ### `register(id, ...args)`
169
183
 
170
- Registers an entry with the given identifier. If a register callback is attached, it executes immediately. Otherwise, the entry is stored and replayed when a callback is attached. The calling module is tracked for automatic cleanup. Registering the same ID replaces the stored arguments and ownership and calls the register callback again; it does not first call unregister.
184
+ Registers an entry with the given identifier. If a register callback is attached, it executes immediately. Otherwise, the entry is stored and replayed when a callback is attached. The calling module is tracked for automatic cleanup. Registering the same ID replaces the stored arguments and ownership and calls the register callback again; it does not first call unregister. Registering from a destroyed generation throws `ModuleContextInvalidatedError`.
171
185
 
172
186
  ### `unregister(id)`
173
187
 
@@ -187,14 +201,22 @@ All three proxy constructors accept an optional identity string. `GetInterfacePr
187
201
 
188
202
  `IsInterfaceProxy(value, kind?)` checks the shared runtime protocol brand, optionally restricted to `"async"`, `"registering"`, or `"event"`. It works across compatible package copies where `instanceof` is unreliable, but returns a boolean rather than narrowing a TypeScript type. Both helpers operate on proxy objects, not on the callable return value of `InterfaceFunction`.
189
203
 
190
- ## Functions passed through a proxy
204
+ ## Ownership
205
+
206
+ Proxies track ownership so that hot reload can detach and unregister everything a module generation left behind. The owner of an attachment, a registration or an event handler is the nearest module in the chain of work that made it, read from the async module context:
191
207
 
192
- A function a module hands to a proxy runs as that module's work, whoever invokes it later:
208
+ - **A module owns its own work**, including what it registers while serving another module's call. A provider callback runs in the provider's context, so when module A calls B and B's provider registers on C, the entry on C is B's: reloading B removes it, destroying A does not.
209
+ - **A module that forwards registrations declares a `RegisteringProxy`.** When A registers on B and B's provider forwards to C, B's next generation receives A's entry again through replay and forwards it again. When A is destroyed, its entry on B is unregistered and B's unregister callback removes the one on C.
210
+ - **Interface package code is never an owner.** Functions an interface package exports run in their caller's context, so what they forward is the caller's.
211
+ - **An interface package owns what it needs in order to work.** The core evaluates each interface package in a context of its own, of kind `"interface"`, whose owner is released only when the core discards that interface instance, never on a module reload. Code at the package's top level, and the timers, promises and event handlers it creates, run in that context. A provider callback attached there is the exception: it only carries calls and registrations forward on a caller's behalf, so it runs in the caller's context.
193
212
 
194
- - an event handler runs in the context of the module that registered it;
195
- - a function passed as an argument to `AsyncProxy.call` or `RegisteringProxy.register`, or held in a plain object or array passed that way, runs in the context of the module that made the call.
213
+ Values cross unchanged: arguments to `AsyncProxy.call`, `RegisteringProxy.register` and `EventProxy.emit` reach the other side as the very same values, so a class keeps the identity its metadata and registries are keyed by, and a function can be unregistered by reference.
196
214
 
197
- Inside such a function, `GetModuleContext` and `GetResponsibleModule` report the module that passed it, and what it registers is owned by that module. Once that module's generation is destroyed, invoking the function throws `ModuleContextInvalidatedError`. Plain data, classes, class instances and proxies cross unchanged, so a class keeps the identity its metadata and registries are keyed by; a function passed twice reaches the provider as the same value, and a function passed on by another module keeps its original context.
215
+ ### Limits
216
+
217
+ - A function passed as an argument and invoked later by the provider runs in the context of whoever invokes it, and what it registers belongs to that module. Callbacks that outlive the call belong in a `RegisteringProxy` entry, not in `AsyncProxy.call` arguments.
218
+ - Work an interface package starts lazily, from inside a function it exports rather than from its top level, belongs to the module that called first.
219
+ - The core enters an interface package's context only for packages loaded through `require()`. A package reached through an ECMAScript `import` is evaluated in its importer's context, so its top-level work belongs to that importer.
198
220
 
199
221
  ## `ImplementInterface`
200
222
 
@@ -299,7 +321,7 @@ Requiring a connection's `path` (or a subpath of it) gives the interface bound t
299
321
 
300
322
  ## `GetResponsibleModule`
301
323
 
302
- `GetResponsibleModule` inspects the call stack to determine which module is responsible for the current execution. The proxy classes use this internally for automatic cleanup tracking.
324
+ `GetResponsibleModule` returns the module of the active async module context, or `undefined` outside any context. It never inspects the call stack.
303
325
 
304
326
  ```ts
305
327
  import { GetResponsibleModule } from "@antelopejs/interface-core";
@@ -307,11 +329,9 @@ import { GetResponsibleModule } from "@antelopejs/interface-core";
307
329
  const moduleId = GetResponsibleModule();
308
330
  ```
309
331
 
310
- > **Warning:** Calling `GetResponsibleModule` from within an async context (such as `setTimeout` or `setInterval`) without explicit ownership breaks hot reloading. The system logs an error when this is detected.
311
-
312
332
  ## `RunWithResponsibleModule`
313
333
 
314
- `RunWithResponsibleModule` sets the responsible module explicitly for synchronous and asynchronous work. Proxy registrations made in the callback use this module directly instead of capturing and walking a stack. Nested contexts restore their parent when they complete, including when a callback throws.
334
+ `RunWithResponsibleModule` sets the responsible module explicitly for synchronous and asynchronous work. Proxy registrations made in the callback are owned by this module. Nested contexts restore their parent when they complete, including when a callback throws.
315
335
 
316
336
  ```ts
317
337
  import { RunWithResponsibleModule } from "@antelopejs/interface-core";
@@ -322,7 +342,7 @@ await RunWithResponsibleModule("my-module", async () => {
322
342
  });
323
343
  ```
324
344
 
325
- The module loader should wrap known module-owned entry points, including module evaluation and lifecycle hooks. Existing callers need no migration: outside an explicit context, `GetResponsibleModule` retains stack-based resolution as a backward-compatible fallback. Automatic proxy detachment and registration cleanup use the resolved module in both paths.
345
+ The module loader wraps every module-owned entry point, including module evaluation and lifecycle hooks. Work done outside any context has no owner: its attachments belong to a default owner that no module release removes, and its registrations are never released by owner.
326
346
 
327
347
  Ownership contexts are scoped to a loaded module generation. Loaders that can overlap old and replacement instances should use `RunWithModuleContext` and provide a unique `owner` for every generation. `ModuleDestroyed` invalidates and cleans only the active event context's owner while preserving the existing module ID event contract. Detached asynchronous work from that owner then receives a `ModuleContextInvalidatedError`.
328
348
 
@@ -2,7 +2,31 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- The `@antelopejs/interface-core/decorators` module provides factory functions for creating type-safe TypeScript decorators. These factories handle the boilerplate of splitting decorator arguments from factory arguments, producing reusable, parameterized decorators for classes, properties, methods, and parameters.
5
+ Use these factories when you are building a decorator, rather than using an existing one such as `@Get`. Your callback receives the decorated target first and the arguments from the decorator call afterwards.
6
+
7
+ These are TypeScript legacy decorators: enable `experimentalDecorators`. They do not implement the standard JavaScript decorator context API. Examples that call `Reflect.defineMetadata` also need `import "reflect-metadata"` before use; importing the package root already loads it.
8
+
9
+ Start with [`MakeClassDecorator`](#makeclassdecorator) for a one-target example. Consult the combined factory table only when the same decorator must support several targets.
10
+
11
+ ## Name a class with a decorator
12
+
13
+ This decorator stores a label when the class is declared. `target` is the class constructor; `name` is the value passed to `@Label`.
14
+
15
+ ```ts docs-check
16
+ import { MakeClassDecorator } from "@antelopejs/interface-core/decorators";
17
+
18
+ const labels = new WeakMap<Function, string>();
19
+ const Label = MakeClassDecorator((target: Function, name: string) => {
20
+ labels.set(target, name);
21
+ });
22
+
23
+ @Label("users")
24
+ class UserController {}
25
+
26
+ const label = labels.get(UserController); // "users"
27
+ ```
28
+
29
+ The factories do not run request-time behavior by themselves. Your integration decides when to read stored values or invoke a decorated method.
6
30
 
7
31
  ## Import
8
32