Skip to content

fix(secrets): secure captured contracts and reference docs - #120138

Closed
goutamadwant wants to merge 43 commits into
openclaw:mainfrom
goutamadwant:fix/secretref-docs-generator
Closed

goutamadwant wants to merge 43 commits into
openclaw:mainfrom
goutamadwant:fix/secretref-docs-generator

Conversation

@goutamadwant

@goutamadwant goutamadwant commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

SecretRef credential reference files could drift from the source target registry because they were maintained separately, while external channel-contract loading needed a deterministic captured-source boundary that remains compatible with existing native admission receipts.

Changes

  • Generate both SecretRef reference artifacts from the canonical registry and enforce drift checks in the documentation gate.
  • Load bundled source manifests and channel contracts through captured source while failing closed on malformed manifests, blocked candidates, incomplete discovery, mutable configuration, and escaped targets.
  • Preserve supported exact, wildcard, inherited baseUrl, in-root symlink, extensionless module, and unrelated extensionless asset behavior.
  • Capture executable contract dependencies by canonical path, including static imports and bound literal require aliases.
  • Bound capture entries and bytes, revalidate source descriptors, and reject unowned hardlinks before executable loading.
  • Upgrade legacy managed-native receipts only when the installed and captured names still account for the complete inode link inventory.
  • Use private native copies for strict runtime captures, replace hardlinked or source-referencing recovery namespaces, and preserve selected-host validation.
  • Keep OpenClaw-owned private admission sharing while rejecting external links, late source replacement, and non-missing source-resolution errors.
  • Preserve admission-owned native-link inventories when recovery retains an input after the original installed source is removed.
  • Resolve channel security surfaces from each collected source root so documentation checks remain deterministic when ambient bundled-plugin discovery is disabled.

Evidence

At signed head 6b42e60d4e277b26ad6f7bed1b75ba9135251472:

  • Native recovery after package removal passes for standalone and package-export variants, including the file-symlink fallback path.
  • Recovery-link inventory propagation is covered across multiple same-inode members after an original source is removed.
  • An additional external hardlink remains rejected after recovery-link propagation.
  • Source-directory EACCES and other non-missing realpath errors fail closed; only confirmed missing paths are skipped during retained recovery.
  • Strict native captures resolve to private nlink=1 inodes rather than the installed source inode.
  • Legacy receipts with exactly the admission-owned names are upgraded, while late hardlinks and pathname substitution remain rejected.
  • With OPENCLAW_DISABLE_BUNDLED_PLUGINS=1, the SecretRef generator still loads source-owned channel security surfaces and reports the generated artifacts as current.
  • Independent correctness and security reviews found no remaining actionable findings.

Validation

Current-head validation:

OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 node --import ./scripts/tsx.mjs scripts/generate-secretref-docs.ts --check
# passed: SecretRef reference docs are up to date.

pnpm test test/scripts/secretref-docs-file.test.ts --maxWorkers=1
# passed: 1 file, 8 tests

pnpm check:bundled-channel-config-metadata
# passed

node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.root.scripts.json --incremental
# passed

pnpm exec oxlint scripts/generate-bundled-channel-config-metadata.ts test/scripts/secretref-docs-file.test.ts
# passed

git diff --check
# passed

Native recovery validation:

pnpm test src/plugins/plugin-module-loader-recovery.test.ts src/plugins/plugin-native-namespace.legacy-hardlinks.test.ts --maxWorkers=1
# passed: 2 files, 20 tests

node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.plugins-platform.json --incremental
# passed

Post-merge validation before the CI follow-up:

pnpm test src/plugins/plugin-native-namespace.legacy-hardlinks.test.ts src/plugins/plugin-generation-artifact.admission.test.ts src/plugins/plugin-generation-executable-capture.test.ts src/plugins/plugin-generation-source-inspection.test.ts src/plugins/plugin-source-file.copy.test.ts src/secrets/channel-contract-api.external.test.ts src/secrets/credential-matrix-docs.test.ts src/secrets/target-registry-data.current-snapshot.test.ts src/secrets/target-registry.docs.test.ts test/scripts/ci-workflow-planning.test.ts test/scripts/secretref-docs-file.test.ts --maxWorkers=1
# passed: 11 files, 707 tests

Earlier behavior-bearing validation:

pnpm build
pnpm check:secretref-docs
pnpm check:assertion-safety
pnpm check:docs
pnpm exec oxfmt --check
pnpm exec oxlint src/plugins/plugin-generation-artifact.ts src/plugins/plugin-generation-capture-budget.ts src/plugins/plugin-generation-source-lookup.ts src/plugins/plugin-instance-module-loader.ts src/plugins/plugin-native-admission.ts src/plugins/plugin-native-namespace.ts src/plugins/plugin-native-namespace.legacy-hardlinks.test.ts

