Skip to content

crypto: support --use-system-ca on non-Windows and non-macOS - #57009

Merged
nodejs-github-bot merged 3 commits into
nodejs:mainfrom
joyeecheung:certs-others
Feb 15, 2025
Merged

nodejs-github-bot merged 3 commits into
nodejs:mainfrom
joyeecheung:certs-others

Conversation

@joyeecheung

@joyeecheung joyeecheung commented Feb 12, 2025 •

Copy link
Copy Markdown
Member

crypto: support --use-system-ca on non-Windows and non-macOS

On other platforms, load from the OpenSSL default certificate
file and diretory.
This is different from --use-openssl-ca in that it caches
the certificates on first load, instead of always reading
from disk every time a new root store is needed.

When used together with the statically-linked OpenSSL, the
default configuration usually leads to this behavior:

  • If SSL_CERT_FILE is used, load from SSL_CERT_FILE. Otherwise
    load from /etc/ssl/cert.pem
  • If SSL_CERT_DIR is used, load from all the files under
    SSL_CERT_DIR. Otherwise, load from all the files under
    /etc/ssl/certs

I've only checked Ubuntu and RHEL so far. It may be worth checking whether this works on other popular distributions - from what I can tell, though, it seems the hard-coded configurations always leads to default locations under /etc/ssl/, which seems to be a location that most Linux distros would either use or link to anyway - for example, Ubuntu symlinks all the managed certificates to files under /etc/ssl/certs, while RHEL 9 just bundles all managed certificates to /etc/ssl/certs/ca-bundle.crt, so the current approach would usually just work.

If this somehow turns out to be sufficient, we can come back adding specific fallbacks for other systems similar to what go does which is basically listing all the directories that are known to be used for this purpose - but from what I can tell this can be slow and lead to duplicates since they might get symlinked to each other, so ideally if X509_get_default_cert_dir() and X509_get_default_cert_file() works on a platform, it's better not to look further to avoid unnecessary costs.

There is also the question of whether we should use NSS shared DB, like what Chrome does, but since most command line tools rely on the directory/file-based system-wide storage instead (like go listed above, and e.g. every rust tool using the rustls-native-certs crate), and it seems to be losing the point if we statically link NSS, I didn't go with this route. In any case it seems various distros already consolidates the NSS shared DB somehow into these default locations when they manage their certificate stores, or at least NSS DB can be loaded via environment variable overrides, so the current approach looks good enough.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Feb 12, 2025
@joyeecheung
joyeecheung marked this pull request as draft February 12, 2025 01:25
@codecov

codecov Bot commented Feb 12, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 2.43902% with 40 lines in your changes missing coverage. Please review.

Project coverage is 89.09%. Comparing base (79f96b6) to head (76aaa29).
Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_context.cc 2.43% 40 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57009      +/-   ##
==========================================
- Coverage   89.10%   89.09%   -0.02%     
==========================================
  Files         665      665              
  Lines      193203   193245      +42     
  Branches    37220    37223       +3     
==========================================
+ Hits       172158   172167       +9     
- Misses      13771    13807      +36     
+ Partials     7274     7271       -3     
Files with missing lines Coverage Δ
src/crypto/crypto_context.cc 65.19% <2.43%> (-2.84%) ⬇️

... and 24 files with indirect coverage changes

@joyeecheung
joyeecheung marked this pull request as ready for review February 13, 2025 21:46
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Feb 13, 2025
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Feb 13, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread src/crypto/crypto_context.cc Resolved
@joyeecheung
joyeecheung force-pushed the certs-others branch 2 times, most recently from c78e1bb to 0d6c04a Compare February 13, 2025 23:46
On other platforms, load from the OpenSSL default certificate
file and diretory.
This is different from --use-openssl-ca in that it caches
the certificates on first load, instead of always reading
from disk every time a new root store is needed.

When used together with the statically-linked OpenSSL, the
default configuration usually leads to this behavior:

- If SSL_CERT_FILE is used, load from SSL_CERT_FILE. Otherwise
  load from /etc/ssl/cert.pem
- If SSL_CERT_DIR is used, load from all the files under
  SSL_CERT_DIR. Otherwise, load from all the files under
  /etc/ssl/certs
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Feb 13, 2025
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Feb 13, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@joyeecheung

Copy link
Copy Markdown
Member Author

CI is green. @jasnell @addaleax maybe you'll be interested in reviewing this since you've reviewed support for other systems?

Comment thread doc/api/cli.md Resolved
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Feb 14, 2025
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Feb 14, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread src/crypto/crypto_context.cc Resolved
@nodejs-github-bot
nodejs-github-bot merged commit 579fc67 into nodejs:main Feb 15, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 579fc67

targos pushed a commit that referenced this pull request Feb 17, 2025
On other platforms, load from the OpenSSL default certificate
file and diretory.
This is different from --use-openssl-ca in that it caches
the certificates on first load, instead of always reading
from disk every time a new root store is needed.

When used together with the statically-linked OpenSSL, the
default configuration usually leads to this behavior:

- If SSL_CERT_FILE is used, load from SSL_CERT_FILE. Otherwise
  load from /etc/ssl/cert.pem
- If SSL_CERT_DIR is used, load from all the files under
  SSL_CERT_DIR. Otherwise, load from all the files under
  /etc/ssl/certs

PR-URL: #57009
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
acidiney pushed a commit to acidiney/node that referenced this pull request Feb 23, 2025
On other platforms, load from the OpenSSL default certificate
file and diretory.
This is different from --use-openssl-ca in that it caches
the certificates on first load, instead of always reading
from disk every time a new root store is needed.

When used together with the statically-linked OpenSSL, the
default configuration usually leads to this behavior:

- If SSL_CERT_FILE is used, load from SSL_CERT_FILE. Otherwise
  load from /etc/ssl/cert.pem
- If SSL_CERT_DIR is used, load from all the files under
  SSL_CERT_DIR. Otherwise, load from all the files under
  /etc/ssl/certs

PR-URL: nodejs#57009
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
RaisinTen added a commit to RaisinTen/node that referenced this pull request Mar 13, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  nodejs#56599 landed in v23.8.0.
- Windows support nodejs#56833
  landed in v23.8.0
- non-Windows and non-macOS support
  nodejs#57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
nodejs-github-bot pushed a commit that referenced this pull request Mar 15, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  #56599 landed in v23.8.0.
- Windows support #56833
  landed in v23.8.0
- non-Windows and non-macOS support
  #57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #57432
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
aduh95 pushed a commit that referenced this pull request Mar 18, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  #56599 landed in v23.8.0.
- Windows support #56833
  landed in v23.8.0
- non-Windows and non-macOS support
  #57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #57432
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 1, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  #56599 landed in v23.8.0.
- Windows support #56833
  landed in v23.8.0
- non-Windows and non-macOS support
  #57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #57432
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
aduh95 pushed a commit that referenced this pull request Apr 2, 2025
On other platforms, load from the OpenSSL default certificate
file and diretory.
This is different from --use-openssl-ca in that it caches
the certificates on first load, instead of always reading
from disk every time a new root store is needed.

When used together with the statically-linked OpenSSL, the
default configuration usually leads to this behavior:

- If SSL_CERT_FILE is used, load from SSL_CERT_FILE. Otherwise
  load from /etc/ssl/cert.pem
- If SSL_CERT_DIR is used, load from all the files under
  SSL_CERT_DIR. Otherwise, load from all the files under
  /etc/ssl/certs

PR-URL: #57009
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit that referenced this pull request Apr 3, 2025
On other platforms, load from the OpenSSL default certificate
file and diretory.
This is different from --use-openssl-ca in that it caches
the certificates on first load, instead of always reading
from disk every time a new root store is needed.

When used together with the statically-linked OpenSSL, the
default configuration usually leads to this behavior:

- If SSL_CERT_FILE is used, load from SSL_CERT_FILE. Otherwise
  load from /etc/ssl/cert.pem
- If SSL_CERT_DIR is used, load from all the files under
  SSL_CERT_DIR. Otherwise, load from all the files under
  /etc/ssl/certs

PR-URL: #57009
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit to RafaelGSS/node that referenced this pull request Apr 8, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  nodejs#56599 landed in v23.8.0.
- Windows support nodejs#56833
  landed in v23.8.0
- non-Windows and non-macOS support
  nodejs#57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: nodejs#57432
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 14, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  #56599 landed in v23.8.0.
- Windows support #56833
  landed in v23.8.0
- non-Windows and non-macOS support
  #57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #57432
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
aduh95 pushed a commit that referenced this pull request Apr 14, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  #56599 landed in v23.8.0.
- Windows support #56833
  landed in v23.8.0
- non-Windows and non-macOS support
  #57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #57432
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
aduh95 pushed a commit that referenced this pull request Apr 15, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  #56599 landed in v23.8.0.
- Windows support #56833
  landed in v23.8.0
- non-Windows and non-macOS support
  #57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #57432
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 16, 2025
On other platforms, load from the OpenSSL default certificate
file and diretory.
This is different from --use-openssl-ca in that it caches
the certificates on first load, instead of always reading
from disk every time a new root store is needed.

When used together with the statically-linked OpenSSL, the
default configuration usually leads to this behavior:

- If SSL_CERT_FILE is used, load from SSL_CERT_FILE. Otherwise
  load from /etc/ssl/cert.pem
- If SSL_CERT_DIR is used, load from all the files under
  SSL_CERT_DIR. Otherwise, load from all the files under
  /etc/ssl/certs

PR-URL: #57009
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 16, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  #56599 landed in v23.8.0.
- Windows support #56833
  landed in v23.8.0
- non-Windows and non-macOS support
  #57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #57432
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 17, 2025
On other platforms, load from the OpenSSL default certificate
file and diretory.
This is different from --use-openssl-ca in that it caches
the certificates on first load, instead of always reading
from disk every time a new root store is needed.

When used together with the statically-linked OpenSSL, the
default configuration usually leads to this behavior:

- If SSL_CERT_FILE is used, load from SSL_CERT_FILE. Otherwise
  load from /etc/ssl/cert.pem
- If SSL_CERT_DIR is used, load from all the files under
  SSL_CERT_DIR. Otherwise, load from all the files under
  /etc/ssl/certs

PR-URL: #57009
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 17, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  #56599 landed in v23.8.0.
- Windows support #56833
  landed in v23.8.0
- non-Windows and non-macOS support
  #57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #57432
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
RafaelGSS pushed a commit that referenced this pull request May 1, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  #56599 landed in v23.8.0.
- Windows support #56833
  landed in v23.8.0
- non-Windows and non-macOS support
  #57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #57432
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
RafaelGSS pushed a commit that referenced this pull request May 2, 2025
These are the PRs for --use-system-ca:
- initial implementation of the option with just macOS support
  #56599 landed in v23.8.0.
- Windows support #56833
  landed in v23.8.0
- non-Windows and non-macOS support
  #57009 landed in v23.9.0

This change documents the history info.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #57432
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
ajenchen added a commit to ajenchen/design-system that referenced this pull request Nov 26, 2026
)

* feat(governance): 交接常備與額度用法寫進 SSOT,user 提到額度時 hook 自動提醒

user 11-25:「這個上一次就講過了,難道沒有在工作規範ssot內嗎?為何還要我一直講?」—— 交接與額度的要求散在各次對話裡、沒進正本,每個 session 都要 user 重講。

- governance/memory/feedback_orchestration_verify_before_scale.md 加「交接常備與額度」一節,只三條:交接常備(任何時刻停下都能被別的 session / provider 接手,放 repo 的 tmp/ 與已推分支)、額度(user 說剩多少就照優先序用到約剩 1–3%,不提早停、不囤,快重置就用完)、效率(指向「分診與預算」與 work-process.md,不重述)。Why 逐字引 user 六句原話(日期 + session 前 8 碼,已對照對話紀錄逐字比對);1–3% 只在 11-25 那句有原文。MEMORY.md 索引同步。
- AGENTS.md「分診與預算」段尾加一句指向;同段刪掉重複的「,不開工」(「只開工 ①②③」已涵蓋)。開場 bytes 淨增 78,check-agents-bootstrap.mjs A6 上限明改 76,803 → 76,881,理由寫在上限旁。
- check_propose_without_benchmark.sh(既有 UserPromptSubmit hook,不新增 hook 檔)加第三件事:同一子句提到額度 / quota,又帶百分比或「重置 / 用完 / 用光 / 快沒 / 剩」→ 注入一行指向上面那節;Netlify 等第三方免費額度的子句不觸發。
- test_check_propose_without_benchmark.sh 加 10 格:該觸發 4、不該觸發 4、弄壞判斷式的對照組 2。另把 hook 的判準實際改壞一次,整支測試 5 格紅,還原後 22/22 綠。
- test-check-agents-bootstrap.mjs:A8 fixture 照抄分診段時,替該段引用的檔補樁 —— 否則死鏈檢查讓 10 個應綠的格子假紅。
- governance:generate 重生 control-plane lock 與 generated。

不改 work-process.md、不新增 hook 檔、不動產品程式。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyfCTGphdMtHsYCxamP4cK

* fix(額度提醒): 逗號不再把額度字與訊號詞拆開 —— 「我的額度,還剩 21%」也會注入(規格核對必修 Q3)

規格 Q3 的條件是「user 訊息提到額度 / quota,而且帶百分比或重置 / 用完 / 快沒 / 剩」。
原判準連中英逗號也拿來切子句,額度字與訊號詞必須落在同一個逗號子句,實測「我的額度,還剩 21%」不注入。

- check_propose_without_benchmark.sh:先以 。!?;!?; 與換行切句(QUOTA_SENTENCE_RE),句內再以 ,, 切子句(QUOTA_CLAUSE_RE);
  帶排除詞(netlify / vercel / github actions / 免費)的子句整個不算,同一句其餘子句有額度字、也有訊號詞才注入。
  檔頭判準說明跟著改。
- 測試:加 Test 23(「我的額度,還剩 21%」→ 注入)、Test 24(Netlify 子句的訊號詞不借給同句另一個額度子句 → 不注入)、
  Test 25(額度與訊號詞被問號分在兩句 → 不注入);對照組 Test 26 把逗號放回分句 → Test 23 的樣本認不到(證明會紅)。
  Test 13–22 結果不變。
- governance/memory/feedback_orchestration_verify_before_scale.md「機械提醒」改成「同一句(逗號不分句)」並附例。
- governance:generate 重算 control-plane 指紋(lock / PROVENANCE / control-plane.json)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyfCTGphdMtHsYCxamP4cK

* chore(governance): release-rings 回到「兩次候選之間」—— 登記新產品 consumer 的前置狀態

- infra/governance/release-rings.json:candidateRelease 設為 null,三筆 assignment 的 candidateReleaseDigest 同步設為 null;其餘位元不動
- 為什麼:受審登記流程(consumerctl plan-registration)只在兩次候選之間開放(consumerctl.mjs:315「Consumer registration is allowed only between release candidates」);beta.145 這筆候選是 a9b6859 為了 work-management 的 full-snapshot 升級放的 Step 0,而 work-management 要退場
- 讀這個欄位的地方(全列):plan-registration(要 null)、plan-bootstrap / plan-control-plane-update(要非 null;之後要走這兩條路時照前例 #68 / #81 / #165 先把候選推到目標版)、planConsumerFanout(已退役)、reconcile-github 與 model-validation(兩種狀態都接受)、managed-host-assurance(null 時回報 releaseBinding 缺)
- 這一筆是中間狀態:generated 檔在本分支最後一筆一起重算

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyfCTGphdMtHsYCxamP4cK

* feat(governance): 登記 ajenchen/workspace 為受管產品 consumer —— 照受審登記提案原樣套用兩份 after-image

user 2026-11-25 原話:「此外,設計系統 repo 要把 canary 換成 ajenchen/workspace,換過來之後,設計系統出新版時,這個 repo 也會自動收到升級 PR。」

- 提案由 consumerctl plan-registration 產生(repo-id workspace / private / main / ../../../workspace / ring-2-product-canary / canary / entered-at 2026-11-25T15:48:00.000Z),proposalDigest 59e26f7bf9353f698e877982543e180a31cbe3c57ec47b594bdb31e74e33cade
- infra/governance/inventory/managed-repos.json:新增 workspace(product-consumer、new-snapshot-v2);內容雜湊 = 提案 after.inventorySha256 13a7648845faf0d56c70af4775fbc42cfd115351a65baaf6e2c78d487a8ecfc5
- infra/governance/release-rings.json:新增 workspace 的 assignment,onboarding manual blocker 原樣保留(提案明文:登記 PR 不得清掉);內容雜湊 = 提案 after.releaseRingsSha256 062a730c528572de894ff7a7fe642e7713617a24ff6abfa1396238db66928011
- 可重現:在前一筆 commit 上跑同一條 plan-registration 會得到同一個 proposalDigest;check-registration 在前一筆上通過,竄改過的提案(清掉 blocker)被拒
- workspace 的可見性 / 預設分支 / 必過檢查是 2026-11-25 用發版自動化同一把憑證唯讀讀回的(private、main、Verify consumer)
- 這一筆是中間狀態:work-management 的移除與 generated 檔在本分支下一筆

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyfCTGphdMtHsYCxamP4cK

* feat(release): 產品 canary 換成 ajenchen/workspace —— 發版自動開升級 PR、合併由它決定;work-management 自設定與現行規則移除

user 2026-11-25 原話:「此外,設計系統 repo 要把 canary 換成 ajenchen/workspace,換過來之後,設計系統出新版時,這個 repo 也會自動收到升級 PR。」「work-management 那個 repo不要了可以刪掉了」

設定正本
- infra/governance/release-workflow.json:consumers 的 work-management 那一筆換成 ajenchen/workspace(upgrade: automatic、delivery: repository-dispatch-pr、merge: consumer-owned;必過檢查照舊是 audit.yml 的 Verify consumer)
- infra/governance/inventory/managed-repos.json、infra/governance/release-rings.json:work-management 的登記整筆移除;certificationCanaries.product-consumer 指向 workspace;ring-2 的用途句改名(workspace 的登記在前兩筆 commit,走 consumerctl plan-registration 的受審提案)
- infra/governance/schemas/release-workflow.schema.json:兩種 consumer 形狀都加 merge(automatic / consumer-owned)
- scripts/standard-ci-evidence-plan.json:產品 consumer 改成 workspace,加 consumerOwnedStatus

為什麼選 repository-dispatch-pr:release-published-pr 是設計系統自己的 mirror workflow 把整棵 template 鏡像 rsync --delete 蓋到目標 repo(目標寫死 ds-product-template),套在產品 repo 會把產品自己的程式蓋掉;repository-dispatch-pr 是 consumer 自己的接收 workflow 在它自己的樹上跑 exact-version 升級,orchestrator 再用發版憑證開 PR(這樣 audit.yml 才會在 PR 上跑)。

「只開 PR、不等合併」(AI 的工程判斷,不是 user 逐字指定)
- 原本的模型只有一種完成條件:orchestrator 合併升級 PR 並讀回 protected main。套在產品 canary 上,設計系統的發版就得等別的產品合併、它的檢查紅了發版也跟著紅 —— AGENTS.md「Decision/Engineering Authority」明文 preview-canary 不得進標準五步的 blocking graph。
- scripts/lib/release-consumer-selection.mjs:加 consumerMergeMode / consumerBlocksRelease(唯一實作;orchestrator 與深度稽核證據共用)
- scripts/release-orchestrator.mjs:第五步的狀態只看 consumerBlocksRelease 的 consumer;合併 / 丟錯那條路只走它們。merge: consumer-owned 的 consumer 走 advanceConsumerOwnedUpgrades:派工 → 分支出現後開 PR → 到此為止(判定表 consumerOwnedStepAction 沒有「合併」這個輸出),讀不到它或動作失敗只印出來、不往上丟。五步完成後最多再看 5 分鐘(consumerOwnedFollowUp;--no-wait 不等),期限到照實回報、仍以完成結束。回報多一段 consumerOwnedUpgrades(版本、PR 連結、必過檢查)。設定層另擋「每個 consumer 都 consumer-owned」(完成條件變空集合)。
- scripts/lib/standard-ci-evidence.mjs、standard-ci-evidence-live-observer.mjs、scripts/schemas/standard-ci-evidence-observation.schema.json:dim 64/66 的證據把它記成 consumerSelection.consumerOwned,不要求、也不接受它「已合併」的證據(否則稽核會逼人去合併別人的 PR)

測試(每支仍在測原本那件事)
- infra/governance/test/release-workflow.test.mjs:on-request 的機制測試改用合成的 on-request consumer(現行設定已沒有);新增三支「產品 canary」測試,含對照組(拿掉 merge 就卡 pending)。另跑過三個破壞:consumerBlocksRelease 恆真、第五步拿掉 filter、canary 那條路加回合併 —— 各紅 2 / 2 / 1 支
- scripts/test-standard-five-step-ci-evidence.mjs:on-request 那一組改讀「只改一格的設定副本」(validator 從 repoRoot 讀設定);新增現行設定的 consumer-owned 一組;validator 的判斷式弄壞時紅 5 支
- infra/governance/test/model-validation.test.mjs、repository-path-topology.test.mjs、workflow-identity-sync.test.mjs:現行產品 consumer 的名字與路徑跟著換;舊制 id 不得自稱 new-snapshot 那道防線改用合成的一筆驗,加對照組
- infra/governance/test/consumerctl.test.mjs:legacy bootstrap / control-plane 測試改用 legacyFleetInventory()(把現行清冊的產品那一筆換回舊制形狀),其餘邏輯不動
- scripts/test-sync-all-transaction.mjs:暫存目錄名改中性名

規則、記憶、文件
- AGENTS.md:第五步那一列與工程決策那一列(開場位元組上限 76691,改後 76690)
- governance/memory:project_provider_neutral_governance.md(產品 canary 身分與操作、它那邊還缺接收 workflow)、feedback_solo_dev_workflow.md、MEMORY.md 索引
- CONTRIBUTING.md、.changeset/README.md、docs/npm-native-staged-release.md、infra/governance/README.md、external-assurance-checklist.md、design-system-audit SKILL.md 的 dim 64/66、audit-prompts.md、phase-z、deep-audit-cross-codex SKILL.md、scripts/audit-coverage-matrix.mjs、consumer-fullsnapshot-upgrade.mjs 與 template docs 的用法範例
- infra/governance/providers/certifications.json:product-consumer 幾筆「還沒測」的敘述改指 workspace;唯一一筆拿 work-management 的 run 當 pass 的檢查改回 not-tested(那份證據不屬於現在的 canary)
- generated:npm run governance:generate 重算

沒改(判定見完成報告):upgrade: on-request 機制與 LEGACY_PRODUCT_REPOSITORY_IDS / schema 的舊制防線(保留,可能多餘待判);歷史文件與歷史出處註解;packages/design-system/src 內四處(受 UI/UX 編輯閘保護,且屬歷史出處或待判的外部登記);harness-registry.json、scripts/fork-role-sources/AGENTS.product.md、packages/governance/README.md 的三句「WM」現況敘述(會連動出貨語料與契約摘要,時間預算內沒做)

workspace 讀回(2026-11-25,發版自動化同一把憑證,唯讀):private、main、template_repository = ajenchen/ds-product-template、ruleset main-protection 要求 Verify consumer(GitHub Actions)、裝著 0.1.0-beta.149;.github/workflows 只有 audit.yml —— **沒有接收升級的 workflow**,在它補上之前第五步只會回報「升級 PR 還沒開出」,不影響設計系統發版。

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyfCTGphdMtHsYCxamP4cK

* test(governance): 釘住 phase-z consumer 規則那句的斷言跟著文件改成新規則

- infra/governance/test/consumerctl.test.mjs「fleet fanout enumerates…」開頭那幾行斷言原本釘的是「WM 只在 user 要求時升級」那一句;文件(phase-z-cross-repo-ssot-propagation.md 第 5 步)在前一筆已改成新規則,斷言跟著改:template 每次合併並讀回、產品 canary ajenchen/workspace 每次只開升級 PR 且不是完成條件、不得寫回「產品 consumer 的 PR 每次由發版合併」
- 為什麼分開一筆:前一筆 commit 之後跑完整 infra/governance 測試才抓到這支紅(單獨重跑該支:修前紅、修後綠)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyfCTGphdMtHsYCxamP4cK

* chore(governance): control-plane 快照跟著前一筆的測試檔重算

- governance/control-plane.lock.json、governance/generated/control-plane.json、governance/generated/PROVENANCE.md:npm run governance:snapshot:generate 重算
- 為什麼:前一筆改了 infra/governance/test/consumerctl.test.mjs,它是 control-plane 快照的輸入;沒重算時 npm run governance:check 在 GOV-SNAPSHOT-001 紅(實測),重算後綠

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyfCTGphdMtHsYCxamP4cK

* fix(governance): canary 核對必修 1、2 —— 稽核判準與其他現況句不再寫 WM

必修 1(稽核判準正本):
- audit-prompts.md:1318 成立條件改成「template 恆在;產品 canary 記成
  consumerSelection.consumerOwned,不交已合併證據」
- design-system-audit SKILL.md:186(dim 64)改成「產品 canary 記成
  consumerSelection.consumerOwned,禁止為了讓 dim 64/66 變綠而去合併它的 PR」
- 同檔 :188(dim 66 (e))template/WM → template/workspace

必修 2(其他現況句):
- scripts/fork-role-sources/AGENTS.product.md:103 改中性寫法、不寫 repo 名
  (出貨到下游產品的 fork AGENTS.md / template AGENTS.md 由生成器跟著改)
- packages/governance/README.md:89 WM → A product consumer
- harness-registry.json:547 與 harness-authority-contracts.json:1200
  逐字相同改成 product canary(registry 內的 sha256 與 compatibility-matrix
  的 registrySha256 跟著重算)
- infra/governance/README.md:110、:191 WM → product consumer;同檔 :34 同類
  現況句一併改(核對報告沒列,同一檔同一類句子)

非必修第一條:AGENTS.md:110「讀回 consumer protected main」→ template,
位元組數不變(22541)。

.claude / .agents 副本、fork lock、template lock、control-plane 快照全由
governance:generate 產生。

驗證:governance:generate 冪等(再跑一次 diff 不變)、governance:check PASS、
check:agents-bootstrap PASS、node --test infra/governance/test/*.test.mjs
369 支 368 過,唯一紅是改動前就紅的 GOV-PROVIDER-CLI-TOOLCHAIN-001。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* fix(setup): 鎖定安裝鏈改信「內建 CA + 主機系統憑證庫」—— 下游 Claude Code 雲端 setup:all 必定 SELF_SIGNED_CERT_IN_CHAIN(P0)

根因(逐一讀程式查證):
- scripts/lib/governance-dependency-bootstrap.mjs HOSTILE_NAME 剝除 NODE_EXTRA_CA_CERTS / SSL_CERT_FILE / SSL_CERT_DIR /
  NODE_OPTIONS / 代理變數;createIsolatedGovernanceNpmEnvironment 寫 strict-ssl=true;鎖定 npm 以 process.execPath 啟動,
  Node 預設只信內建 Mozilla bundle → TLS 被重新簽的主機(代理 CA 只在系統憑證庫)鎖定 npm 一定連不上。
- 同族:父行程以 Node HTTPS 下載 npm tarball 與修補層(verified-exact-npm-runtime.mjs downloadCanonicalRegistryTarball)也只信
  Node 預設;Setup script 階段若沒有 NODE_EXTRA_CA_CERTS,連下載都會失敗。

修法(威脅模型不變:環境變數仍不可信):
- verified-exact-npm-runtime.mjs 新增唯一入口 verifiedNpmNodeArgv():鎖定 npm 子行程以 --use-system-ca 啟動;
  本行程下載明確傳 ca = tls.getCACertificates('bundled') + ('system'),不用 'default'(含 NODE_EXTRA_CA_CERTS)。
  出處:Node 官方 cli.md(--use-system-ca added v22.15.0;Linux 支援 nodejs/node#57009 於 22.15.0 帶入)、tls.md
  (getCACertificates added v22.15.0 / v23.10.0);官方 Linux 執行檔 OPENSSLDIR=/etc/ssl(strings 實測 v24.14.0)。
- 同族呼叫點全改走 verifiedNpmNodeArgv:bootstrap(ci / audit signatures / 高風險 audit / 差集 audit)、
  setup-provider-cli-toolchain、install-candidate-dependencies、run-verified-npm、verify-upgrade-evidence(consumer 升級重建)。
  未改:release-npm-publish / readback / finalize-verify(GitHub-hosted runner、以 shebang 直接執行 npm),寫在測試註解。
- 不抬高契約最低 Node(維持 22.13.0):consumer 的 package.json 與 lock 的 engines 必須逐字等於 >=minimumNodeVersion
  (fork/consumer/governance-check.mjs GOV-RUNTIME-001、refresh-fork-launchers.mjs:1212、setup-governance.mjs:462),
  沒有任何升級程式會改寫 consumer engines;抬高 = 每個既有 consumer 升級後一起紅。改為依 Node 版本啟用
  (nodeReadsSystemTrustStore:22.15+ / 23.10+ / 24+),22.13–22.14 行為與修前相同,文件寫明重新簽 TLS 的主機需 22.15.0+。

回歸測試(擴既有測試,不新增閘檔):
- test-verified-exact-npm-runtime.mjs:argv 判定表、信任錨組成(不讀 extra/default)、下載把錨交給 HTTPS、同族呼叫點掃描、
  真 TLS 對照組(剝光環境變數、探針 CA 只在系統庫:對照臂必紅、子行程與下載兩臂必綠;CA 未入庫時三臂都必紅)。
- 系統憑證庫要 sudo、harness 測試不得執行 openssl / sudo → 在 ci.yml「Cloud portability gates」步驟準備憑證、
  untrusted / trusted 各跑一次、跑完移除。本機 macOS 不能改鑰匙圈:該題 skip「儀器無法執行」(本機已跑 untrusted 態通過、
  trusted 態在未入庫時確實紅),綠燈的那一半交給 CI。
- 其餘 fake-runner 測試改成先驗 --use-system-ca 前綴再取 npm 參數。

文件(Claude Code 官方文件查證:https://code.claude.com/docs/en/cloud-environments#setup-scripts、
https://code.claude.com/docs/en/web-quickstart#setup-script-failed):Setup script 以 root 在 Ubuntu 24.04、clone 之後
Claude Code 啟動之前執行;非 0 退出會讓 session 起不來或缺東西;環境變數此時尚未設定;官方未寫工作目錄。
template README、docs/01-first-time-setup.md、consumer-governance.md(ds-canonical 與 template 兩份)改成「該 repo 專用環境 +
自己找 checkout 的 script」並寫明 TLS 條件;template onboard-banner 的過時 >=22.12.0 改成契約值 >=22.13.0。

檢查:node --test test-verified-exact-npm-runtime / test-setup-governance / test-install-candidate-dependencies /
test-setup-provider-cli-toolchain / test-verify-upgrade-evidence / test-setup-workspace / test-product-template-scaffold-lock /
test-sync-all-transaction / test-fork-governance / authority-setup / harness-registry / provider-surface / ci-workflow-scope /
workflow-identity-sync / test-workflow-security / test-cloud-portability-invariants 全綠;governance:generate + governance:check PASS;
test:gate-reachability、repository hygiene PASS。既有紅(基線同樣紅,非本包):test-release-bom 1、provider-runtime-conformance 2。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* fix(setup): P0 規格核對必修四項 —— Playwright 下載同族補上信任旗標、系統憑證庫改在環境清空的子行程讀、Claude 開場檔 Setup script 指示更正、補 Windows 平台說明

1. 同族下載點漏查(規格漏做):DS repo 自己的 setup:all(scripts/setup-authority-governance.mjs:188-189)在剝除後的環境
   跑 scripts/ensure-playwright-browsers.mjs,Playwright CLI 以 Node HTTPS 下載 Chromium(playwright-core 1.59.1
   lib/server/utils/network.js httpRequest,不傳 ca),遇到重新簽的 TLS 一樣失敗。判定在範圍內:installArgs 前加
   verifiedNodeTrustArgs()(與鎖定 npm 同一個入口)。下載真正發生在 CLI 以 childProcess.fork(oopDownloadBrowserMain.js)
   開的子行程(browserFetcher.js:85,不帶 options);Node 文件 fork 的 execArgv「Default: process.execArgv」
   (https://nodejs.org/docs/latest-v22.x/api/child_process.html#child_processforkmodulepath-args-options),
   本機以同形狀 fork 實測:父行程帶 --use-system-ca 時子行程 execArgv = ["--use-system-ca"]、不帶時 = []。
   test-verified-exact-npm-runtime.mjs 同族掃描加入這支檔,並守 Playwright fork 呼叫形狀(升級若改帶 options 會紅)。
   playwright-runtime.test.mjs 的 install argv 斷言同步。consumer 的 setup:all 不跑 Playwright(只在 DS repo)。
2. 內容不實(選 (a) 讓事實符合文字):Linux 上 tls.getCACertificates('system') 會跟著 SSL_CERT_FILE / SSL_CERT_DIR 走
   (Node cli.md --use-system-ca 段原文:「If the overriding OpenSSL environment variables (typically SSL_CERT_FILE and
   SSL_CERT_DIR ...) are set, the specified paths will be used to load certificates instead.」),而父行程(剝除者)的環境
   沒剝、Node 讀過一次就快取。改為 readSystemTrustAnchorsWithoutEnvironment():由 env = {} 的同版 Node 子行程讀 'system'
   回傳 PEM(不繼承 execArgv,讀不到 fail closed,本行程快取一次);'bundled' 編進 Node、照舊在本行程讀。
   於是 README / 01-first-time-setup / consumer-governance(兩份)「ignores CA ... environment variables」與程式註解
   「錨不取自任何環境變數、父子同一組錨」成為事實,文件未改字。CI 真 TLS 對照組加一臂:父行程環境帶指向探針 CA 的
   SSL_CERT_FILE / SSL_CERT_DIR 跑下載臂,untrusted 態必須仍連不上(修前在 Linux 會連上 = 對照組紅;交 CI Linux runner)。
3. 內容不實:scripts/fork-role-sources/CLAUDE.product.md「Fresh environments」不再要 bare `npm run setup:all` 當 Setup script,
   改指向 template README「Local, cloud, and container setup」那支自己找 checkout 的 script、放在 repo 專用環境;
   governance:generate 重生 fork/CLAUDE.md、fork/providers/claude/instruction.md、template/ds-product-template/CLAUDE.md 與鎖。
4. 規格漏做:verified-exact-npm-runtime.mjs 註解補齊三平台(Linux 預設檔 / 目錄與兩個覆寫變數、macOS Default 與 System
   鑰匙圈 Always Trust、Windows Local Machine / Current User 的 Trusted Root Certification Authorities 等,註明本 repo 不支援
   native Windows),出處 https://nodejs.org/docs/latest-v22.x/api/cli.html#--use-system-ca;--use-system-ca 原句補全
   (含「and the NODE_EXTRA_CA_CERTS environment variable」,子行程環境已剝)。

檢查:node --test scripts/test-verified-exact-npm-runtime.mjs infra/governance/test/playwright-runtime.test.mjs
→ 36 tests、35 pass、0 fail、1 skip(真 TLS 對照組:本機 macOS 儀器無法執行,交 CI)。突變對照(跑完還原):
Playwright installArgs 拿掉入口 → 同族掃描 + hermetic 測試紅;系統庫改回本行程讀 → 錨組成測試紅;讀取子行程改繼承環境 → 子行程測試紅。
node --test test-setup-governance / authority-setup / provider-surface / harness-source-inventory / harness-registry /
ci-workflow-scope / workflow-identity-sync / test-cloud-portability-invariants / test-fork-governance /
test-product-template-scaffold-lock → 134/134 pass;node scripts/test-workflow-security.mjs pass;
governance:generate + governance:check PASS。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* chore(release): 整合後重算生成檔與 workflow 身分、版號 0.1.0-beta.149 → 0.1.0-beta.150

S1 發版線整合點(額度規則 2 筆 + canary 6 筆 + P0 2 筆挑到 main 2e5c1b0 之後):
- 版號:packages/design-system/package.json(版本 SSOT)149 → 150;npm 上 149 已發布。其餘版號面
  (plugin / marketplace / 三包 / template / package-lock / provider-lifecycle)由 governance:generate
  呼叫 sync-version-to-all-manifests.mjs 同步,不手改。
- 挑入時生成檔衝突一律取整合分支的版本,這裡一次 governance:generate 重算(control-plane lock、
  governance/generated、fork 投影、consumer / template lock)。governance:check PASS。
- workflow 身分:P0 在 ci.yml「Cloud portability gates」加了系統憑證庫對照測試 → required check 0 的綁定過期。
  --propose → 審:desiredAfter 對現行 github.json 只差 /profiles/design-system-authority/requiredChecks/0/workflowIdentity
  三個雜湊(gitBlobSha 2b43ca3 → 5cfa709、contentSha256 a54ee592 → 8c6d91cc、semanticSha256 4e147b6b → 45336cd4);
  git hash-object 與 shasum -a 256 獨立重算吻合;ci.yml 相對 main 只在既有 run 區塊加 22 行,權限與觸發條件不變。
  → --apply-reviewed-proposal(digest 01a7505f…)→ --check:workflow identities are synchronized。
- 檢查:check-agents-bootstrap PASS(76,768 / 76,769);test-verified-exact-npm-runtime + test-setup-governance 76 過 /
  1 略過(真 TLS 對照組本機儀器無法執行,交 CI Linux runner);test:public-surface 對 149 零破壞性差異;
  test:gate-reachability、test:release-consent PASS。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* chore(storybook): Storybook 8.6.19 → 10.6.9 全 repo 升級(storybook-config preset 改 ESM、play 靜態匯入、openStory 認得 10.x 吞掉的 play 錯誤)

user 原話:「我覺得不要再研究差異了,反正就是要更新,因為8裝不起來套件」(下游要用 storybook-addon-canvas-comments)。

版本:storybook 與 @storybook/* 全部 10.6.9 精確版號(repo 沒有發布天數規則;10.6.9 過得了 npm ci、差集弱點稽核 0 新增)。
- 根 / storybook-config / template:移除 @storybook/react、addon-essentials、blocks、test;addon-a11y / addon-docs / addon-links / react-vite / storybook = 10.6.9;
  @whitespace/storybook-addon-html 7 → 9.0.0(10.x 版),它的 preview 靜態匯入 prettier → 根加 prettier 3.10.1。
- overrides 拿掉兩條 8.x 時代的:@storybook/addon-actions 的 uuid(套件已併入本體、樹上沒有了)、docgen 外掛 0.6.4(react-vite 10.6.9 要 ^0.7.0,留著會反向降級)。
- storybook-config peerDependencies 改成 storybook / @storybook/react-vite ^10.6.9(自己依賴的 addon 就要求 ^10.6.9),不再宣稱支援 8 / 9。

官方遷移(MIGRATION.md 8→9、9→10;automigrate 實跑對照):
- 216 個 story 檔 @storybook/react → @storybook/react-vite、@storybook/test → storybook/test(與官方 renderer-to-framework、consolidated-imports 產出逐位元相同)。
- essentials 退場 → features { outline:false, backgrounds:false };docs.autodocs 移除;globalTypes.defaultValue → initialGlobals;experimental_afterEach → afterEach;
  manager-api / preview-api / components → storybook/*;DS Devmode 工具列 IconButton → ToggleButton(10.1 棄用 IconButton 與 active)。
- 不採用的選配 automigrate:eslintPlugin、wrap-require、addon-mcp、enable-experimental-review / docgen-server。

S3 preset:.cjs 與 ESM 在 DS repo 與 consumer(published template 鏡像 + tgz)兩面實測都建得起來,
只有 ESM 是 10.x 官方支援格式 → preset.ts 編成 dist/…/preset.js(fileURLToPath(import.meta.resolve()));preset.cjs 退場。
記憶檔改名 feedback_storybook_addon_preset_esm.md(兩面實測與出處);hook r2 判準翻轉(擋 .cjs preset 與 ESM 裡未定義的 CJS 全域),測試 19 格。

閘:10.x 核心預設 throwPlayFunctionExceptions:false —— play 拋錯 phase 照樣走到 finished、不顯示錯誤頁。
全量截圖抓到 9 個檔的 play 用 `await import('storybook/test')`,10.x 建置改寫成 import(__STORYBOOK_MODULE_TEST__) 而靜默失敗:
- 9 個檔改檔頭靜態匯入;改後 1089 則 story 截圖與 8.6 逐像素相同。
- scripts/lib/launch-browser.mjs openStory 加「渲染錯誤帳本」(訂 storyRenderPhaseChanged / playFunctionThrewException),
  這一次 render 進過 errored 就判 render-errored;test-open-story 加 10.x 形狀對照組,真實壞建置兩面驗過。
- devmode 閘改量開關的 aria-checked(不再用 title 文字當狀態代理)。

帳本:ds-changes.json 0.1.0-beta.150 補 changes(storybook-10)、updated(預覽站 UI / Devmode 開關)、noVisibleChange(匯入路徑);
story-rules.md 加「Storybook 版本與匯入路徑(10.x)」段;governance:generate / check 綠。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyfCTGphdMtHsYCxamP4cK

* fix(gates): 三支瀏覽器閘在 Storybook 10 建置下換成量性質本身(預覽 CSS / DocsRenderer chunk / 面板分頁)

本機重放 ci.yml 瀏覽器 job 時,10.6.9 建置讓三處「拿建置檔名 / 標籤名當代理」的量具量到 0(M37):
- scripts/lib/storybook-css-fixture.mjs previewCssOf:8.x 的全域預覽 CSS 叫 assets/preview-<hash>.css、由 JS 載入;
  10.x 改名 iframe-<hash>.css 並由 iframe.html 直接 <link>(內容逐位元相同)。改量「iframe.html 連的那一份」,沒有 link 才退回 8.x 規則;
  連兩份 / 連到不存在的檔 / 兩者皆無 → 儀器失效(合成建置五格兩面驗過)。用到它的夾具閘:dialog-width / dialog-coexistence / field-open-border /
  overflow-reveal-selected / overlay-density-follows-trigger / overlay-height-cap / sidebar-standalone-collapse / link-input 兩支。
- scripts/storybook-docs-race-invariant.mjs:8.6 的 DocsRenderer 在 DocsRenderer-<hash>.js,10.6.9 併進 addon-docs 的 index-<hash>.js;
  改從正在服務的建置找「匯出 DocsRenderer 的 chunk」(檔名或模組物件 DocsRenderer:),認不出 = 儀器失效。
  10.6.9 實跑:正式量測全綠,--selftest 關掉守衛時殭屍 docs 與歷史浮層照樣重現(競態在 10.x 仍在,守衛仍需要)。
- scripts/test-devmode-visual.mjs:面板分頁 8.6 是 <button role="tab">、10.x 是 react-aria 的 <div role="tab">,改量 role=tab。devmode:test 6/6。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyfCTGphdMtHsYCxamP4cK

* fix(openStory): Storybook 10 的 completing phase —— 假時鐘暫停的閘接受「play 跑完之後」的 completing

10.x 在 completed 之前多一個 completing:用 setTimeout(100ms 起、5 秒上限)等畫面上的有限動畫
(storybook/dist/preview/runtime.js StoryRender.render 的 waitForAnimations)。menu-message-row 用 Playwright 假時鐘暫停,
計時器不走,遠端搜尋 / 非同步名錄四則 story 就停在 completing、30 秒逾時(本機重放 field-dialog-steps job 實測)。
- scripts/lib/launch-browser.mjs:FINISHED_PHASE_CHOICES 加 'completing'(它在 played 之後,與 afterEach 同一個性質:渲染與 play 都已完成);
  更早的 phase 照舊 TypeError,預設仍只認 finished。
- scripts/menu-message-row-invariant.mjs:假時鐘暫停時接受 completing / completed / afterEach / finished。
- scripts/test-open-story.mjs:合成頁照 10.x 加 completing;新對照組 13b(卡在 completing:預設與只允許 afterEach 都儀器失效、
  允許 completing 才成功、允許了也不提早接受 rendering)。52/52。
- scripts/storybook-docs-race-invariant.mjs:檔內自我引用的行號照 owner-claims --fix-moved-cites 跟上(上一個 commit 插入 import 行)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyfCTGphdMtHsYCxamP4cK

* chore(governance): 重生 fork 治理快照 —— consumer 受管的 scripts/lib/launch-browser.mjs 跟上渲染錯誤帳本與 completing

launch-browser.mjs 隨 fork 治理套件交付給 consumer(audit-consumer-a11y 用 openStory);前兩個 commit 改了它卻沒重跑生成,
verify-static「Focused governance and release SSOT checks」的 governance-build-graph --check 在 fork-template 段紅(FORK-GOVERNANCE DRIFT)。
npm run governance:generate 只動 fork consumer lock / managed blob / governance.lock / template governance lock 與 control-plane 快照;governance:check、build graph --check 綠。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyfCTGphdMtHsYCxamP4cK

* docs(storybook-10): story-rules 補「play 的 storybook/test 一律靜態匯入」、visual-audit 參考檔的 Storybook v8 / @storybook/test 說法跟上 10.x

72e64ba1 把 9 個檔的 `await import('storybook/test')` 改靜態匯入、openStory 加渲染錯誤帳本,但寫 story 的正本沒有這條,
下一位作者照舊寫動態匯入時只會在閘裡看到 render-errored,不知道原因:
- ds-canonical/rules/story-rules.md「Storybook 版本與匯入路徑(10.x)」加一句:play 用的 storybook/test 一律檔頭靜態匯入
  (10.x 建置改寫成執行期解析不到的模組、throwPlayFunctionExceptions 預設 false → 畫面照常、play 沒跑),閘 = openStory 渲染錯誤帳本。
- ds-canonical/skills/visual-audit/references/audit-architecture.md:標題與內文還寫「Storybook v8」「@storybook/test」,
  但同段範例已是 storybook/test(內容自相矛盾)→ 改成 10.x 說法並指到 story-rules 同一段。
npm run governance:generate 只動 provider view / fork 鏡像 / template 鏡像與 lock;governance:check、audit-content-quality --check、
owner-claims-invariant(對 origin/main 2e5c1b0)、check-dangling-infra-ref --check 綠。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* docs(ds-changes): 0.1.0-beta.150 節登記 Storybook 10 規則變更(main 帳本格式)

Storybook 10 分支以 int(feat/batch2)為底,帳本是較新的格式(條目帶 paths,另有 added / updated / noVisibleChange 節);
main 的帳本只有 changes 節,條目欄位 = id / surface / target / change / to / fix / do / spec。
挑到 main 時帳本衝突取 main 版,這裡照 main 格式新增 0.1.0-beta.150 節,只放一條:
- 0.1.0-beta.150/storybook-10(rule):storybook-config peer 改 10.x、不再支援 8 / 9,consumer 要做的事(do / spec 逐字取自 Storybook 10 分支,拿掉 paths)。
分支上的 storybook-10-preview-ui(updated)屬「預覽站外框變化」,main 的帳本只記 DS 公開介面的破壞性變更,不登記。
檢查:npm run test:public-surface → 對 v0.1.0-beta.149 零破壞性差異、已發布節逐位元相同;selftest 綠。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* chore(governance): Storybook 10 挑入後重算生成檔與受管檔雜湊

挑入 Storybook 10 五筆時,生成檔衝突段以整合分支為準(cherry-pick -X ours);這裡一次 governance:generate 重算
control-plane lock、governance/generated、fork/consumer/lock.json、template governance/lock.json
(Storybook 10 改了 consumer 受管的 scripts/lib/launch-browser.mjs 與 fork 快照)。
governance:check PASS;workflow identities are synchronized(Storybook 10 沒動 .github/)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* fix(openStory): 量測頁不開 Storybook 10 的整合 highlight —— 它在每批 DOM 變動重跑整頁 getComputedStyle,吃掉 DataTable 捲動的主執行緒

根因(實測,不是推測):Storybook 9 起 highlight 併進核心(main 設定 features.highlight,型別註解「Enable the integrated
highlight addon」「@default true」)。preview 端 useHighlights(storybook/dist/preview/runtime.js「src/highlight/useHighlights.ts」)
在每次 render 進 'loading' 時 resetState → 在 #storybook-root 掛 subtree childList 的 MutationObserver;之後 story 每一批 DOM 增刪
都 elements.set(新的空 Map) → 重跑 document.body.querySelectorAll('*') + 每個元素 getComputedStyle、重掛所有捲動元素的監聽。
8.6 的 @storybook/addon-highlight 沒有這段(8.6 runtime 也不讀 FEATURES.highlight)。虛擬捲動的 DataTable 每一格都在增刪列。

原本的假設「addon-a11y 在 10.x 才自動跑 axe」不成立:8.6 的 addon-a11y 也在 experimental_afterEach 跑 axe,
兩版 afterEach 都約 370–410ms(probe 實測 SB8 382–414 / SB10 369–409)。

A/B(同一支量測腳本;SB8 建置 = main+P0 9a40caab,與 db0f657 在 story 相關路徑只差 storybook-config 版號;SB10 建置 = 56e4d89):
1) highlight 的 MutationObserver 成本(本機,perception 閘同形的 inertia 捲動,每格 4 次):
   SB10:highlight 已初始化,iframe chunk 的 MO 41–46 次 / 118–133ms;SB10 + FEATURES.highlight=false:0 次(只剩 DataTable 自己 3–4ms);SB8:3–5ms。
2) delayed 對照組(test-data-table-scroll-perception 的子命令,--cpu-throttle=3 重現 CI 慢機,3 輪):
   SB8:三輪都第 1 次有效,maxActiveGapMs 97 / 88 / 91
   SB10(修前):15/15 次全部作廢,maxActiveGapMs 144–238(CI 讀回 100.7–150.5 同一形狀),追蹤判定 main-thread-stall
   SB10 + 修正:107→96(第 2 次有效)/ 74 / 74,captureCoverageValid=true
   本機不節流:SB8 49 / SB10 80(整窗跳轉重跑)→34 / SB10+修正 48。
3) 兩支失敗 job 的 gate 步驟(照 ci.yml 抄,本機):
   perception gates:SB8 331s → SB10+修正 354s(1.07×),exit 0;對照組 delayed 第 1 次有效、maxActiveGapMs 34(SB8 50)
   handles + dpr1:SB8 401s → SB10+修正 430s(1.07×),exit 0(CI 修前:同一步驟 1070s → 1404s+ 被 25 分上限砍)
   剩下約 7%:10.x StoryRender 的 completing(waitForAnimations,100ms 起)排在 afterEach 前面,與 axe 串行 ——
   openStory 每則 SB8 約 1.17s / SB10 約 1.55s,關不關 highlight 都一樣(不是 highlight);那是 runtime 固有成本,不改它。

修法(只動量測入口):openStory 開 Storybook iframe 時,以 init script 在 iframe.html 第一支腳本之前把 window.FEATURES.highlight
定成 false(Storybook 自己文件化的開關,等同 features.highlight: false,只作用在這個分頁的 preview 文件)。
給讀者看的預覽站與管理介面(index.html)不變;a11y 閘跑 axe 本身,不經 highlight(axe 也排除 #storybook-highlights-root)。
opts.storybookHighlight = true 保留原樣;同一分頁換模式 → TypeError。門檻(100ms)與 timeout-minutes 一格都沒動。
對照組:test-open-story 真實建置段新增「預設關 / storybookHighlight:true 開」兩面 + 換模式 TypeError。
launch-browser.mjs 是 consumer 受管檔 → npm run governance:generate 重生 fork / template lock 與 control-plane 快照。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* fix(openStory): 更正 6172a67 的耗時歸因與 a11y 說法 —— 同機修前 / 修後實測,highlight 只佔兩支失敗步驟的 3–5%

6172a67 的訊息有兩處要以本 commit 為準(該 commit 已在分支上、不改寫歷史):
(a)「A/B」第 3) 點拿本機 SB8 與修後去對 CI 的修前數字,跨機器不能比,讀起來像「其餘的慢都來自 highlight」;
(b)「修法」段寫「axe 也排除 #storybook-highlights-root」當 a11y 閘不受影響的理由 —— 不實,見下方 a11y 段。
scripts/lib/launch-browser.mjs「量測頁不開 Storybook 10 的整合 highlight」區塊註解同步改(只改註解,程式碼一行未動)。

同機 A/B(照 ci.yml 抄;同一台機器、修前 / 修後背靠背;兩棵樹只差 scripts/lib/launch-browser.mjs —— 修前 = 56e4d89、
修後 = 6172a67,同一份 SB10 建置 56e4d89):
  perception gates(verify-browser-datatable-perception 的 gate 步驟):修前 371s → 修後 352s(−5%),兩面 exit 0(規格核對審查者量)
  handles + dpr1(ci.yml:1005–1062):修前 470s → 修後 457s(−3%),兩面 exit 0;
    其中 dpr1 感知迴圈 72s → 51s;前 13 支閘 398s → 406s(修後第一支 31s 是單次離群;row-estimate-density 29s → 20s;其餘逐支差 ≤ 2s)
  → 本機不節流時修前也是綠的,highlight 只佔這兩支步驟的 3–5%。CI 上 handles job 慢 1.3 倍以上、被 25 分上限砍掉,
    **不能**由本機數字算在 highlight 頭上。
  CI 修前那一次(56e4d89,handles 步驟 1404s 被取消)逐段讀回(ci 日誌時間戳):前 13 支閘 1029s(本機修前 398s,約 2.6×);
    dpr1 4500px/s 那格 5 次全作廢(整窗跳轉 4 次 + 送幀缺口 1 次 108ms)單格 210s(本機修前 7s)。
  修後 CI 的 handles job 會不會回到 25 分以內,只能在合回點讀回 CI 判定(本 commit 未推,尚未讀回)。
  有實測直接撐住的 highlight 效果只有捲動量測期間的送幀缺口 / 作廢重跑:delayed 對照組(--cpu-throttle=3)
    SB8 5 輪都第 1 次有效(maxActiveGapMs 97 / 88 / 91 / 93 / 88);SB10 修前 25/25 次全作廢(144–482);
    SB10 修後 5 輪都有效(107→96 / 74 / 74 / 102→78 / 69;後 2 輪為審查者補量)。
  與 highlight 無關、已量到的 10.x 成本:StoryRender 的 completing(waitForAnimations,100ms 起)排在 afterEach 前、與 axe 串行,
    openStory 每則 SB8 約 1.17s / SB10 約 1.55s,關不關 highlight 都一樣;runtime 固有成本,不改它。
  (6172a67 裡 SB8 的整步耗時 perception 331s / handles 401s 是另一時段量的,不與上面的同時段數字直接相比。)

a11y:專案的 a11y 閘用 AxeBuilder 掃整頁、沒有 exclude(scripts/audit-a11y.mjs:141、scripts/data-table-multi-sort-invariant.mjs:581)。
排除 #storybook-highlights-root 的只有 Storybook 自己的 addon-a11y(node_modules/@storybook/addon-a11y/dist/_browser-chunks/
chunk-5WURYCET.js:76),不是我們的閘;修前那個 div 在我們 axe 的掃描範圍裡,修法確實改了 a11y 閘的頁面環境。以實測為準:
node scripts/audit-a11y.mjs --tag=datatable(48 則)與 --story=40(前 40 則),修前 / 修後每則違規逐條相同 ——
有違規的 37/37、19/19 則完全一致,違規節點 128/128、102/102,audit-error 0 / 0(兩面 exit 1 是既有基線違規、非 --gate 模式)。
完整 1089 則的 npm run a11y:check -- --gate 未跑。

門檻(100ms)與 timeout-minutes 一格都沒動。launch-browser.mjs 是 consumer 受管檔 → npm run governance:generate 重生
fork / template lock 與 control-plane 快照(exit 0);npm run governance:check exit 0;npm run test:launch-browser exit 0。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* docs(openStory): highlight 區塊註解直接寫同機實測數字,不再指向「引入這段的 commit 訊息」

上一個 commit 的註解寫「只認引入這段的 commit 訊息裡同一台機器的修前 / 修後實測」,但同機實測在更正 commit 裡、
不在引入這段的 6172a67 —— 指錯出處。改成直接寫數字:同機修前 / 修後(不節流)perception 371 → 352s、
handles 470 → 457s,兩面都綠,highlight 只佔 3–5%;CI 上整支 job 變慢的其餘部分沒有歸因到 highlight。
只改註解(程式碼一行未動);consumer 受管檔 → npm run governance:generate(exit 0),governance:check exit 0,
test:launch-browser exit 0。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* revert(s1): Storybook 10 移出本版 —— 樹回到 db0f657(額度規則 + canary + P0 + 版號 150),SB10 留待下一輪

依交接 NEXT-SESSION §2 第 5 步截止規則(T+6h 若 Storybook 10 還沒核對綠,就從這個 PR 拿掉,先讓 P0 + 額度規則 + canary 能發;
user 原話「我認爲這個任務要優先處理且處理完若其他東西還要很久才能完成的話,那可以先發版這個」)。

為何現在拿掉:
- 56e4d89(含 SB10)的 CI 紅 2:「DataTable handles + dpr1 perception」gate 步驟 1404s+ 撞 25 分上限被取消(SB8 的 db0f657 = 1070s);
  「DataTable perception gates」delayed 對照組 5 次全部作廢(送幀空檔 100.7–150.5ms > 100)。
- 已找到並修好其中一個根因(6172a67 / cf9682d / 45ca92f,保留在 refs/lanes/sb10-full 與 s1-sb10-full.bundle):
  Storybook 10 核心內建 highlight 在 #storybook-root 掛 MutationObserver,每批 DOM 變動重跑整頁 getComputedStyle;
  量測頁關掉後 delayed 對照組在 --cpu-throttle=3 下由 25/25 作廢 → 5 輪全有效。規格核對 + 必修 3 條修一次 + 再驗,必修 0。
- 但同一台機器修前 / 修後實測,highlight 只佔兩支失敗步驟的 3–5%(perception 371→352s、handles 470→457s);
  CI 上 handles job 慢 1.3 倍以上、撞上限的主因還沒有歸因,推上去大機率仍紅,截止時間(07:32)已過。

這筆的內容:git commit-tree db0f657^{tree} -p 45ca92f,樹與 db0f657 逐位元相同(db0f657 的 CI 39/39 綠)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* docs(setup): 雲端 setup:all 仍停在 npm audit signatures —— 四份 Setup script 說明補「已知限制」,修好前不要設

雲端實測(下游 TT session,Claude Code 雲端、Node 22.23.5,workspace 副本換上本分支 4 個受管檔後跑 npm run setup:all):
- 憑證那關已修:鎖定 npm 以 --use-system-ca 啟動,npm ci「added 387 packages … in 12s」(修前這裡就 SELF_SIGNED_CERT_IN_CHAIN)。
- 下一步失敗:npm audit signatures → ENOTFOUND tuf-repo-cdn.sigstore.dev,88 秒 exit 1,沒走到 scope=local-bootstrap。
- 根因(同機查證):有代理變數時 curl 該網址 200;env -i 時 DNS 解析不到;registry.npmjs.org 可直接解析。
  = 該環境只讓 npm registry 直連,Sigstore TUF CDN 只能經代理;鎖定安裝把 HTTPS_PROXY 當有敵意剝掉。

本 PR 原本的文件(README、first-time-setup、consumer-governance、CLAUDE.product)寫「代理重新簽章的環境放進系統憑證庫就能跑」,
並教下游把 setup:all 設成雲端 Setup script;照做會讓雲端 session 開不起來(Setup script 非 0 結束)= 內容不實,發版前必修。
修法:四份正本的雲端那一條開頭先寫「目前跑不完,修好前不要設」,憑證段後補已知限制(卡在哪、為什麼、該 session 算降級不得宣稱合規);
生成檔(fork CLAUDE.md、provider instruction、template CLAUDE.md、template consumer-governance、受管檔 lock / blob)由 governance:generate 重生。
代理那關的修法(讓鎖定安裝走代理)會讓安裝鏈讀可能帶憑證的代理網址,屬 work-process「選做法前先問」的監督邊界,另開 PR 處理。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* docs(setup): 規格核對必修 4 條 —— 已知限制段的字串、位置、矛盾句與後果說法

a04c6a2 的規格核對(canonical-reviewer,未參與撰寫)判不通過,必修 4 條,本筆一次修完:
1. 改壞既有測試:scripts/test-setup-governance.mjs:1879 規定 setup 說明面不得出現 `npm audit signatures`(防各處 setup 指令寫法分歧),
   新段落在 README / 01-first-time-setup / CLAUDE.product(及生成的 CLAUDE.md)含該字串。→ 改寫成「the registry signature audit
   (`audit signatures`)」,不動測試。node --test scripts/test-setup-governance.mjs:48/48 pass。
2. README「The same `setup:all` works on … Claude Code on the web …」與新段落「does not complete」矛盾 → 清單拿掉 Claude Code on the web,
   改寫「on Claude Code on the web it does not complete yet (see the known limitation below)」。
3. consumer-governance.md 先教設定、警語在後,且開頭清單仍要讀者在 Claude Code on the web 設 setup 指令;CLAUDE.product.md 警語在段尾。
   這兩份是發到既有 consumer 的受管檔,讀者可能照自家舊 README 抄 script → 警語移到段首,清單拿掉 Claude Code on the web。
4. 「stop sessions from starting」沒有實測依據,且與同檔「fail to start or start without what it failed to install」不一致 → 沿用原兩種結果寫法。
同句順修:「has not run `setup:all`」→「has not completed `setup:all`」(在 session 裡手動跑過但失敗時原句字面不成立)。
生成檔由 governance:generate 重生;governance:check、check:agents-bootstrap、audit-content-quality、work-process-ssot-invariant、
test:fork-governance、test:public-surface、workflow-identities、test-verified-exact-npm-runtime 全 exit 0。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* fix(setup): 鎖定安裝鏈轉送不帶帳密的 HTTPS_PROXY / NO_PROXY —— 雲端 session 內 audit signatures 不再 ENOTFOUND sigstore

根因:scripts/lib/governance-dependency-bootstrap.mjs 的 HOSTILE_NAME 把 HTTPS?_PROXY / NO_PROXY / https?_proxy / no_proxy
整族當不可信剝除。Claude Code 雲端 session 對外只能經安全代理(HTTPS_PROXY 有設、網址不帶帳密;NO_PROXY 含 registry),
registry 可直接解析、tuf-repo-cdn.sigstore.dev 不行 → npm ci 成功後 audit signatures 抓 TUF 中繼資料 ENOTFOUND,88 秒 exit 1。

修法(M37:判斷的是「代理網址帶不帶帳密」這個性質本身,不是變數名):
- verified-exact-npm-runtime.mjs 新增唯一判定 resolveGovernanceProxyForwarding:可解析成 URL、scheme 為 http(s)、
  username / password 皆空、hostname 非空 → 只轉送 HTTPS_PROXY(origin)與 NO_PROXY;帶帳密 / 無法解析 / scheme 不支援
  → 照舊剝除,印一行原因(GOV-PROXY-FORWARD,只印變數名與原因,不印值)。大小寫並存照 curl 慣例取小寫。
  ALL_PROXY / HTTP_PROXY / proxy / NOPROXY(不分大小寫,@npmcli/agent 不分大小寫讀)、NPM_CONFIG_*、CA 類、NODE_OPTIONS 照舊剝除。
- 同族全修(M10):sanitizeGovernanceBootstrapEnvironment(setup-governance / setup-authority-governance / run-verified-npm
  直接用;install-candidate-dependencies / setup-provider-cli-toolchain / 依賴 bootstrap 經 createIsolatedGovernanceNpmEnvironment)
  與 verify-upgrade-evidence 的 isolatedNpmEnvironment 都消費同一支判定;本行程的 npm tarball 與兩個修補層下載改走
  resolveGovernanceProxyRoute(NO_PROXY 命中直連,否則經 HTTP CONNECT 隧道,隧道上 TLS 仍以同一組內建 + 系統憑證驗)。
- 只經環境變數、不寫 npmrc:npm 11.19.0 原始碼 —— @npmcli/agent 4.0.2 lib/proxy.js:13-21 由 process.env 收 https_proxy /
  no_proxy、:64-75 沒有傳入 proxy 時回落環境變數;npm lib/utils/verify-signatures.js:37-41 的 initTUF 不傳代理、
  tuf-js 4.1.0 dist/fetcher.js:67-75 只傳 timeout / retry、make-fetch-happen 15.0.6 lib/remote.js:40 getAgent 回落同一支 proxy.js。
  雲端實測 E2:只給 --https-proxy / --noproxy 旗標仍 ENOTFOUND;環境變數給 → exit 0。
- 代理不新增任何信任錨。無代理路徑(Setup script 階段實測全 unset)行為不變:判定回傳空集合,下載照舊直連。

證據:node --test scripts/test-verified-exact-npm-runtime.mjs 36/36(本機以 openssl 造探針憑證跑隧道對照);
弄壞對照三組各自紅(帶帳密也轉送 / sanitize 不放回 / 下載永遠直連)後還原逐位元相同。
本機 S5:沙箱 https_proxy 帶帳密 → npm run setup:dependencies 印「GOV-PROXY-FORWARD:https_proxy 帶帳密,鎖定安裝鏈不轉送」、
getaddrinfo ENOTFOUND registry.npmjs.org、exit 1(帶帳密不轉送那一面)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* test(setup): 代理轉送判定表、npm 原始碼釘、呼叫端消費同一支判定,與雲端同形的代理對照組探針

- scripts/test-verified-exact-npm-runtime.mjs:判定表 21 列(帶帳密:帳號 / 密碼 / 兩者;無法解析;scheme 不支援
  socks5 / file / 無 scheme;大小寫並存取小寫、小寫帶帳密不退回大寫;NO_PROXY 大小寫並存、控制字元;IPv6;預設埠 80 / 443;
  路徑與空白正規化);原因行逐字且不印值;NO_PROXY 命中逐格對照 npm 11.19.0 內建 @npmcli/agent 的 getProxy 本身
  (後綴比對、不認 *、不看埠、IPv6 帶中括號);npm / tuf-js / make-fetch-happen 原始碼釘(升級 npm 就紅);
  sanitize / createIsolatedGovernanceNpmEnvironment(npmrc 仍只有四行)/ verify-upgrade-evidence 三個環境建構器
  真的消費同一支判定,七個呼叫端原始碼掃描不得自己拼代理變數;下載走共用路由(未命中先開隧道、帶同一組 ca);
  prepare 把同一份 env 交給三次下載;CI 探針憑證下的真 CONNECT 隧道:錨相同 → 通、只有內建 bundle → 拒、代理 403 → 不退回直連。
- infra/governance/test/authority-setup.test.mjs:不帶帳密的 HTTPS_PROXY / NO_PROXY 到達鎖定 npm 三步與 Playwright 安裝,
  封閉前置工具探針不帶代理;HTTP_PROXY / ALL_PROXY / SSL_CERT_FILE 照舊剝除。原本的敵意代理改成帶帳密(照舊剝除)。
- scripts/test-setup-governance.mjs:敵意 HTTPS_PROXY 改成帶帳密的網址(不帶帳密的會被轉送,是新行為)。
- scripts/proxy-route-parity-probe.mjs(CI 對照組):--serve 本機不帶帳密 CONNECT 代理(只放行 443、每次 CONNECT 記一行);
  --arm=forward|control|flags-only 跑鎖定安裝鏈本身的 audit signatures 並以純函式 evaluateProxyParityArm 判定;
  control 臂的「帶帳密」原因行改為接住鎖定鏈自己印到 stderr 的那一行(原本探針自己算一次再印 = 自我應驗);
  --selftest 跑判定、路由、代理轉發與兩個拒絕對照、三臂判定表 14 列。隧道建好但代理不轉送時原本會掛住,
  加 10 秒逾時(弄壞轉發的對照組實測:修前掛住 25 秒被殺,修後 10 秒 exit 1)。

證據:node scripts/proxy-route-parity-probe.mjs --selftest exit 0;弄壞 forward 臂判定 → selftest exit 1;
test-verified-exact-npm-runtime 36/36、test-setup-governance 48/48、authority-setup(含於 infra 全套 369 支 368 過,
唯一失敗 provider-runtime-conformance 在乾淨 4961567 同樣失敗:本機 node_modules 未裝 provider CLI toolchain)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* ci(cloud-portability): 「sigstore 只能經代理」的真實對照組三臂,並重算 required check 的 workflow 身分

ci.yml「Cloud portability gates」既有 run 區塊尾端加一段(不另開 job):
- 本機起 scripts/proxy-route-parity-probe.mjs --serve(不帶帳密的 CONNECT 代理,用 runner 正常的名稱解析連出)。
- 三臂各在 `sudo unshare --mount --propagation private` 的私有 mount namespace 跑:/etc/nsswitch.conf 的 hosts 行換成
  `hosts: files`、/etc/hosts 多釘 registry.npmjs.org 的 IPv4 → sigstore 直連解析不到、registry 可直連(與雲端同形);
  setpriv 降回 runner 身分、env -i 只帶 PATH / HOME。前提由探針先驗,不成立 = 儀器失效 exit 2。
  forward(環境變數不帶帳密)→ audit signatures 綠且代理紀錄有 CONNECT tuf-repo-cdn.sigstore.dev:443;
  control(代理網址帶帳密)→ 必 ENOTFOUND 且鎖定鏈自己印「帶帳密」;flags-only(只給 --https-proxy / --noproxy 旗標)
  → 必 ENOTFOUND(雲端實測 E2 的回歸釘:npm 的 https-proxy 設定到不了 TUF 下載)。
- namespace 隨行程結束消失,runner 設定不動;收尾 getent hosts tuf-repo-cdn.sigstore.dev 證明 runner 本身解析未被動到。
- 前一位實作者留下兩段重複的區塊(一段有 flags-only、一段用 env -i 與保留 passwd 的 nsswitch),合併成一段。

workflow 身分(照 db0f657 的程序):sync-workflow-identities --propose → 審:desiredAfter 對現行 infra/governance/desired/github.json
只差 /profiles/design-system-authority/requiredChecks/0/workflowIdentity 三個雜湊(gitBlobSha 5cfa709 → 1bcf59c、
contentSha256 8c6d91cc → 22047ace、semanticSha256 45336cd4 → 4dd77da9);git hash-object 與 shasum -a 256 獨立重算吻合;
ci.yml 相對 4961567 只在既有 run 區塊加 30 行、刪 0 行,權限與觸發條件不變 → --apply-reviewed-proposal
(digest a7ff39a8…)→ --check:workflow identities are synchronized。

檢查:audit-workflow-security PASS(16 workflows);test:gate-reachability PASS;audit-gate-meta-test-coverage --check PASS;
infra/governance/test/ci-workflow-scope.test.mjs 10/10。三臂本身要 Linux runner 的 sudo / unshare,本機(macOS 沙箱)儀器無法執行,
由這支 PR 的 CI 讀回。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* docs(setup): 雲端 Setup script 可放共用 Default 環境、已知限制段改寫成修好後的行為;重生受管檔與 lock

四份正本(template/ds-product-template/README.md、template/ds-product-template/docs/01-first-time-setup.md、
packages/design-system/ds-canonical/templates/consumer-governance.md、scripts/fork-role-sources/CLAUDE.product.md):
- 威脅模型句:CA 與 NODE_OPTIONS 環境變數照舊忽略;不帶帳密的 HTTPS_PROXY / NO_PROXY 只用來路由、不新增信任;
  帶帳密的代理網址照舊忽略。
- Setup script:非本 repo 印一行略過並 exit 0(不擋其他 repo 的 session);是本 repo 就 exec npm run setup:all、照實傳回結束碼;
  同時處理「在上一層、repo 在子資料夾」與「在 repo 根目錄」;cd 失敗 exit 1。工作目錄寫成已知:Setup script 在 /home/user、
  repo 在子資料夾(user 在真實 Setup script 實測)。腳本以假 npm(exit 7)模擬四種位置:上一層 / 根目錄都傳回 7、
  別的 repo / 無 repo 都 exit 0。
- 已知限制段改寫成修好後的行為:Setup script 階段無代理變數、registry 與 tuf-repo-cdn.sigstore.dev 直連;session 內經
  不帶帳密的 HTTPS_PROXY(鎖定鏈連同 NO_PROXY 轉送)→ 兩處都跑得完 setup:all;沒跑完的 session 視為 degraded、不得宣稱合規。
  不寫實測數字(發版前由雲端 session 實測,失敗再改)。全文不含 `npm audit signatures` 字串(test-setup-governance 的斷言)。

生成檔:npm run governance:generate(在 workflow 身分套用之後最後重生一次)→ fork / consumer lock、managed blob、
template governance lock、fork CLAUDE.md / provider instruction、template CLAUDE.md 與 consumer-governance.md 副本、
control-plane lock / PROVENANCE 同步。governance:check PASS、workflow-identities:check PASS、check:agents-bootstrap PASS、
audit-content-quality --check PASS、test:public-surface PASS。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* docs(setup): 規格核對必修 —— 雲端已知限制段改回事實陳述,不宣稱 setup:all 已能跑完

根因:上一個 commit(e04d622)把四份正本的「已知限制」段改寫成修好後的行為,寫了
「setup:all completes both in the Setup script stage and when rerun inside a session」
「In the Setup script stage no proxy variable is set and both hosts are reached directly」,
README 另寫「works … on Claude Code on the web through the Setup script above」。
規格 S6 第三點要求這段保留、改寫成「雲端 Setup script 階段尚未實測」的事實陳述;
規格背景也列明 Setup script 階段有沒有 HTTPS_PROXY、能不能直連 sigstore 都是未知,
而且修後的 setup:all 還沒在雲端端到端實測過。那幾句是把推論寫成事實(M36(a))。

修正(四份正本:template/ds-product-template/README.md、template/ds-product-template/docs/01-first-time-setup.md、
packages/design-system/ds-canonical/templates/consumer-governance.md、scripts/fork-role-sources/CLAUDE.product.md):
- 已知限制段改成:雲端 setup:all 尚未驗證能跑完;session 內修正前的原因(鎖定安裝過了、
  audit signatures 撞 ENOTFOUND tuf-repo-cdn.sigstore.dev:該主機只能經不帶帳密的 HTTPS_PROXY 連到,
  鎖定鏈卻剝光代理變數);修正內容(轉送不帶帳密的 HTTPS_PROXY / NO_PROXY、只用來路由);
  套用本修正後 session 與 Setup script 階段都尚未實測、Setup script 階段有沒有代理變數或能否直連未知;
  Setup script 非 0 結束的後果(官方文件);沒跑完的 session 視為 degraded、不得宣稱合規。
- README「The same setup:all works on … and on Claude Code on the web」改成雲端尚未驗證能跑完。
- 同族全修(M10):四份正本把「Setup script 從 /home/user 開始執行」寫成事實(規格背景只知道
  工作目錄未文件化、雲端實測 repo 在 /home/user/<repo>),改成「官方未文件化工作目錄,腳本兩種位置都處理;
  雲端 session 看到 checkout 在 /home/user/<repository-folder>」。
- 「earlier releases」改成「before this fix」:雲端實測的是哪個版本無法查證,只寫得出「修正前」。
Setup script 腳本本身、威脅模型句沒動;全文仍不含 `npm audit signatures` 字串。

生成檔:npm run governance:generate 重生 → template CLAUDE.md、fork CLAUDE.md、fork/providers/claude/instruction.md、
template governance/consumer-governance.md、managed blob 884721…(cmp 與正本相同)、
fork/consumer/lock.json、fork/governance.lock、template governance/lock.json(三處 sha256 = af0ae71b…)、
control-plane lock / PROVENANCE 同步。

驗證(全部 exit 0):governance:generate、governance:check、check:agents-bootstrap、test:content-quality、
test:public-surface、governance:workflow-identities:check;node --test scripts/test-setup-governance.mjs 48/48、
scripts/test-setup-netlify-access.mjs 16/16、scripts/test-governance-protected-roots.mjs 22/22、
packages/governance/test/provider-adapter-generator.test.mjs 29/29。殘句 grep(completes both / no proxy variable is set /
through the Setup script above / script starts in / earlier releases)在四份正本與生成副本 0 筆。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* docs(setup): 雲端說明改成已查證的事實 —— Setup script 階段直連、session 內經不帶帳密的代理;範例腳本 REPO_DIR 加引號

93b0632 照「舊版規格 S6 第 3 點」把已知限制改成「Setup script 階段有沒有代理變數、能不能直連 sigstore 未知」。
該條已被接手說明覆蓋(核對者沒拿到接手說明,是主 session 派工腳本漏傳),而且這句已不符事實:
- user 在 Claude Code 雲端真實 Setup script 實測(探測腳本):root、pwd=/home/user、repo 在子資料夾;
  HTTPS_PROXY / NO_PROXY 全 unset;sigstore DNS ok、直連 200。
- 同一階段用 4961567 跑 setup:dependencies(34 秒,676 個套件簽章全過)+ setup:provider-cli(14 秒,0 漏洞)全成功。
- session 內(TT 實測):sigstore TUF CDN 只能經不帶帳密的 HTTPS_PROXY;以環境變數給代理 audit signatures exit 0。
四份正本(README、01-first-time-setup、consumer-governance、CLAUDE.product)改寫:
- 「已知限制」段改成雲端網路說明:鎖定安裝預設直連;有不帶帳密的 HTTPS_PROXY 時 NO_PROXY 以外走代理(只做路由);
  Setup script 階段實測直連;session 內 sigstore 只能經代理、鎖定安裝會轉送 → session 內重跑也能跑完。沒跑完的 session 算降級。
  session 內那句由 TT 在雲端實測把關,通過才發版。
- 工作目錄改引 user 的 Setup script 實測(/home/user、checkout 在 /home/user/<repository-folder>)。
- 範例腳本 REPO_DIR=<repository-folder> 沒加引號,照抄未替換時 bash 語法錯誤 exit 2(核對者實測);放在共用 Default 環境會讓
  所有 repo 的 session 起不來 → 加引號,未替換時只印略過行、exit 0。模擬五種情況(未替換 × 兩處位置、上一層、repo 根、別的 repo)
  在 README 與 01 兩份逐一符合預期(0 / 0 / 7 / 7 / 0,假 npm exit 7)。
生成檔由 governance:generate 重生。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSRtrF3AtuG7rRd1cvtHgj

* docs(setup): 規格核對必修 2 條 —— 雲端「setup:all 會跑完 / 能跑」說過頭,只寫已證實的部分

0cd4b74 的規格核對(canonical-reviewer,未參與撰寫)必修 2 條(內容不實):
- M1 README / 01-first-time-setup / consumer-governance 寫「rerunning setup:all in the session … also completes」。
  事實只到:session 內用 93b0632 跑,簽章稽核經轉送的代理通過(525 簽章 / 223 attestations),之後停在
  GOV-MANAGED-FILE-001(workspace 的 lock 仍是 beta.149,發版前必然);Setup script 階段只跑過 setup:dependencies
  與 setup:provider-cli 兩段,完整 setup:all 在雲端從未被看到跑完。→ 改成「rerun 時簽章稽核經代理連到該 CDN」。
- M2 README「The same setup:all works on … Claude Code on the web」→ 改成「Claude Code on the web 經上面的 Setup script
  執行(見網路說明)」,不宣稱已跑完。
發版後在雲端 sessi…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash PRs the Commit Queue should land as one squashed commit. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants