Skip to content

Harden toolkit-doc generation against destructive failures#1064

Draft
jottakka wants to merge 4 commits into
mainfrom
split/toolkit-docs-fail-closed-generation
Draft

Harden toolkit-doc generation against destructive failures#1064
jottakka wants to merge 4 commits into
mainfrom
split/toolkit-docs-fail-closed-generation

Conversation

@jottakka

@jottakka jottakka commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • reject incomplete, colliding, unsafe, or unwritable generator inputs before publishing
  • preserve the last-known-good generated JSON when a run fails
  • add deterministic verification for output safety and data-source snapshots

Test plan

  • pnpm exec tsc --noEmit --project toolkit-docs-generator/tsconfig.json
  • pnpm exec vitest run --config toolkit-docs-generator/vitest.config.ts

Note

Medium Risk
Changes affect the CI docs generation pipeline and incremental --skip-unchanged behavior; failures now skip overwrites and can fail the job, which is intentional but alters operational outcomes.

Overview
Hardens the toolkit docs generator so incremental runs cannot wipe committed JSON from bad API data or partial merge failures.

Snapshot consistency and mass-delete guard: createCachedToolkitDataSource reuses one fetchAllToolkitsData snapshot for change detection, progress, and merging. --skip-unchanged now documents a single /v1/tool_metadata fetch instead of summary-then-partial fetches. assertSafeCurrentToolkitSnapshot aborts when the current snapshot is empty but previous output had toolkits.

Failures preserve last-known-good output: MergeResult gains an error field; failed merges return the previous toolkit when available and are excluded from writes. The CLI exits non-zero on merge or write failures and only writes successful merges. requireCompleteData fails the run instead of emitting placeholder toolkits.

Safer output I/O: Toolkit IDs are validated (no path escape, reserved index, case-insensitive collisions). JSON is written atomically; index.json entries are sorted. Output directory clearing uses stricter clearSafeOutputDir rules.

Schema/docs: ToolkitSubPageSchema tightens custom sections and merged subPages. README/workflow docs add generator tests in CI and Anthropic as the primary LLM secret.

Reviewed by Cursor Bugbot for commit 7ffca25. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jul 16, 2026 8:34pm

Request Review

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7ffca25. Configure here.

if (this.requireCompleteData) {
throw new Error(`Failed to process ${toolkitId}: ${message}`, {
cause: error,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Overwrite then strict fail wipes output

High Severity

With requireCompleteData enabled, a single toolkit merge failure now throws an error, stopping the entire generation process. This can leave the output directory empty if cleared, or result in stale/incomplete output and an outdated index.json for other toolkits that successfully processed before the failure, particularly in batch or incremental runs.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7ffca25. Configure here.

const errors = validateToolkitFileNames(toolkits);
if (errors.length > 0) {
return { filesWritten, errors };
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incremental writes skip collision checks

Medium Severity

Case-insensitive toolkit ID collision detection runs only in generateAll via validateToolkitFileNames. Incremental mode publishes through onToolkitCompletegenerateToolkitFile, which never runs that batch check, so colliding IDs can still overwrite the same JSON file before publishing is rejected.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7ffca25. Configure here.

@jottakka
jottakka marked this pull request as draft July 16, 2026 18:22
Reject incomplete or unsafe inputs before they can erase generated artifacts, while retaining actionable verification evidence for the workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jottakka
jottakka force-pushed the split/toolkit-docs-fail-closed-generation branch from 7ffca25 to eb2fb74 Compare July 16, 2026 20:18
jottakka and others added 2 commits July 16, 2026 17:24
Keep last-known-good merge fallbacks in generated output when an individual toolkit merge fails.

Co-authored-by: Cursor <cursoragent@cursor.com>
Write last-known-good merge fallbacks during generate-all as well as provider batch generation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Prevent check-changes from reporting a transient empty toolkit API response as every toolkit being removed.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant