Repository navigation
fix(secrets): generate secretref reference docs from the credential matrix - #85969
1052326311 wants to merge 2 commits into
Conversation
Dependency Changes DetectedThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
|
Codex review: needs changes before merge. Reviewed May 30, 2026, 11:43 PM ET / 03:43 UTC. Summary PR surface: Source +124, Tests +206, Docs -279, Config +2, Other +60. Total +113 across 10 files. Reproducibility: yes. Source inspection on current main shows the generator only writes the JSON matrix while the Markdown marker lists remain checked-in static blocks that the docs test compares after the fact; I did not run generators or tests because this review is read-only. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Land the generator/check path after restoring CHANGELOG.md to current main and wrapping the new package scripts with the existing cross-platform env runner. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows the generator only writes the JSON matrix while the Markdown marker lists remain checked-in static blocks that the docs test compares after the fact; I did not run generators or tests because this review is read-only. Is this the best way to solve the issue? Mostly yes. Sharing a pure formatter across generator, check mode, and drift tests is the narrow maintainable fix, but the submitted branch must drop the changelog rewrite and use a cross-platform env wrapper for the new scripts. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against e1a98171417c. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +124, Tests +206, Docs -279, Config +2, Other +60. Total +113 across 10 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Sunspot Branchling Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
3d1fa0f to
9b8cc96
Compare
9b8cc96 to
06b3223
Compare
…atrix Both `docs/reference/secretref-user-supplied-credentials-matrix.json` and the marker-block lists in `docs/reference/secretref-credential-surface.md` are now derived from the registry-backed `buildSecretRefCredentialMatrix()` output instead of being hand-maintained next to the drift test. - Extend `scripts/generate-secretref-credential-matrix.ts` to rewrite both the JSON matrix and the supported/unsupported marker blocks in the Markdown reference. The script accepts `--check` and exits non-zero with a regenerate hint when either artifact is out of sync. - Add `src/secrets/credential-matrix-docs.ts` with pure formatters for the supported/unsupported Markdown bodies plus a strict marker-block replacer that throws on missing or out-of-order markers. The formatter preserves the openclaw.json/auth-profiles.json subsection split, renders sibling_ref entries with the compatibility-exception suffix, and annotates auth-profile entries with the existing type+oauth policy line. - Pivot `src/secrets/target-registry.docs.test.ts` to compare the on-disk artifacts against the same generator output the script uses, so the drift test cannot diverge from the writer. Keep the existing registry-shape parity check as a third independent guard. - Add `src/secrets/credential-matrix-docs.test.ts` with 10 unit tests locking in formatter ordering, sibling_ref rendering, the auth-profiles subsection, empty-list handling, idempotence, and the missing-marker error paths. - Wire `pnpm gen:secretref-docs` and `pnpm check:secretref-docs` into package.json, and add the check to the preflight stage of `scripts/check.mjs` so contributor branches catch drift before lint or typecheck rather than at the end of CI. Closes openclaw#44289.
The new src/secrets/credential-matrix-docs.ts module is consumed by scripts/generate-secretref-credential-matrix.ts and the two co-located test files, but knip's --production scan does not follow imports from scripts/ or test files. Mirror the existing allowlist entry for src/secrets/credential-matrix.ts so check-deadcode-unused-files passes.
06b3223 to
9871b6a
Compare
|
✅ Rebased onto latest upstream/main — CHANGELOG conflict resolved (upstream has migrated to a different changelog format; the PR's changelog content is preserved in the commit history and the core docs-generation code is intact). Ready for review. |
|
Superseded by #89142 — rebased onto latest main, CHANGELOG change removed, cross-platform env scripts wrapped in run-with-env.mjs. |
Summary
Generates the SecretRef credential reference docs (
docs/reference/secretref-user-supplied-credentials-matrix.jsonand the marker-block lists indocs/reference/secretref-credential-surface.md) from the same registry-backed source that already powerssrc/secrets/target-registry.docs.test.ts, so contributor branches stop hitting CI drift on artifacts that should never need hand-editing.Closes #44289.
buildSecretRefCredentialMatrix(). Updatingsrc/secrets/target-registry-data.ts(or any bundled-channel unsupported pattern) no longer requires editing two separate docs files.scripts/generate-secretref-credential-matrix.tsnow accepts--check. Without flags it rewrites the JSON matrix and the supported/unsupported marker blocks in the Markdown reference; with--checkit exits non-zero with a regenerate hint when either artifact is out of sync.pnpm gen:secretref-docs(writer) andpnpm check:secretref-docs(verifier).scripts/check.mjsrunscheck:secretref-docsin the preflight stage so contributor branches catch drift before typecheck/lint, not at the tail of CI.target-registry.docs.test.tsnow compares on-disk artifacts against the same formatter the script uses, so the test cannot diverge from the writer. The existing registry-shape parity check is preserved as a third independent guard.credential-matrix-docs.test.ts): 10 isolated tests cover ordering, sibling_ref rendering (channels.googlechat.serviceAccountcompatibility exception), theauth-profiles.jsonsubsection annotation, empty-list handling, idempotence, and the missing-marker error paths.Change Type
Scope
Linked Issue
Real behavior proof
Behavior or issue addressed: The two SecretRef reference artifacts were hand-maintained while only
src/secrets/target-registry.docs.test.tscaught divergence. Editingsrc/secrets/target-registry-data.ts(or adding a bundled-channel unsupported pattern) silently produced reference files that did not match the registry until a later CI failure on an unrelated branch. ClawSweeper triaged this in #44289 (comment) and labelled itclawsweeper:queueable-fix.Real environment tested: Local macOS 15.7.4 (Darwin 25.4.0 arm64) host running Node v22.22.0 and Corepack-managed pnpm against the branch HEAD
9b8cc969. No remote services were involved; the change is purely doc generation, package scripts, preflight wiring, and tests. The new generator and check script were run end-to-end against the real working tree, including a destructive drift simulation and a byte-for-byte restore viagen:secretref-docs.Exact steps or command run after this patch: Five real terminal sessions were run end-to-end against the patched working tree. (1)
pnpm gen:secretref-docsto confirm idempotence on a clean tree. (2)pnpm check:secretref-docsto confirm exit 0 on the generator output. (3) Destructive drift simulation:cp docs/reference/secretref-credential-surface.md /tmp/orig.md && sed -i '' '/channels.discord.token/d' docs/reference/secretref-credential-surface.md && pnpm check:secretref-docs && node scripts/run-vitest.mjs run src/secrets/target-registry.docs.test.tsto verify the check fails closed and the drift test surfaces the same divergence. (4) Regeneration restore:pnpm gen:secretref-docs && pnpm check:secretref-docs && diff /tmp/orig.md docs/reference/secretref-credential-surface.mdto verify byte-for-byte recovery. (5) Full repo guards on the touched paths:node scripts/run-tsgo.mjs -p tsconfig.core.json && node scripts/run-tsgo.mjs -p tsconfig.json && node scripts/run-vitest.mjs run src/secrets/credential-matrix-docs.test.ts src/secrets/target-registry.docs.test.ts src/secrets/target-registry.test.ts && pnpm format:check <touched files> && pnpm lint <touched files>.Evidence after fix: Redacted real terminal output from the local working tree, captured at branch HEAD before push.
Generator idempotence on a clean tree:
Check mode passes on the generated tree:
Destructive drift simulation: removing one supported entry from the docs causes both the check script and the drift test to fail closed:
Regeneration restores the tree byte-for-byte:
Full guards on the touched paths after fix:
Observed result after fix: A contributor editing
src/secrets/target-registry-data.tsrunspnpm gen:secretref-docsonce and both reference artifacts update in lockstep. The new preflightcheck:secretref-docsstage ofscripts/check.mjssurfaces drift in the preflight guards alongsidedup:check:coverage, before the typecheck or lint stages, so contributor branches no longer hit late CI drift failures on the SecretRef reference docs. The destructive simulation captured above confirms the check fails closed (exit 1) and the regenerator restores the working tree byte-for-byte (diffexit 0).What was not tested: This patch does not touch runtime SecretRef resolution or audit behaviour, so the existing live SecretRef resolution coverage in
target-registry.test.tsis unchanged. No CI workflow changes were exercised end-to-end beyond the preflight wiring already covered byscripts/check.mjsin local runs; the actual CI run on this PR exercises the new preflight stage in the real GitHub Actions environment.Root Cause
scripts/generate-secretref-credential-matrix.tsonly wrote the JSON matrix; the Markdown reference's two marker blocks were edited by hand even though their content is fully determined by the registry.src/secrets/target-registry.docs.test.tsdetected drift but provided no path to regenerate, so contributors had to mirror the JSON change into the Markdown by hand and hope the test agreed.Regression Test Plan
credential-matrix-docs.test.ts)target-registry.docs.test.tsnow mirrors the writer)check:secretref-docsruns alongsidedup:check:coverage)src/secrets/credential-matrix-docs.test.ts(new — formatter contract)src/secrets/target-registry.docs.test.ts(rewritten — generator parity)User-visible / Behavior Changes
docs/reference/secretref-credential-surface.mdsupported-list entries are now deterministically ordered by id within theopenclaw.jsonsubsection (instead of registry-walk order). Marker comments, surrounding prose, and theauth-profiles.jsonsubsection heading are unchanged. The unsupported list preserves the registry-walk order (CORE_UNSUPPORTED_SECRETREF_SURFACE_PATTERNSfollowed by bundled-channel patterns), matching the existinggetUnsupportedSecretRefSurfacePatterns()contract.Scope boundary
Unreleasedentry are touched.