Limitations

  • No external provider behavior was required or claimed; proof is deterministic and repository-local.
  • The security-sensitive-path gate requires fresh maintainer approval for this head.
  • The persisted native-link inventory compatibility decision remains maintainer-owned.
  • The preceding hosted run also exposed production/core-1 type failures reproduced on current main and unrelated flaky Telegram, Gateway, Discord, Codex DB, UI, and Feishu tests.
  • Hosted CI and automated review have restarted for this head.

Disclosure: AI was used to understand the codebase and review the fix.

@goutamadwant
goutamadwant requested a review from a team as a code owner August 7, 2026 03:57
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: M labels Aug 7, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR generates SecretRef reference artifacts from registry metadata and strengthens captured contract and native-file admission.

Example: A contributor updates registry metadata for channels.googlechat.serviceAccount.

  • Before: The JSON matrix and Markdown credential list require separate manual synchronization.
  • After: pnpm gen:secretref-docs regenerates both artifacts, and the documentation gate detects drift.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The generator check is demonstrated and no new actionable code defect was found, but required runtime authority and upgrade evidence remains incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Contributors must manually synchronize credential-reference artifacts, and external contract loading currently executes from original sidecar paths.
Reason: Reference generation has clear value, but the combined patch changes an established native-capture policy and persisted receipt shape.

Merge readiness

⛔ Blocked before merge - 6 items remain

This PR contains useful work absent from current main, and the latest commit resolves the prior metadata-root finding; the expanded native-capture policy still needs an owner decision.

Priority: P2
Reviewed head: 6b42e60d4e277b26ad6f7bed1b75ba9135251472
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should strict external-plugin captures replace managed native-link reuse with private copies and persist exact link inventories in admission receipts?
  • Recommendation: Approve the combined hardening direction: Accept private copies for strict roots and additive receipt inventories once runtime security and stable-upgrade evidence establish the intended boundary and compatibility.
  • Why: The existing owner deliberately optimized managed-native reuse, while this external PR changes that policy and serialized receipt contract without recorded owner approval.

Before merge

  • Add real behavior proof - Authority-chain proof required: supplied terminal output demonstrates the source-bound generator --check path, but runtime loading is supported only by tests and assertions; provide terminal screenshots or redacted logs showing an allowed contract executing, outside or replaced source rejected before execution, and stale retained-link inventories unable to authorize replacement code, identifying the environment and redacting keys, IPs, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security review attention item - The changed execution boundary needs final-effect evidence before security clearance.
  • Resolve merge risk - Before merge, establish that retained admission-link inventories cannot authorize substituted native code after source replacement or recovery.
  • Complete next step - Attribute the five completed test-job failures on the reviewed head before merging, and require contributor repairs only for failures caused by this diff.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Low-value test src/plugins/plugin-generation-executable-capture.test.ts: Remove the helper-only mocked-copy test: it primarily pins copyPackage arguments and call counts, while real captured-contract tests already exercise symlink dependency loading.
  • Missing end-to-end proof: Missing runtime allowed/forbidden execution traces and a v2026.10.1-to-candidate upgrade preserving installed plugin receipts and recovery; base-failing regression runs are not shown.
Agent review details

How this fits together

Plugin manifests and admission receipts feed captured contract loading, whose credential metadata supplies runtime SecretRef discovery and reference-document generation.

flowchart LR
 A[Plugin manifests] --> B[Captured source]
 C[Admission receipts] --> B
 B --> D[Contract loader]
 D --> E[Secret registry]
 E --> F[Docs generator]
 F --> G[Reference artifacts]
Loading

Technical review

Best possible solution:

Land canonical reference generation with an owner-approved native-custody policy and preserved installed-plugin recovery behavior.

Do we have a high-confidence way to reproduce the issue?

Fetched main confirms separate reference artifacts and no shared regeneration command; the external-loader path is source-verifiable, but no runtime exploit reproduction was performed.

Is this the best way to solve the issue?

A shared registry-backed formatter addresses documentation drift directly; the broader runtime hardening needs explicit agreement on its custody and performance tradeoff.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ec9db387c421.

Merge-risk options

Maintainer options:

  1. Keep the PR pending boundary evidence (recommended)
    Retain the useful contribution while the changed admission owner is exercised against substituted source and stale recovery inventories before execution.

Provenance checked

  • External channel-contract loading keeps the original intent (b1f8172: Restore SecretRef collection for externalized channel plugins through generic package sidecars, as recorded in fix(secretrefs): resolve external channel contracts #76449.)
  • Plugin cache ownership keeps the original intent (c6c2268: Use one progressive lifecycle owner for checked metadata, artifact resolution, and lazy module exports.)
  • Managed native admission changes intended behavior with a stated reason (9faa93d: Avoid repeated native-byte copies and hashing while preserving retained companion paths; this PR explains stricter private custody as its security rationale.)
  • Generated channel security metadata keeps the original intent (bd20a92: Generate SecretRef policy metadata for configuration consumers; the correction binds collection to the selected source tree.)

Testing

Proof path: shipped entry point.

Security

Needs attention: The changed execution boundary needs final-effect evidence before security clearance.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9faa93d adds src/plugins/plugin-native-admission.ts:143 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9faa93d44c85; files: src/plugins/plugin-native-admission.ts)
  • Josh Avant: Raw commit b1f8172 adds src/secrets/channel-contract-api.ts:157 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b1f8172867f3; files: src/secrets/channel-contract-api.ts)
  • Vincent Koc: Raw commit bd20a92 adds scripts/generate-bundled-channel-config-metadata.ts:140 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: bd20a920a2a3; files: scripts/generate-bundled-channel-config-metadata.ts)

PR surface

Source +1338, Tests +1828, Config +2, Other +199. Total +3367 across 41 files. Added test files: 4.

View PR surface stats
Area Files Added Removed Net
Source 23 1651 313 +1338
Tests 11 1895 67 +1828
Docs 0 0 0 0
Config 1 3 1 +2
Generated 0 0 0 0
Other 6 224 25 +199
Total 41 3773 406 +3367

Review metrics

Metric Value Why it matters
Persisted receipt contract 1 optional field: admissionHardlinks Adds inode-link ownership metadata to existing installed-index receipts without adding a database table or configuration option.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Useful contributor tooling and plugin-admission hardening with a limited plugin-loading surface; no urgent production incident is established.
  • merge-risk: 🚨 compatibility: Strict native captures change managed-file reuse and consume legacy persisted receipts, requiring owner agreement and stable-upgrade validation.
  • merge-risk: 🚨 security-boundary: Captured paths and retained link inventories determine which external plugin code reaches execution.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof for substituted source and stale recovery-link inventories before executable loading.
  • Show a latest-stable upgrade retaining installed-plugin state and successful native recovery.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (58 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-10T08:51:47.777Z sha 62f9abc :: needs real behavior proof before merge. :: [P1] Preserve supported path mappings for runtime channel contracts | [P1] Keep cold module eviction out of ordinary inventory retirement | [P2] Reuse the updater-aware source exclusion in the contract walk
  • reviewed 2026-10-10T09:40:06.538Z sha df54e89 :: needs real behavior proof before merge. :: [P1] Preserve supported path mappings for runtime channel contracts | [P1] Keep cold module eviction out of ordinary inventory retirement | [P2] Reuse the updater-aware source exclusion in the contract walk | [P2] Distinguish admitted native hardlinks from unsafe contract inputs | [P2] Reduce the added capture code to pass the enforced lint gate
  • reviewed 2026-10-10T13:58:28.692Z sha ead8d81 :: needs real behavior proof before merge. :: [P2] Include the extracted helpers in the PR wrapper inventory | [P1] Keep unrelated extensionless assets from disabling path mappings | [P1] Upgrade native receipts before rejecting their retained links
  • reviewed 2026-10-10T14:13:02.985Z sha 3e9313f :: needs real behavior proof before merge. :: [P2] Include the extracted helpers in the PR wrapper inventory | [P1] Keep unrelated extensionless assets from disabling path mappings | [P1] Upgrade native receipts before rejecting their retained links
  • reviewed 2026-10-10T15:20:24.956Z sha 10ee0dc :: needs real behavior proof before merge. :: [P1] Keep unrelated extensionless assets from disabling path mappings | [P1] Upgrade native receipts before rejecting their retained links
  • reviewed 2026-10-11T03:18:14.155Z sha 0a47c46 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-11T05:31:41.789Z sha 36771f6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-11T06:06:06.203Z sha 8b340c1 :: needs real behavior proof before merge. :: [P2] [P2] Bind the metadata prepass to the selected source tree

Reviewed October 11, 2026, 3:21 AM ET / 07:21 UTC (Revision 59).

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 7, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@goutamadwant
goutamadwant force-pushed the fix/secretref-docs-generator branch from 4b05b3b to c6d6bba Compare August 20, 2026 10:38
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Aug 20, 2026
@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Sep 30, 2026
@steipete

Copy link
Copy Markdown
Contributor

Thanks for the PR. We're closing older pull requests that have gone stale against current main.

This is a large (+3.7k lines) security-sensitive change with failing CI that still needs behavior proof, bundling doc generation with contract-admission changes. Please split it into smaller focused PRs against current main if you want to continue.

If this change is still needed, please open a fresh PR against current main and we'll review it there.

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

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts security-review-required security-sensitive-changed size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants