Skip to content

refactor(plugins): tighten web fetch provider boundary - #59646

Merged
vincentkoc merged 4 commits into
mainfrom
chore/web-fetch-contract-cleanup
Apr 2, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
chore/web-fetch-contract-cleanup

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

  • Problem: after #59465, Firecrawl fetch execution was mostly behind the plugin boundary, but one compare/helper seam still lived in core and there was no dedicated guardrail to stop vendor-specific fetch logic from drifting back into core.
  • Why it matters: the boundary was cleaner but not enforced, migration coverage was still narrow, and main picked up two follow-up failures from the new plugin-owned Firecrawl fetch config path.
  • What changed: moved the remaining Firecrawl fetch helper into extensions/firecrawl/api.ts, removed the core helper/export, tightened the generic web-fetch provider contract suite, expanded doctor migration coverage, added a CI/test guard for Firecrawl-specific fetch logic in core, and fixed the config-baseline + exec-secret-ref parity fallout.
  • What did NOT change (scope boundary): this PR does not add a local/browser-backed fetch provider and does not redesign the web_fetch tool contract.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause / Regression History (if applicable)

  • Root cause: #59465 established the fetch-provider boundary, but one Firecrawl compare/helper path still lived in core and there was no dedicated fetch-boundary guard equivalent to the existing web-search guard.
  • Missing detection / guardrail: no web_fetch-specific boundary lint/test existed, contract coverage did not assert provider-owned selection/config seams strongly enough, and main fallout from the new plugin-owned Firecrawl fetch secret target was not folded into the follow-up branch yet.
  • Prior context (git blame, prior PR, issue, or refactor if known): direct follow-up after #59465 landed.
  • Why this regressed now: the original PR intentionally prioritized the boundary move and compat path; this cleanup finishes the seam and folds in the post-merge parity/baseline failures.
  • If unknown, what was ruled out: N/A.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
    • test/web-fetch-provider-boundary.test.ts
    • src/plugins/contracts/web-fetch-provider.contract.test.ts
    • src/commands/doctor-legacy-config.migrations.test.ts
    • extensions/firecrawl/src/firecrawl-tools.test.ts
    • src/secrets/exec-secret-ref-id-parity.test.ts
    • src/config/doc-baseline.integration.test.ts
  • Scenario the test should lock in: Firecrawl fetch execution/helper ownership stays in the plugin, generic fetch-provider contracts cover provider-owned config/selection seams, legacy Firecrawl fetch migration remains merge-safe, and the plugin-owned Firecrawl fetch secret target stays classified in shared secret metadata/baselines.
  • Why this is the smallest reliable guardrail: it validates the seam itself instead of broad unrelated runtime flows.
  • Existing test that already covers this (if any): the Firecrawl and web-fetch provider tests from #59465 cover the runtime behavior; this PR extends the boundary and migration/metadata coverage.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

  • None for normal users beyond the already-landed #59465 behavior.
  • Maintainer/developer-visible changes:
    • Firecrawl compare helper now lives in the Firecrawl extension, not core.
    • CI now enforces a dedicated web-fetch provider boundary guard.
    • openclaw doctor migration coverage is stronger for plugin-owned Firecrawl fetch config.

Diagram (if applicable)

Before:
[scripts/firecrawl-compare] -> [core web-fetch helper] -> [Firecrawl provider]

After:
[scripts/firecrawl-compare] -> [extensions/firecrawl/api.ts] -> [Firecrawl plugin runtime]

Guardrail:
[core src/**] -X-> [Firecrawl-specific fetch logic]

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:
    • N/A

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: Node 22 / pnpm workspace
  • Model/provider: N/A
  • Integration/channel (if any): Firecrawl plugin / core web-fetch boundary
  • Relevant config (redacted): plugins.entries.firecrawl.config.webFetch.*, legacy tools.web.fetch.firecrawl.*

Steps

  1. Run the Firecrawl compare helper and verify it no longer imports core Firecrawl fetch logic.
  2. Run the web-fetch provider contract tests and migration tests.
  3. Run the secret parity/config baseline tests that failed on main after #59465.

Expected

  • Firecrawl-specific fetch helper logic is owned by the extension.
  • Core stays free of Firecrawl fetch execution logic.
  • Contract, migration, parity, and baseline checks are all green.

Actual

  • Now matches expected.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios:
    • pnpm test -- src/plugins/contracts/web-fetch-provider.contract.test.ts src/commands/doctor-legacy-config.migrations.test.ts extensions/firecrawl/src/firecrawl-tools.test.ts test/web-fetch-provider-boundary.test.ts
    • pnpm test -- src/secrets/exec-secret-ref-id-parity.test.ts src/config/doc-baseline.integration.test.ts
    • pnpm tsgo
    • pnpm run lint:web-fetch-provider-boundaries
    • pnpm build
  • Edge cases checked:
    • extension-owned Firecrawl helper preserves compare-script behavior
    • fetch provider contracts assert credential/config selection seams
    • doctor migration still merges legacy Firecrawl fetch config without overriding explicit plugin config
    • plugin-owned Firecrawl fetch secret target stays classified in parity coverage
  • What you did not verify:
    • full pnpm test
    • a local/browser-backed fetch provider

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:
    • N/A

Risks and Mitigations

  • Risk:

    • boundary guard could be too strict and block legitimate shared fetch plumbing later.
    • Mitigation:
      • the guard is intentionally scoped to a small allowlist of core files and only catches Firecrawl-specific fetch logic.
  • Risk:

    • moving the compare helper into the extension could break the existing script flow.
    • Mitigation:
      • extension-owned helper tests cover the script-facing API shape and Firecrawl scrape params.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts commands Command implementations agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Apr 2, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review April 2, 2026 11:44
@vincentkoc
vincentkoc requested a review from a team as a code owner April 2, 2026 11:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d4960573d

ℹ️ About Codex in GitHub

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

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

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/ci.yml Resolved
@greptile-apps

greptile-apps Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR completes the web-fetch provider boundary work from #59465: moves the remaining fetchFirecrawlContent helper into extensions/firecrawl/api.ts, removes the core export from web-tools.ts, adds a CI lint step + test to guard the boundary, and folds in the config-baseline / exec-secret-ref parity failures that were regressed on main. The config baseline correctly moves 9 Firecrawl-specific core paths into 6 plugin-owned paths and adds a generic tools.web.fetch.provider entry.

Confidence Score: 5/5

  • Safe to merge — all remaining findings are P2 style/documentation suggestions with no functional impact.
  • The boundary move is clean, the migration and parity tests cover the regressed paths, and the contract suite additions are correctly constrained. The two P2 comments are about guard coverage breadth and a missing explanatory comment — neither affects correctness.
  • scripts/check-web-fetch-provider-boundaries.mjs (guard coverage scope) and src/plugins/contracts/suites.ts (implicit inactiveSecretPaths invariant).
Prompt To Fix All With AI
This is a comment left during a code review.
Path: scripts/check-web-fetch-provider-boundaries.mjs
Line: 64

Comment:
**Boundary guard only checks 6 specific files**

The guard walks all of `src/` via `walkFiles` but immediately skips any file not in `focusedCoreFiles`, so it effectively only protects those 6 enumerated files. A new file like `src/agents/tools/web-fetch-helper.ts` could contain Firecrawl-specific fetch logic and would silently pass. By contrast, the sibling `check-web-search-provider-boundaries.mjs` does a comprehensive scan of all of `src/` using a baseline inventory — making the fetch guard notably weaker. If the intent is to protect the entire core boundary (not just the allowlist), the file-enumeration approach should be replaced with an allowlist-exclusion approach, similar to the web-search guard.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/plugins/contracts/suites.ts
Line: 157-160

Comment:
**`credentialPath` must appear in `inactiveSecretPaths` when defined — consider a comment**

The new assertion `expect(provider.inactiveSecretPaths).toContain(provider.credentialPath)` enforces an invariant that is non-obvious from the type description (`"Legacy or inactive credential paths that should warn but not activate this provider"`). The reason `credentialPath` must also be in the list is that `inactivePathsForProvider` in `runtime-web-tools.ts` uses `inactiveSecretPaths` directly when it is non-empty, so omitting `credentialPath` would cause the active credential path to be excluded from classification/detection. A brief inline comment on the assertion (or on the `inactiveSecretPaths` type field) explaining this coupling would prevent future implementors from accidentally omitting `credentialPath` from their list.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Merge branch 'main' into chore/web-fetch..." | Re-trigger Greptile

Comment thread src/plugins/contracts/suites.ts Resolved
@vincentkoc
vincentkoc merged commit 6eca194 into main Apr 2, 2026
9 checks passed
@vincentkoc
vincentkoc deleted the chore/web-fetch-contract-cleanup branch April 2, 2026 11:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 33d3aa47b6

ℹ️ About Codex in GitHub

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

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

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +31 to +33
/providerId:\s*"firecrawl"/,
/provider:\s*"firecrawl"/,
/id:\s*"firecrawl"/,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Cover equality checks in web-fetch boundary guard

The new boundary lint only looks for object-literal/import spellings like providerId: "firecrawl" and provider: "firecrawl". A core regression written as a comparison (for example if (providerId === "firecrawl") or case "firecrawl":) is not matched, so lint:web-fetch-provider-boundaries can return success even when Firecrawl-specific fetch branching has re-entered src/**. Because this guard is now wired into check-additional as the enforcement point, these common comparison forms need to be detected as well (or handled via AST parsing).

Useful? React with 👍 / 👎.

ngutman pushed a commit that referenced this pull request Apr 3, 2026
* refactor(plugins): tighten web fetch provider boundary

* fix(config): sync fetch secret parity and baseline

* fix(ci): enforce web fetch boundary guard
steipete pushed a commit to duncanita/openclaw that referenced this pull request Apr 4, 2026
* refactor(plugins): tighten web fetch provider boundary

* fix(config): sync fetch secret parity and baseline

* fix(ci): enforce web fetch boundary guard
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* refactor(plugins): tighten web fetch provider boundary

* fix(config): sync fetch secret parity and baseline

* fix(ci): enforce web fetch boundary guard
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* refactor(plugins): tighten web fetch provider boundary

* fix(config): sync fetch secret parity and baseline

* fix(ci): enforce web fetch boundary guard
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* refactor(plugins): tighten web fetch provider boundary

* fix(config): sync fetch secret parity and baseline

* fix(ci): enforce web fetch boundary guard
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
* refactor(plugins): tighten web fetch provider boundary

* fix(config): sync fetch secret parity and baseline

* fix(ci): enforce web fetch boundary guard
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
* refactor(plugins): tighten web fetch provider boundary

* fix(config): sync fetch secret parity and baseline

* fix(ci): enforce web fetch boundary guard
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
* refactor(plugins): tighten web fetch provider boundary

* fix(config): sync fetch secret parity and baseline

* fix(ci): enforce web fetch boundary guard
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
* refactor(plugins): tighten web fetch provider boundary

* fix(config): sync fetch secret parity and baseline

* fix(ci): enforce web fetch boundary guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant