Skip to content

Commit ed00e67

Browse files
authored
feat(authority): add Stage 2A NoKV AuthorityStore candidate (#3819)
* feat(authority): add NoKV candidate store Signed-off-by: wchwawa <wch19961116@gmail.com> * test(authority): qualify live NoKV candidate Signed-off-by: wchwawa <wch19961116@gmail.com> * fix(authority): preserve Node 22 transport admission Signed-off-by: wchwawa <wch19961116@gmail.com> * test(authority): qualify NoKV Stage 2A boundary Signed-off-by: wchwawa <wch19961116@gmail.com> * fix(authority): fail closed on NoKV lineage races Signed-off-by: wchwawa <wch19961116@gmail.com> * test(authority): isolate the qualification helper interpreter Run the Stage 2A live-qualification helper with the Python isolation flag so PYTHONPATH, PYTHONHOME, and user site-packages cannot substitute a stand-in nokv module for live evidence; the interpreter's own environment is the only SDK source. Add a TypeScript test that first proves the vector (a stand-in module on PYTHONPATH is imported and admitted without the flag) and then proves the qualification argv never imports it. Document that the report's SDK and API version fields are the helper's admission constants rather than server-observed values, in the README and both RFC mirrors. Signed-off-by: wchwawa <wch19961116@gmail.com> --------- Signed-off-by: wchwawa <wch19961116@gmail.com>
1 parent dfb6d82 commit ed00e67

15 files changed

Lines changed: 4108 additions & 9 deletions

‎docs/architecture/rfcs/shared-goal-authority-state-provider-v0.md‎

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
- Status: Draft, under maintainer review
44
- Initially proposed by: NoKV Lab
55
- Widened by: LoopX maintainers
6-
- Date: 2026-08-05; revised 2026-09-01
6+
- Date: 2026-08-05; revised 2026-09-02
77
- Scope: one provider-neutral LoopX authority contract with built-in file,
88
optional NoKV, and optional PostgreSQL provider profiles, complementing
99
[`host-integration-surface-v0`](../../reference/protocols/host-integration-surface-v0.md)
1010
- Source baseline: LoopX `a0c20f1779d273e7aaa4bd3ea166d145d466e6d5`
11-
- Provider API baseline: NoKV `3d75d96965` (0.11.0 line). The Python
12-
`publish_bytes` generation-CAS mapping was exercised once by hand against a
13-
live NoKV stack at that pin (see the example README); the run is evidence for
14-
the mapping only, not part of any merge gate
11+
- Provider API baseline: NoKV `7bb3ffd6512fd57d9c0f193aa6d9c5b935d77f30`
12+
(release 0.11.0, Python API 1, Holt pinned to 0.8.6). The Stage 2A executable
13+
qualification admits only that SDK contract and this checkout's helper. It
14+
remains candidate evidence, not a merge gate or authority promotion
1515
- PostgreSQL baseline: the TypeScript Stage 2B candidate implements the store
1616
contract and has passed a real PostgreSQL 16 transaction matrix. No shared
1717
authority service, runtime caller, authentication boundary, or authority
@@ -1428,6 +1428,30 @@ claim that the complete P0 acceptance gate above passes. Historical latency or
14281428
fault results are informative only; they are not a durability, recovery, HA,
14291429
or production qualification claim.
14301430

1431+
The additional TEST ONLY Stage 2A probe in
1432+
`examples/nokv-authority-store/` opens three independent SDK helper processes
1433+
and checks fresh create, exact generation update, reconciliation after an
1434+
applied CAS response is deliberately lost, a one-winner/two-contender CAS,
1435+
winner/loser receipt behavior, and fresh-process receipt/history readback. Its
1436+
executable fixes argv to one absolute Python executable, the interpreter
1437+
isolation flag `-I`, and this checkout's reviewed helper, so `PYTHONPATH`
1438+
cannot substitute the `nokv` module; the helper fails closed unless the SDK
1439+
reports NoKV 0.11.0 and Python API 1, and the report repeats those two
1440+
admission constants rather than server-observed values. It validates read metadata against the current workbench
1441+
incarnation and validates publish responses against the requested workbench,
1442+
path, operation, revision, and generation. The AuthorityStore accepts even a
1443+
successful publish response only after a fresh read proves the exact persisted
1444+
transaction under the current workbench incarnation. This closes false success
1445+
at the LoopX boundary, but NoKV's current Python API does not atomically bind an
1446+
expected workspace incarnation into `publish_bytes`; preventing a write after a
1447+
concurrent remove/recreate remains an explicit provider-contract hold.
1448+
Only a successful live JSON report is evidence for that single-node Stage 2A
1449+
store-conformance run; deterministic tests are sequence tests only. This
1450+
LoopX-only candidate changes neither NoKV source nor its workbench/artifact data
1451+
model, and it does not prove runtime shadow parity, a multi-Agent canary,
1452+
authority-source promotion, HA, restart recovery, capacity, or production
1453+
routing.
1454+
14311455
## Appendix B: Handoff-Mode Decision Record (2026-08-10)
14321456

14331457
This appendix writes down a direction already agreed during the PR #2787

‎docs/architecture/rfcs/shared-goal-authority-state-provider-v0.zh-CN.md‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
- 状态:Draft,正在接受 maintainer review
44
- 最初提案方:NoKV Lab
55
- 扩展修订方:LoopX maintainer
6-
- 日期:2026-08-05;修订于 2026-09-01
6+
- 日期:2026-08-05;修订于 2026-09-02
77
- 范围:一个 provider-neutral 的 LoopX 权威合同,支持内置 file、可选 NoKV
88
与可选 PostgreSQL provider profile,用来补充
99
[`host-integration-surface-v0`](../../reference/protocols/host-integration-surface-v0.md)
1010
- 源码基线:LoopX `a0c20f1779d273e7aaa4bd3ea166d145d466e6d5`
11-
- Provider API 基线:NoKV `3d75d96965`(0.11.0 线)。Python `publish_bytes`
12-
generation-CAS 映射已在该基线的真实 NoKV stack 上手工跑过一次(见示例 README);
13-
该次运行只是映射本身的证据,不属于任何合并门槛
11+
- Provider API 基线:NoKV `7bb3ffd6512fd57d9c0f193aa6d9c5b935d77f30`
12+
(release 0.11.0、Python API 1、Holt 固定为 0.8.6)。Stage 2A 的可执行资格
13+
验证只接受这份 SDK 合同与本 checkout 的 helper;它仍是候选证据,不是合并门槛
14+
或 authority promotion
1415
- PostgreSQL 基线:TypeScript Stage 2B candidate 已实现 store contract,且已通过
1516
真实 PostgreSQL 16 transaction matrix;shared authority service、runtime caller、
1617
authentication boundary 与 authority promotion 均尚未交付
@@ -1145,6 +1146,24 @@ migration/promotion、service recovery 或 HA。
11451146
验收门通过。历史 latency 或 fault 结果只具有参考意义,不构成 durability、recovery、
11461147
HA 或 production qualification 声明。
11471148

1149+
`examples/nokv-authority-store/` 还包含一个 TEST ONLY 的 Stage 2A probe:它会
1150+
打开三个相互独立的 SDK helper 进程,验证 fresh create、精确 generation update、
1151+
一次 CAS 已落盘但响应被刻意丢弃后的回读 reconciliation、两个竞争者恰一胜出的
1152+
CAS、胜负双方的 receipt 行为,以及新进程对 receipt 与完整 history 的回读。该可
1153+
执行入口把 argv 固定为一个绝对 Python executable、解释器隔离标志 `-I`,加本
1154+
checkout 中经过评审的 helper,因此 `PYTHONPATH` 无法替换 `nokv` 模块;helper 只
1155+
接受 NoKV 0.11.0 / Python API 1,report 中重复的是这两个准入常量,而非从服务端读
1156+
回的值。它把 read metadata 与当前
1157+
workbench incarnation 对照,并针对请求的 workbench、path、operation、revision、
1158+
generation 校验 publish 回包。即使 publish 回包报告成功,AuthorityStore 也必须
1159+
重新读取并证明当前 workbench incarnation 下持久化了完全相同的 transaction,才会
1160+
接受成功。这在 LoopX 边界消除了错误成功,但 NoKV 当前 Python API 尚不能把
1161+
expected workspace incarnation 原子绑定到 `publish_bytes`;阻止 concurrent
1162+
remove/recreate 后的写入仍是明确的 provider-contract hold。只有成功的 live JSON report 才是该次单节点 Stage 2A store-conformance
1163+
运行的证据;确定性测试只证明场景序列。这个纯 LoopX 候选既不修改 NoKV 源码,也
1164+
不改变其 workbench/artifact 数据模型;它不证明 runtime shadow parity、multi-Agent
1165+
canary、authority-source promotion、HA、重启恢复、容量或生产路由。
1166+
11481167
## 附录 B:交接模式决策记录(2026-08-10)
11491168

11501169
本附录把 PR #2787 评审中已同意的方向落成文字,作为实施前置条件的一部分。
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Stage 2A NoKV AuthorityStore candidate qualification (TEST ONLY)
2+
3+
This directory contains an explicit, write-producing single-node conformance
4+
probe for the Stage 2A `NoKVAuthorityStore` candidate. It is **TEST ONLY**.
5+
LoopX does not select NoKV by importing this code, and a successful run does
6+
not connect a runtime shadow, run a multi-Agent canary, or flip an authority
7+
source.
8+
9+
The integration priority remains:
10+
11+
1. the native, full NoKV CLI as the primary operator and production surface;
12+
2. the NoKV Python SDK as the secondary programmable surface; and
13+
3. optional sidecars only as adapters around those surfaces, never as the main
14+
authority API.
15+
16+
This probe intentionally exercises the current Python SDK bridge because it is
17+
the available raw byte-CAS seam. It always starts this checkout's reviewed
18+
`NoKVJsonLinesTransport` and `nokv_jsonl_helper.py`; it has no fake, skip, or
19+
"unverified but successful" CLI path. The helper admits exactly NoKV SDK
20+
`0.11.0` / Python API `1`, and the successful report repeats both values.
21+
22+
## What it proves
23+
24+
Against one **already existing** NoKV workbench, the probe starts three
25+
independent helper processes and verifies:
26+
27+
- the selected tenant/goal path is initially absent and can be created;
28+
- the stored path generation advances from 1 to 2 under exact generation CAS;
29+
- after the generation-2 CAS lands, an injected response loss is reconciled
30+
from the durable authority envelope and operation receipt rather than from
31+
the lower-layer response;
32+
- every successful CAS response is accepted only after a fresh read proves the
33+
exact transaction in the current workbench incarnation;
34+
- two writes released together against generation 2 produce exactly one
35+
generation-3 winner and one typed conflict;
36+
- the losing operation does not acquire a durable receipt; and
37+
- a third, freshly opened transport reads the winning envelope, its complete
38+
three-entry history, the response-lost operation receipt, and the retained
39+
winner receipt.
40+
41+
If the SDK, helper, workbench, backend, CAS, or independent readback cannot be
42+
proved, the process exits nonzero. The normal test suite uses deterministic
43+
fakes only to test this sequence and does **not** count as live evidence.
44+
45+
The probe does not prove an atomic expected-incarnation publication fence,
46+
runtime shadow parity, a multi-Agent canary, authority promotion, HA, failover,
47+
restart recovery, capacity, or performance. NoKV generation can restart after
48+
workbench recreation, so the current adapter fails closed through authoritative
49+
post-write readback; preventing the stale-incarnation write itself requires a
50+
future provider primitive. The probe also does not create a workbench. A green
51+
run is Stage 2A single-node storage conformance evidence only.
52+
53+
## Inputs
54+
55+
Use a current NoKV Python environment. Keep the client configuration in an
56+
ignored local file; do not commit credentials. Static routing is valid for a
57+
single-node NoKV deployment—etcd is not required by this probe. The following
58+
shape is illustrative:
59+
60+
```json
61+
{
62+
"root_id": "00000000000000000000000000000000",
63+
"routing": {
64+
"kind": "static",
65+
"endpoint": "127.0.0.1:7412",
66+
"logical_shard_id": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
67+
"object_namespace_id": "cccccccccccccccccccccccccccccccc",
68+
"placement_generation": 1,
69+
"owner_epoch": 1
70+
},
71+
"object_store": {
72+
"kind": "s3",
73+
"bucket": "qualification-bucket",
74+
"region": "us-east-1",
75+
"root": "/loopx-qualification",
76+
"endpoint": "http://127.0.0.1:9000",
77+
"access_key_id": "set-in-your-ignored-local-file",
78+
"secret_access_key": "set-in-your-ignored-local-file",
79+
"virtual_host_style": false,
80+
"skip_signature": false
81+
}
82+
}
83+
```
84+
85+
Configuration objects are exact-key contracts. An unknown top-level, routing,
86+
or object-store key fails before an SDK routing config, object-store config, or
87+
client is constructed. In particular, a misspelled explicit credential cannot
88+
silently fall through to NoKV's ambient provider chain. Intentionally omitted
89+
optional S3 credential fields retain the NoKV SDK's normal behavior.
90+
91+
Pass only the absolute path to the Python executable that resolves the qualified
92+
NoKV SDK. The probe itself fixes the remaining argv to the interpreter isolation
93+
flag `-I` followed by the reviewed helper in this checkout; callers cannot
94+
supply a wrapper argument or an alternate helper path, and `PYTHONPATH`,
95+
`PYTHONHOME`, or user site-packages cannot redirect the `nokv` import away from
96+
that executable's own environment:
97+
98+
```text
99+
/path/to/nokv-python-environment/bin/python
100+
```
101+
102+
Choose a fresh tenant/goal pair for every run. The probe refuses to overwrite
103+
an existing authority envelope and deliberately leaves its three-generation
104+
test envelope behind for inspection. Use a disposable qualification namespace
105+
or remove it later with the native NoKV CLI according to that environment's
106+
retention policy.
107+
108+
## Run
109+
110+
From the LoopX repository root:
111+
112+
```bash
113+
node --no-warnings --experimental-strip-types \
114+
examples/nokv-authority-store/live-qualification.ts \
115+
--execute-live \
116+
--config-json /path/to/ignored/nokv-client.json \
117+
--python-executable /path/to/nokv-python-environment/bin/python \
118+
--tenant-id qualification-tenant-20260902 \
119+
--goal-id qualification-goal-20260902-01 \
120+
--workbench existing-qualification-workbench
121+
```
122+
123+
`--execute-live` is mandatory and is checked before any helper starts. Exit 0
124+
means every listed live check passed. Any unavailable, failed, ambiguous,
125+
unfenced, pre-existing, or unreadable state exits nonzero with a compact JSON
126+
reason; provider stderr, endpoints, credentials, and raw SDK errors are not
127+
copied into that result. A successful JSON report includes
128+
`"qualification_scope":"stage_2a_single_node_store_conformance"`,
129+
`"nokv_sdk_version":"0.11.0"`, and `"nokv_api_version":1`. The two version
130+
fields are the helper's admission constants: the helper refuses to open a client
131+
for any other SDK version or API version, so a successful report implies them,
132+
but they are not values read back from the NoKV server. The report is Stage
133+
2A/helper-admission evidence only, not runtime-shadow, canary, HA, or
134+
production-readiness evidence.

0 commit comments

Comments
 (0)