@plumbus/ai-decision-laya 0.2.2 → 0.3.0-beta.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 +8 -0
- package/README.md +5 -4
- package/dist/.tsbuildinfo +1 -1
- package/instructions/README.md +2 -2
- package/instructions/framework.md +3 -3
- package/instructions/testing.md +2 -2
- package/package.json +4 -4
- package/service/test_audit_round_two.py +9 -1
package/instructions/README.md
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
**Classification, categorization, provider/model selection, TypeSafe/Jev or Laya:**
|
|
9
9
|
read `node_modules/@plumbus/core/instructions/ai-classification.md` first (core
|
|
10
|
-
**0.
|
|
10
|
+
**0.8.0-beta.6+**), then [framework.md](framework.md) for this package.
|
|
11
11
|
|
|
12
|
-
Core 0.
|
|
12
|
+
Core 0.8.0-beta.6+ provides `ctx.ai.decide()` and also routes `ctx.ai.classify()`
|
|
13
13
|
to explicitly registered decision adapters. Keep app business logic in Plumbus
|
|
14
14
|
primitives and `ctx.*`. Never route predictions around capability access checks
|
|
15
15
|
or confirmation policy. Provider registration is explicit in `app/server.ts`.
|
|
@@ -4,7 +4,7 @@ Laya provider for self-hosted typed decision inference, with a persistent Python
|
|
|
4
4
|
|
|
5
5
|
## Install and ownership
|
|
6
6
|
|
|
7
|
-
Install `@plumbus/ai-decision-laya` explicitly. Its core peer is exactly `"0.
|
|
7
|
+
Install `@plumbus/ai-decision-laya` explicitly. Its core peer is exactly `">=0.8.0-beta.0 <0.9.0"` (core 0.8 beta family).
|
|
8
8
|
Consumers reuse Zod/testing utilities from core; do not install them separately.
|
|
9
9
|
Use this package for bounded typed decisions. Use core generation and embeddings
|
|
10
10
|
for text responses and vector inference.
|
|
@@ -14,7 +14,7 @@ Public exports: `createLayaDecisionAdapter` — construct an explicitly configur
|
|
|
14
14
|
File map: `src/index.ts` is the public barrel, `src/__tests__/` exercises the public
|
|
15
15
|
API, `instructions/` contains these recipes. Laya alone also ships `service/`.
|
|
16
16
|
|
|
17
|
-
## Classification and model selection (core 0.
|
|
17
|
+
## Classification and model selection (core 0.8.0-beta.6+)
|
|
18
18
|
|
|
19
19
|
Read `node_modules/@plumbus/core/instructions/ai-classification.md` for the complete
|
|
20
20
|
registration and usage recipe. Call `ctx.ai.classify({ text, labels, provider, model,
|
|
@@ -45,7 +45,7 @@ console.log(result.answers.refund.probability);
|
|
|
45
45
|
1. Keep capabilities, flows, access policy and `ctx.*` as the application implementation path.
|
|
46
46
|
2. Construct adapters at a server-owned infrastructure boundary and inject them. Keep keys on the server.
|
|
47
47
|
3. Treat direct adapter usage as protocol integration, not a replacement for core's security/budget/audit lifecycle.
|
|
48
|
-
4. With core 0.
|
|
48
|
+
4. With core 0.8.0-beta.6+, use `ctx.ai.decide()` in capabilities/flows. Export `decisions = { providers, defaultProvider }` from `app/server.ts`; API and workers share it. Do not register decision adapters as completion providers.
|
|
49
49
|
5. Preserve distributions and provider confidence separately. A high confidence value is not authorization or proof of correctness.
|
|
50
50
|
6. Validate thresholds on the actual task/model/language. Unknown cost is `null`, not free.
|
|
51
51
|
7. Pass `signal: ctx.signal` and `timeoutMs` where needed. Flow steps supply their signal by default.
|
package/instructions/testing.md
CHANGED
|
@@ -18,12 +18,12 @@ Validate choices, scores, probabilities, actual model/routing, usage and unknown
|
|
|
18
18
|
cost handling. Measure live accuracy and calibration separately from connection
|
|
19
19
|
success. Do not assert a universal confidence cutoff or guaranteed live label.
|
|
20
20
|
|
|
21
|
-
For core 0.
|
|
21
|
+
For core 0.8.0-beta.6+ classification, use `mockAI({ classify: ['billing'] })` and test
|
|
22
22
|
through `runCapability()` / `simulateFlow()`. Integration tests should assert
|
|
23
23
|
provider/model forwarding, zero/multiple matches, inclusive thresholds, and one
|
|
24
24
|
`classify` cost row. Use injected fetch; routine tests do not require live Laya.
|
|
25
25
|
|
|
26
|
-
For core 0.
|
|
26
|
+
For core 0.8.0-beta.6+ integration tests, configure `mockAI({ decide: result })` or a real
|
|
27
27
|
`createAIService({ decisions, costTracker, onAICostRecorded })` with injected
|
|
28
28
|
provider fetch. Assert exactly one cost row, identity, actual model/usage, unknown
|
|
29
29
|
cost handling, billed validation failures, and budget rejection before dispatch.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumbus/ai-decision-laya",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-beta.0",
|
|
4
4
|
"description": "Self-hosted Laya typed decision adapter and Python reference service for Plumbus.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"node": ">=20.6.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@plumbus/core": "0.
|
|
39
|
+
"@plumbus/core": ">=0.8.0-beta.0 <0.9.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@biomejs/biome": "^2.4.6",
|
|
43
43
|
"@types/node": "^25.4.0",
|
|
44
44
|
"typescript": "^5.7.0",
|
|
45
45
|
"vitest": "^3.2.4",
|
|
46
|
-
"@plumbus/core": "0.
|
|
46
|
+
"@plumbus/core": "0.8.0-beta.6"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@plumbus/ai-decision": "~0.
|
|
49
|
+
"@plumbus/ai-decision": "~0.3.0-beta.0"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsc -b",
|
|
@@ -43,6 +43,14 @@ class ServiceRoundTwo(unittest.TestCase):
|
|
|
43
43
|
finally:
|
|
44
44
|
conn.close()
|
|
45
45
|
|
|
46
|
+
def refused(self, address):
|
|
47
|
+
# Over capacity the server answers at accept without reading a request, so a client
|
|
48
|
+
# still sending one can be reset before it reads the 503. Connect and only read.
|
|
49
|
+
with socket.create_connection(address, timeout=2) as sock:
|
|
50
|
+
response = http.client.HTTPResponse(sock)
|
|
51
|
+
response.begin()
|
|
52
|
+
return response.status, json.loads(response.read())
|
|
53
|
+
|
|
46
54
|
def test_L23_missing_length_cannot_start_inference(self):
|
|
47
55
|
self.assertEqual(self.send(length=None)[0], 400)
|
|
48
56
|
self.assertEqual(self.backend.calls, [])
|
|
@@ -108,7 +116,7 @@ class ServiceRoundTwo(unittest.TestCase):
|
|
|
108
116
|
first.start()
|
|
109
117
|
try:
|
|
110
118
|
self.assertTrue(entered.wait(1))
|
|
111
|
-
self.assertEqual(self.
|
|
119
|
+
self.assertEqual(self.refused(server.server_address)[0], 503)
|
|
112
120
|
finish.set()
|
|
113
121
|
first.join(2)
|
|
114
122
|
self.assertEqual(results, [200])
|