Skip to content

feat: site-build-gate as external pkg - #3143

Merged
witalisoft merged 3 commits into
masterfrom
feat/site-build-gate-as-ext-pkg
Oct 15, 2026
Merged

witalisoft merged 3 commits into
masterfrom
feat/site-build-gate-as-ext-pkg

Conversation

@witalisoft

@witalisoft witalisoft commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Learn runs the published @netdata/site-build-gate package instead of a copy of the gate checked in under scripts/site-build-gate/. A Dependabot security update to one of the gate's dependencies is then an ordinary yarn.lock change. It no longer fails the Netlify build on a checksum mismatch.

 build:netlify
   verify-git-history
   verify-indexnow-vendor
-  npm ci --prefix scripts/site-build-gate      # separate npm lock, bound by manifest.json
   docusaurus build
   run-post-build-gates
-    scripts/site-build-gate/site_build_gate.mjs       # refuses to run if any file's hash differs
+    node_modules/@netdata/site-build-gate/site_build_gate.mjs
 package.json
+  devDependencies: "@netdata/site-build-gate": "^10.1.0"
 yarn.lock
+  @netdata/site-build-gate@^10.1.0             # css-tree, parse5, saxes already in the graph
 scripts/
-└── site-build-gate/
-    ├── manifest.json        # SHA-256 of package.json, package-lock.json, site_build_gate.mjs
-    ├── package.json
-    ├── package-lock.json
-    └── site_build_gate.mjs

The gate's rules, baseline (config/site-build-gate-baseline.json) and command-line arguments are unchanged.

  • Source and versioning: the package is published from netdata-labs/seo (vendor/site-build-gate/). Its major version is the ruleset version, so 10.x means ruleset 10.
  • Tests: they no longer pin checksums. Instead they check that the installed gate's major version matches the baseline's ruleset_version.
  • Docs: AGENTS.md (static build gate contract) and README.md (dependency authority, and the local setup step that mentioned the nested gate install) describe the package instead of the copy.

Evidence

  • Before: a lockfile-only update to a gate dependency, the shape of a Dependabot security PR, fails after the full Docusaurus build:

    site build gate contract error: vendor checksum mismatch for package-lock.json: expected a3cac544…, got 3c71e70c…
    exit=2
    

    Bump source-map-js from 1.2.1 to 1.2.2 in /scripts/site-build-gate #3121 (source-map-js 1.2.1 → 1.2.2) shows this in practice: all GitHub checks were green, netlify/netdata-docusaurus/deploy-preview was red, and the PR was closed. The fix needed coordinated changes in seo, website and Learn (Consolidate Learn dependencies and runtime updates #3136).

    After: the same kind of change, only yarn.lock (entities 8.1.0 → 8.0.0, within ^8.0.0), installed with --frozen-lockfile:

    node scripts/run-post-build-gates.mjs
    "checked_pages": 2030,
    "regressions": [],
    exit=0
    
  • Full Netlify build (npm run build:netlify, Node 22.23.2): passes. The site build gate scanned 2,030 pages with 0 regressions, the Cloudflare analytics gate passed, and there are 297 broken-anchor warnings, the same as master.

  • Tests: yarn test:run passes: Vitest 494 passed and 1 skipped, plus the first-touch (26), IndexNow (64), Swagger UI assets (3), dependency-authority (3) and site-build-gate (4) suites.

  • Pull request checks on b1eebcd0f (^10.1.0): the Netlify deploy preview, header and redirect rules, the required same-site links job, the advisory cross-site and new third-party link jobs, verify and the dependency-impact check all pass.

  • Published package (10.1.0 on registry.npmjs.org, released by the seo publish workflow through npm trusted publishing): all four files are byte-identical to vendor/site-build-gate/ at seo main @ 7b3e6d83. Installed from the registry, it gives site build gate v10: 2030 pages, 0 regression(s), 0 accepted finding(s) on the same build.

Merge Danger

Door: two-way

Reverting this PR restores the vendored copy and its npm ci step exactly. The published package stays on npm either way; nothing else depends on it yet.

Blast Radius: deploys

  • Every Netlify build runs the gate. If the package were missing or broken, every deploy would fail (exit 2), including ingest. It fails loudly; it can't silently let pages through.
  • Version range: ^10.1.0 lets Dependabot propose later 10.x releases as their own PRs; .github/dependabot.yml needs no change. A new major is a ruleset change: its Dependabot PR fails the Netlify build by design (baseline ruleset 10 does not match 11) until the PR also updates config/site-build-gate-baseline.json and any new findings are reviewed.
  • Changes an earlier decision: "Learn commits the checksum-bound gate" becomes "Learn installs a published version". Costa agreed to this experiment.
  • Trade-off: the gate's parser dependencies now float within ^ ranges in Learn's yarn.lock instead of matching seo byte for byte.
    • Caught by the build: a parser update that crashes the gate or reports defects that aren't there.
    • Not caught here: a parser update that makes the gate miss a defect. Only seo's fixture tests can catch that.
  • Left unchanged on purpose: config/seo-remediation-contract.json still names scripts/site-build-gate, because it's a frozen historical acceptance record.

Summary by CodeRabbit

  • Build and Dependency Management

    • The site-build gate is now installed as a published package and runs locally after the Docusaurus build.
    • The gate’s major version is checked against the configured baseline version.
    • The Netlify build no longer performs a separate dependency installation for the gate.
  • Documentation

    • Updated setup and dependency guidance to reflect the package-based gate and the project’s Node.js and Yarn versions.

@netlify

netlify Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for netdata-docusaurus ready!

Name Link
🔨 Latest commit b1eebcd
🔍 Latest deploy log https://app.netlify.com/projects/netdata-docusaurus/deploys/6ace309bb097d0dbb6eee28c
😎 Deploy Preview https://deploy-preview-3143--netdata-docusaurus.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 02223129-1337-45f8-bc7e-b3af5abf1a82
📥 Commits

Reviewing files that changed from the base of the PR and between 03daccf and b1eebcd.

⛔ Files ignored due to path filters (2)
  • scripts/site-build-gate/package-lock.json is excluded by !**/package-lock.json
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (12)
  • .gitignore
  • AGENTS.md
  • README.md
  • package.json
  • scripts/run-post-build-gates.mjs
  • scripts/site-build-gate/manifest.json
  • scripts/site-build-gate/package.json
  • scripts/site-build-gate/site_build_gate.mjs
  • src/seo/deploymentIntegrations.test.js
  • src/seo/postBuildGates.test.js
  • tests/dependency_authority.test.js
  • tests/site_build_gate.test.js
💤 Files with no reviewable changes (4)
  • .gitignore
  • scripts/site-build-gate/package.json
  • scripts/site-build-gate/manifest.json
  • scripts/site-build-gate/site_build_gate.mjs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The build now installs @netdata/site-build-gate through the root Yarn dependency graph and runs it after Docusaurus. The repository’s vendored gate package and separate install step are removed.

Changes: Site build gate package migration

Layer / File(s) Summary
Replace the vendored gate with the published package
package.json, scripts/site-build-gate/*, AGENTS.md, README.md, .gitignore, tests/dependency_authority.test.js
The root package declares @netdata/site-build-gate at ^10.1.0. The vendored implementation and package metadata are removed, along with the nested install guidance and related dependency-authority assertions.
Run the installed gate after the build
scripts/run-post-build-gates.mjs, src/seo/*, tests/site_build_gate.test.js
The post-build runner invokes the installed package path. Tests check that invocation, retain the build-before-gate ordering check, and assert that the installed package major version matches the baseline ruleset version.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: ktsaou

Merge Risk: ⚪ Minimal · up to b1eeb

The published gate’s installed entrypoint is present, and no issue remains that needs correction before merge.

Security architecture risk: 🔵 Low · up to b1eeb

The gate remains a build-time validator with the same consumed arguments and failure handling. Its installed implementation matches the previous checker apart from removing vendor-manifest verification. The lockfile pins the package and records its integrity, but package publication now becomes part of the build’s trust chain. No exploitable bypass was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The newly trusted gate implementation executes with the build account’s process authority, repository working directory, and inherited environment. A compromised accepted package could therefore affect accessible build files or environment data, not merely gate results. Those execution privileges predate the PR; the implementation distribution authority changes. Actual credentials and broader environment access were not established.

Trust Boundaries and Controls

  • observed — Repository-bound vendor hashes are replaced by package distribution and root-lockfile integrity. This is an intentional authority transfer, not evidence of malicious code or a verified input bypass. The locked package identity and matching local checker implementation are counterevidence to an immediate regression, but neither establishes the external publisher’s source revision or publication controls.

Resilience and Maintainability Implications

  • observed — The inspected gate reads build content and the baseline and produces a report without introducing a shared-output mutation phase. Contract failures return a nonzero status, which the runner rejects. Tests retain assertions for rendered defects, malformed input, and unchanged fixture bytes; these assertions were inspected, not executed during this review.

Hardening Proposals

  • proposed — For future gate releases, record a verifiable link between the accepted npm artifact and its publishing source revision, and review implementation changes separately from parser-only security updates. This would strengthen the new package-authority boundary without restoring checksum coupling to transitive dependency updates.
Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. (3 skipped: 3 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: replacing the local site-build-gate with an external package.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 14 files

Confidence score: 3/5

  • The package.json build gate is pinned to 10.1.0-test.0, which the PR says must not ship. Update it to 10.1.0 after that release is published before merging.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="package.json">

<violation number="1" location="package.json:76">
P2: This pins the build gate to the prerelease `10.1.0-test.0`, which the PR description explicitly says must not ship. Update the pin to `10.1.0` after that release is published before merging.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant CI as Netlify Build
    participant NPM as npm Registry
    participant Yarn as yarn.lock
    participant Gate as @netdata/site-build-gate
    participant Baseline as config/site-build-gate-baseline.json
    participant PostGate as run-post-build-gates.mjs
    participant Docusaurus as Docusaurus Build

    Note over CI,PostGate: Site Build Gate Flow

    CI->>CI: verify-git-history.js
    CI->>CI: verify-indexnow-vendor.js
    CI->>Yarn: install dependencies (--frozen-lockfile)
    Yarn-->>CI: node_modules ready
    CI->>Docusaurus: docusaurus build
    Docusaurus-->>CI: build/ output

    CI->>PostGate: node scripts/run-post-build-gates.mjs
    PostGate->>Gate: run gate with args (--build-dir, --site-origin, --baseline, --integration-route-prefix)
    Gate->>Gate: validate Node 22.x
    Gate->>Docusaurus: scan build output (2030 pages)

    alt Gate major version matches baseline ruleset
        Gate->>Baseline: read ruleset_version
        Baseline-->>Gate: ruleset_version = 10
        Gate->>Gate: run ruleset 10 checks
        Gate-->>PostGate: JSON report (0 regressions)
        PostGate-->>CI: exit 0
    else Gate major version mismatch
        Gate->>Baseline: read ruleset_version
        Baseline-->>Gate: ruleset_version = 10
        Gate-->>PostGate: contract error (exit 2)
        PostGate-->>CI: build fails
    end

    Note over NPM,Yarn: NEW: Gate installed from npm as devDependency
    NPM-->>Yarn: @netdata/site-build-gate@10.1.0-test.0
    Yarn-->>CI: resolves gate + parser deps (css-tree, parse5, saxes)
Loading

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread package.json Outdated
Comment thread README.md
@witalisoft
witalisoft marked this pull request as ready for review October 13, 2026 13:34
@witalisoft
witalisoft requested a review from a team as a code owner October 13, 2026 13:34
@witalisoft
witalisoft requested review from ktsaou and mtblz October 13, 2026 13:34
@witalisoft
witalisoft merged commit 9bc8fdb into master Oct 15, 2026
14 checks passed
@witalisoft
witalisoft deleted the feat/site-build-gate-as-ext-pkg branch October 15, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants