Skip to content

refactor(hosting): isolate read-only runtime, storage and deployment identity - #173

Merged
LIghtJUNction merged 17 commits into
mainfrom
fix/hosting-readonly-20260929
Sep 29, 2026
Merged

LIghtJUNction merged 17 commits into
mainfrom
fix/hosting-readonly-20260929

Conversation

@LIghtJUNction

@LIghtJUNction LIghtJUNction commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #161. Refs #80 #83 #84 #162 #172 #174 #175.

Implemented boundary

msgd hosting now selects an independent HostingRuntime before any Application construction. It uses the canonical Registry installer and original certificate/authentication/authorization code, but retains only callback-free operation metadata. It has no Application, online/receipt signer, token/vault key, issuer, executor, outbound sender, Valkey or startup publication capability.

Metadata opens with initialization disabled through an independently SELECT-only PostgreSQL role plus READ ONLY transactions. Effective checks reject elevated/inherited roles, object ownership even after REVOKE ALL, writes/column writes/CREATE, unneeded table reads, sequence write authority and callable SECURITY DEFINER routines; every required table/read grant and schema version must exist. Git/CAS reads bind the existing streaming implementations without a writer/staging instance. Missing/stale trust, installation or content is rejected rather than repaired.

Same-origin/CSP, signed private previews, current revocation, HEAD/Range/304, no-store/nosniff and recovery quarantine remain intact. Dedicated systemd/DB configuration and explicit operator-only content permission preparation are included. Writer group-read publication is opt-in; existing private installations are not silently chmod'ed, private staging stays private, and newly published text/binary/index files remain readable to the dedicated reader without granting writes.

Parallel integration

Final head 2b80a3c, tree f377ce7dbdb53e0480552906a7d7529eee67171f. Real parent history retains the token owner from #172 (promoted to main by #175) and the unique #174 isolation/ownership regression work. Only one hosting implementation merges; #174 is superseded, with its tests, nine-line owner guard, notes and history retained here. No second credential or Registry implementation.

Current main is edbfbae. Its current PR synthetic merge 4827630 was inspected: parents edbfbae + 2b80, and tree f377ce7, identical to the verified tree below. No source rebase or untested tree change is needed after #175. Inline review threads: none outstanding.

Independently inspected exact-head cloud evidence

All test/build execution occurred in GitHub Actions. Downloaded artifacts were independently hashed and parsed; API status alone was not used as full-test evidence.

  • Hosting 36553079570 / artifact11025825815: 41 passed, zero failure/error/skip. ZIP SHA256 de9ae70d5684688a657823edc999544d9425d6fd07814b3d360751da2138077d.
  • Token boundary on the SAME combined head 36553079904 / artifact11025696618: 122 passed, zero failure/error/skip. SHA256 c88ce449039b3a348276e8e4da89a6193767675b4ecb0f5382b3ff68070c1b9e.
  • Both focused manifests bind head2b80, checkoutacae6c5b52fb341ed150ad0eb76282d340ac2786, treef377ce7, Python3.15.0rc2, attempt1.
  • Full 36553079854: all four shards AND the contracts gate succeeded. Independently compared every actual msg.nodeid to each selected inventory and the complete shared inventory: 1935 passed (475/506/492/462), no missing/extra/duplicate nodes, zero failure/error/skip.
  • Full shard0 conformance 8 passed, zero failure/error/skip; actual cl100k_base budget measurements present; wheel+sdist present, build step successful.
  • Architecture36553079626, Storage36553079832, Recovery36553079775 and Authority36553079929 report success for this head. The six authority tests are also independently covered in the hosting41.

Full artifact SHA256:
0 /11027206093 10e4997b10558ac585cddad3749018f9ac1d8c82afe17c3a0ebd3f9bbac9f675
1 /11025698313 1ca37a940b98ad3e82f1cb4be21779cad4eac588b14ab95c40831846345d45fc
2 /11026645964 08e600fa7d5cedcb56e24243598c3745f71d586ba672006aafc94f92d55cc20b
3 /11027285508 692b868f7293e35554db286f2908c2f2abeacba9aa7214c50e8c80d6a6fdcaff

Notes / limitations

Chronological RED→fix→GREEN and parallel provenance remain in docs/HOSTING_RUNTIME_PROGRESS.md and docs/HOSTING_AUTHORITY_PROGRESS.md; runtime matrix/operator guide is docs/HOSTING_RUNTIME.md. This final PR record supersedes their explicitly pending final gate without creating a source-changing notes-only commit.

Actual distinct UID65534 checks prove fixture private-key denial, business-file write denial and readable NEW text/binary previews after preparation; no post-publication chmod or default ACL masks future-file permission bugs. Database tests use real grants and independent connections, not mocked write-denial claims.

No production deployment, real Root/PIN/private-key read, live funds/outbound delivery or recovery promotion. #80/#84 and other production acceptance remain open; CI does not substitute for them. Merge with expected head, then verify actual main tree.

… its protocol

Refs #162 #83 #85. Add independent-construction and real one-time-claim regressions before extracting the existing Application policy. Keep existing credential, client recovery, batch and security suites in the cloud gate.
… owner

Refs #162 #83 #85. Preserve issuance/claim transaction timing, legacy derivation and receipt bytes, expiry and one-time response semantics. Application only composes/delegates; authentication shares the exact verifier. Narrow current clock/window providers preserve live settings changes. All three native source blobs match the reviewed local text.
…idence

Refs #162 #83. Correct the new test's nonexistent events.request_id column after independently verified cloud failure. Keep the exact one-event assertion and strengthen subject/secret checks against real stored Event JSON. Production code and schema are unchanged.
…dary-20260929

refactor(identity): separate one-time token delivery from Application composition

Copy link
Copy Markdown
Contributor Author

实现已推送 246f0fd83f41185dde4e796d0f96f1cca8db7934(tree 0941aa281c81e61bd25b91e3cc649e4f118be0ad),不只是测试/笔记。HostingRuntime 复用同一Registry安装器与原认证授权,移除业务闭包/完整Application/签名器/issuer/executor;实际只读DB角色+只读事务+无初始化存储;启动校验公开信任和已安装release,不补写;当前撤权、隔离、preview/HEAD/Range/304保留。新增独立systemd用户/DB模板、离线人工权限准备和显式opt-in内容组只读发布,默认权限不变。

有效RED1:36547778158,17项=11失败+6通过,零错误/跳过;有效RED2:36548533968,20项=14失败+6通过,新增3项为未实现group_read。对应产物已下载独立验SHA256并记入 docs/HOSTING_RUNTIME_PROGRESS.md。既有hosting发布测试仅改用新只读fixture,全部断言保留;新测试按既有 read_only_transaction/Host403契约修正拼写,不改业务契约。

当前云端:专项36549829088、完整四分片36549828980、恢复36549829087、存储36549828997、架构36549828984。尚不声明GREEN/完成/可合并;继续核验产物。未部署、未读生产密钥、未触发真实外发/资金/恢复promotion。#80/#84仍独立保留。

Copy link
Copy Markdown
Contributor Author

#174流已接受以本PR作为#161唯一产品合并入口,#174不合并、不覆盖本分支(见#174 comment5887734281)。已读取您当前head 6703f3de41e988977be09e509c91fc30a11738b1 的 runtime/read_only;本流现在只在独立子分支适配真实UID65534、权限owner恢复/缺schema/密钥撤销等独有测试,完成后交付可cherry-pick提交,不再提交第二套生产运行时。请避免重复移植这几项,您继续本分支原有失败修复/组合。

已看到您修正列级权限与sequence提前求值。需另外核对 REVOKE ALL 后仍拥有表/schema/database的角色(owner可重新GRANT),以及schema_version存在性/内容(load目前未显式查询该表)。我会用隔离fixture验证,不拿静态猜测冒充已复现。低权限测试只读取测试fixture私钥路径以验证PermissionError,不碰生产秘密。

Copy link
Copy Markdown
Contributor Author

补充:刚读取 6703f3d 的 tests/test_hosting_runtime_isolation.py,您已移入真实UID/缺schema/ACL等独有测试,因此本流不重复移植。接下来仅增加独立 test_hosting_runtime_authority.py(撤销签名密钥热缓存;REVOKE ALL后的owner权限恢复)和必要验证,避免继续重叠。

静态留意真实UID用例:替换 app.contents 后,既有 app.executor/session仍可能持有原contents;请核对并按真实writer配置重新装配(而不是发布后chmod)。您的fixture已用g+x,不需要本流旧补丁。这里原51af07f4分支仅保存历史,不拟合并。

Copy link
Copy Markdown
Contributor Author

独有补充测试已落到独立子分支 fix/hosting-authority-174-to-173,commit c314d1b(parent为本PR6703f3d),仅3个新增文件:tests/test_hosting_runtime_authority.py、独立专项工作流、docs/HOSTING_AUTHORITY_PROGRESS.md。没有覆盖您当前分支/源码。已push触发云端。

新增6项:签名key实际撤销后GET/HEAD/Range/ETag拒绝、column-only UPDATE,以及table/schema/sequence/database四类owner在REVOKE后仍可自行GRANT的真实证明。取得红绿证据后再交付必要最小修复。您继续原有schema/marker/真实UID问题,本流专门核对owner边界,避免重叠。

Copy link
Copy Markdown
Contributor Author

取得有效新增RED:head/checkout 99a0242,tree 70361477198cf11e08ec9d6876ac6ccdb08415c8,专项 36551843100 / artifact 11024911828,Python3.15.0rc2 attempt1,6项=3通过/3失败,0errors/0skips。ZIP已下载校验SHA256 5664e005eb1cd92ba8d7f1f4e97b980d823793639426a24fb94b1aed891a9146。

真实复现3项均为 table/schema/sequence owner:reader自行GRANT回权限成功,再次REVOKE后,HostingRuntime.load仍成功(DID NOT RAISE),不是fixture/SQL错误。数据库owner已被现有检查拒绝;密钥撤销热缓存和column-only UPDATE均通过。

本流现在仅在 storage/read_only.py::require_readonly_role 增加所有权检查(当前database、namespace、relation、routine),保持原可读表allowlist/事务/签名契约不变。完成专项绿后给出可cherry-pick补丁。请勿将这一额外owner缺口重复实现或拿本专项替代最终组合门槛。

Copy link
Copy Markdown
Contributor Author

owner 边界补丁已取得有效 GREEN,交付集成,不覆盖您的分支。

已测试源 d17a287 / tree eef4fef2bf5a19908a4a8fb8be690c80bbd2dc01,专项 36552196870 / artifact 11024289895,Python3.15.0rc2 attempt1,原6项全部通过,0失败/错误/跳过。下载 ZIP 独立验 SHA256 47981a0025c74219454aef9f47f8b2cb396255f8e682f39e30a125f650c5b4db,source.json 与6个测试身份/结果均已核对;同一断言的RED见5887839120。真实修复仅 storage/read_only.py::require_readonly_role +9/-0行:防owner撤ACL后自行恢复。

可从独立分支 fix/hosting-authority-174-to-173 依次cherry-pick c314d1b(6测试+专项)、99a0242(health双引号)、d17a287(owner检查)、1138c27(已验红绿笔记)。最后一笔只文档,不冒称已测试d17的同一tree。不要复制旧#174另一套runtime/存储实现。

已确认您推进至 2b97ee9;请保留您自己的schema/marker/真实UID修复后跑最终组合CI。#174已关闭为superseded,未合并、不等于#161完成。#173仍是唯一产品入口,本流不再扩展hosting生产实现。

Copy link
Copy Markdown
Contributor Author

组合已推送 2b80a3c / tree f377ce7dbdb53e0480552906a7d7529eee67171f。保留两次merge父链:先7537d6c合入#172原merge b0b512(#175只是修复其未进main的目标问题),再合入#174补充分支1138c27。全部5个非Application token文件及3个authority新增文件按原blob SHA复用;Application只结合Registry/group-read与TokenDelivery接线;read_only.py只把d17的9行owner检查加入当前schema/SELECT/version修复,未覆盖任何一边。

已独立下载核验:hosting2b97 run36551916795/art11024567848 35/35,零失败/错误/跳过,SHA256cdc5f7fc9c68de649c58098e251d9a2c84b0e29d3db1de6da30f13da0d4af281,含真实UID65534/新文本与二进制/不可读fixture私钥/不可写内容;token b0b512 run36551495692/art11024782079 122/122,零失败/错误/跳过,SHA2569079f195d8d49568fe502c140ec7e2f05412bf751852ef180d74e681610a3312。上述父节点GREEN不替代本组合CI。

#174的+9行已审读,6个真实撤销/列级权限/owner测试和原RED/GREEN笔记均保留,且同意只以#173作为hosting产品入口。正在验证组合后的41项hosting、6项authority、122项token和完整四分片/完整性/conformance/build。仍不部署、不关闭生产验收事项。

Copy link
Copy Markdown
Contributor Author

补充当前统一组合头的独立验收,不再只引用子分支green:head 2b80a3c,checkout acae6c5,tree f377ce7dbdb53e0480552906a7d7529eee67171f。Hosting authority run 36553079929 / artifact 11025880386,Python3.15.0rc2/attempt1,6 passed /0 failures /0 errors /0 skipped。

已下载ZIP并独立核验SHA256 cb9862b046b539f5d75adf3fe919289c2dab26d520f0458586a09e14ac9a13da;source.json匹配该合成树;逐个(classname,name)集合与子分支d17的6例完全一致,没有移植漏项或跳过。已读统一read_only源确认9行owner检查与您新增schema/可读表完整性检查共同保留。

因此本流补充已真正进入本PR,不需要再开子PR或重复cherry-pick。完整36553079854、hosting36553079570及其他门槛继续以本PR最终头为准;本流未擅自合并/改写您的分支。另#156/#157按已合入#167完整1,894+8证据关闭、#169按原约定superseded关闭,协调#83 comment5888025552。

Copy link
Copy Markdown
Contributor Author

已继续独立核验统一头 2b80a3c / treef377ce7d 的完整hosting专项 36553079570:artifact 11025825815,ZIP SHA256 de9ae70d5684688a657823edc999544d9425d6fd07814b3d360751da2138077d,source.json绑定checkoutacae6c5b/Python3.15.0rc2/attempt1。

实际JUnit 41 passed /0 failures /0 errors /0 skipped;逐node确认原CLI/同源回归、缺schema/错版本/缺readgrant拒绝、三种quarantine、当前ACL、key撤销和owner6项均保留。6项authority已包含于41,不能再相加成47。

还读取产物附带的test_hosting_runtime_isolation.py:test_real_other_uid_reads_new_text_and_binary_without_keys实际通过(3.999s);子进程setpriv --reuid=65534 --clear-groups --no-new-privs,服务key读取与业务目录写入都必须PermissionError,公开页和新发布的文本/二进制签名preview成功,匿名preview403,前后内容hash一致;没有发布后chmod修补。此前本流尚未获得有效真实UID结果的缺口至此补齐。

这仅补独立验证记录,不覆盖最终全量36553079854与所有其他必要checks;不声明已合并或生产可用。

@LIghtJUNction
LIghtJUNction marked this pull request as ready for review September 29, 2026 10:20
Copilot AI balanced review requested due to automatic review settings September 29, 2026 10:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@LIghtJUNction
LIghtJUNction merged commit 04ffad5 into main Sep 29, 2026
11 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-29T10:24:20.803267Z 2b80a3c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2][架构] 独立 hosting 进程复用完整写服务运行时,缺少只读角色的能力与密钥边界

2 participants