Skip to content

feat(scanner): add Trustabl Forge pre-coding skill - #1972

Open
ericksondelacruz wants to merge 4 commits into
openlit:mainfrom
ericksondelacruz:feat/trustabl-forge
Open

ericksondelacruz wants to merge 4 commits into
openlit:mainfrom
ericksondelacruz:feat/trustabl-forge

Conversation

@ericksondelacruz

Copy link
Copy Markdown

Issue number:

Change description:

Adds Trustabl Forge to the Trustabl scanner connector. Forge turns the detection rules for a repository's SDKs into a pre-coding SKILL.md. Coding agents read it before writing agent code, so they avoid the issues the Analyzer would flag.

  • Runs and API: POST /api/scanners/{id}/forge runs trustabl forge with policies taken from the latest succeeded Analyzer scan of the repository. The repository is not cloned. GET /api/scanners/{id}/forge/{runId} returns a run with its skill. GET /api/scanners/{id}/forge/{runId}/check runs trustabl forge check and reports whether the skill is current or stale. Runs are project-scoped and kept in connector metadata (last 10). Forge policies and flags are read from the installed CLI, and abandoned running entries are reported as failed.

  • UI: Run scan becomes Run Analyzer, with a menu that groups Analyzer and Forge actions. Connectors that support Forge get Analyzer findings and Forge skill tabs. The Forge skill tab covers:

    • empty and running states, with Cancel
    • preview and raw views, with an outline
    • Copy, Download and Regenerate
    • run history and a stale banner

    Run Forge with new parameters prefills policies from the latest scan.

  • Tests: Unit and component tests. A Playwright suite (e2e/scanner-forge.spec.ts) drives Run Analyzer, Run Forge, copy, parameters and stale regenerate against a fake trustabl CLI that replays recorded 0.1.8 output. The dev server uses its own SQLite file and build directory (OPENLIT_NEXT_DIST_DIR).

  • Docs: Forge section on the Scanner connectors page, plus API reference pages and OpenAPI entries for the Forge endpoints.

Checks on the branch rebased onto current main, from src/client:

  • npm run lint: no warnings or errors
  • npx tsc --noEmit: 0 errors
  • npx jest: 435/435 suites, 6205/6205 tests

Checklist

If your change doesn't seem to apply, please leave them unchecked.

  • PR title follows Conventional Commit format.
  • I have reviewed the contributing guidelines
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

Erick dela Cruz added 4 commits November 20, 2026 15:22
Generate a pre-coding SKILL.md with `trustabl forge` from policies taken
from the latest Analyzer scan of a repository, without cloning it. Runs
are project-scoped, stored in connector metadata (last 10), and checked
for staleness with `trustabl forge check`.

- POST /api/scanners/{id}/forge, GET .../forge/{runId}, GET .../check
- Forge policies and flags discovered from the installed CLI
- Abandoned running entries are reported as failed
Rename Run scan to Run Analyzer and group the run menu into Analyzer and
Forge actions. Connectors that support forge get Analyzer findings and
Forge skill tabs: empty, running (with Cancel), preview and raw skill
views, outline, Copy, Download, Regenerate, run history and a stale
banner. Run Forge with new parameters prefills policy chips from the
latest scan.
Drive Run Analyzer, Run Forge, copy, parameters and stale regenerate
against a hermetic fake trustabl CLI with recorded 0.1.8 output. The
dev server uses its own SQLite file, build directory (OPENLIT_NEXT_DIST_DIR)
and a crontab shim so it never touches a developer's setup.
@mintlify

mintlify Bot commented Nov 20, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 268cbd6.

Approve preview

@sourcery-ai

sourcery-ai Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Sorry @ericksondelacruz, your pull request is larger than the review limit of 150,000 diff characters

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Add Trustabl Forge pre-coding skills to scanner connectors

✨ Enhancement 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Generate pre-coding SKILL.md files from Analyzer-derived or manually selected policies without
 cloning repositories.
• Add project-scoped Forge APIs, run history, freshness checks, and a skill review interface.
• Document the workflow and cover it with unit, integration, component, and isolated Playwright
 tests.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The API, CLI adapter, persisted run, and UI are one bounded Scanner/Forge behavior: generating and presenting a pre-coding skill for a selected repository.
  • The propagation path crosses implementation layers but does not create independent capabilities or scopes.
  • Run coordination and history are part of the same bounded Forge integration outcome.
  • Metadata is an implementation boundary for that behavior, not an independent functional scope.
Sources

src/client/src/lib/platform/connectors/scanner/forge-runs.ts[48-74]

export async function prependScannerForgeRun(
	instanceId: string,
	run: ScannerForgeRun
): Promise<ScannerForgeRun[]> {
	const existing = await prisma.connectorInstance.findFirst({
		where: { id: instanceId },
		select: { metadata: true },
	});
	if (!existing) return [];
	const metadata = parseJsonObject(existing.metadata || "{}");
	const current = forgeRunsFromMetadata(existing.metadata || "{}");
	const withoutStale = current.filter((item) => {
		if (item.id === run.id) return false;
		if (run.status !== "running" && item.status === "running") return false;
		return true;
	});
	const next = [run, ...withoutStale].slice(0, MAX_FORGE_RUNS);
	await prisma.connectorInstance.update({
		where: { id: instanceId },
		data: {
			metadata: JSON.stringify({
				...metadata,
				category: "scanner",
				forgeRuns: next,
			}),
		},
	});
Behavioral complexity 🔴 High 🧩 Concurrent ordering, Coordinated invariants

  • Before: scanner jobs had their own active-run and metadata flow.
  • After: Forge introduces a second active-run protocol with running, completion, stale-entry cleanup, history capping, and UI polling over shared connector metadata.
  • New correctness condition: concurrent requests and completion updates must preserve the single-running-run invariant and retain all non-conflicting history entries.
  • The changed read-filter-write sequence does not establish that ordering guarantee.
Sources

src/client/src/lib/platform/connectors/scanner/forge-runs.ts[48-74]

export async function prependScannerForgeRun(
	instanceId: string,
	run: ScannerForgeRun
): Promise<ScannerForgeRun[]> {
	const existing = await prisma.connectorInstance.findFirst({
		where: { id: instanceId },
		select: { metadata: true },
	});
	if (!existing) return [];
	const metadata = parseJsonObject(existing.metadata || "{}");
	const current = forgeRunsFromMetadata(existing.metadata || "{}");
	const withoutStale = current.filter((item) => {
		if (item.id === run.id) return false;
		if (run.status !== "running" && item.status === "running") return false;
		return true;
	});
	const next = [run, ...withoutStale].slice(0, MAX_FORGE_RUNS);
	await prisma.connectorInstance.update({
		where: { id: instanceId },
		data: {
			metadata: JSON.stringify({
				...metadata,
				category: "scanner",
				forgeRuns: next,
			}),
		},
	});
Potential damage 🟡 Medium 🩹 Incorrect results

  • The generated SKILL.md can be semantically incomplete even when it is syntactically valid and successfully stored.
  • Reverting code stops new generation but does not remove an already downloaded/copied skill; recovery requires regenerating after selecting or discovering the correct policies and, for an already distributed skill, replacing it in the consuming repository.
  • Recoverable by rerunning Forge with corrected policies or a compatible rules/CLI version.
  • Existing externally copied skills require consumer-side replacement; code rollback alone does not repair them.
Assessed commit 268cbd6
Diagram

graph TD
  A["Analyzer scan"] --> B["Policy selection"] --> C["Forge API"] --> D["Trustabl CLI"] --> E[("Run metadata")]
  E --> F["Skill panel"] --> G["Freshness check"]
  G --> D
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Dedicated Forge run table
  • ➕ Supports atomic run creation and concurrency control.
  • ➕ Separates potentially large skill bodies from connector metadata.
  • ➖ Requires a schema migration and additional persistence code.
  • ➖ Adds operational complexity for a history capped at ten runs.

Recommendation: Connector metadata is a reasonable choice for bounded history and avoids a migration. Before relying on the one-run-at-a-time guarantee under concurrent requests, consider an atomic reservation or dedicated table: the current read-then-write check is not atomic.

Files changed (62) +7162 / -69

Enhancement (21) +2408 / -51
route.tsAdd Forge freshness-check endpoint +25/-0

Add Forge freshness-check endpoint

• Checks a stored skill through the scanner access wrapper and returns its current, stale, or error result.

src/client/src/app/api/scanners/[id]/forge/[runId]/check/route.ts

route.tsAdd Forge run detail endpoint +23/-0

Add Forge run detail endpoint

• Returns an authorized run, including its generated skill, after validating the run ID.

src/client/src/app/api/scanners/[id]/forge/[runId]/route.ts

route.tsAdd Forge generation endpoint +40/-0

Add Forge generation endpoint

• Parses and validates a request, then runs Forge using scanner access and audit wrappers.

src/client/src/app/api/scanners/[id]/forge/route.ts

scanner-forge-panel.tsxAdd Forge run and skill panel +330/-0

Add Forge run and skill panel

• Loads run details and checks, and renders empty, running, failure, and completed states.

src/client/src/components/(playground)/scanner/scanner-forge-panel.tsx

scanner-forge-params-dialog.tsxAdd Forge parameters dialog +265/-0

Add Forge parameters dialog

• Lets users select policies, target, filename, rules ref, and supported CLI flags, with Analyzer-derived defaults.

src/client/src/components/(playground)/scanner/scanner-forge-params-dialog.tsx

scanner-forge-skill-view.tsxAdd skill preview and run actions +359/-0

Add skill preview and run actions

• Displays skill statistics, outline, preview and raw content, history, copy, download, and stale regeneration.

src/client/src/components/(playground)/scanner/scanner-forge-skill-view.tsx

scanner-page.tsxIntegrate Forge into the scanner page +325/-30

Integrate Forge into the scanner page

• Adds capability-gated tabs and grouped run actions, tracks Forge requests, and preserves repository selection during refreshes.

src/client/src/components/(playground)/scanner/scanner-page.tsx

en.tsAdd Forge interface and error messages +108/-6

Add Forge interface and error messages

• Renames scan actions to Analyzer and supplies Forge status, validation, dialog, and skill-view text.

src/client/src/constants/messages/en.ts

base-adapter.tsProvide default unsupported Forge methods +11/-0

Provide default unsupported Forge methods

• Adds base adapter methods for generation and freshness checks that reject unsupported use.

src/client/src/lib/platform/connectors/scanner/base-adapter.ts

cli-schema.tsParse Forge capabilities from CLI output +38/-0

Parse Forge capabilities from CLI output

• Defines a Forge schema, filters unsafe or application-owned flags, and parses accepted policy IDs.

src/client/src/lib/platform/connectors/scanner/cli-schema.ts

config-fields.tsBuild Forge fields from the CLI schema +33/-1

Build Forge fields from the CLI schema

• Creates dynamic parameter fields with a rules-ref fallback when no Forge schema is available.

src/client/src/lib/platform/connectors/scanner/config-fields.ts

crud.tsExpose Forge summaries on scanner connectors +17/-5

Expose Forge summaries on scanner connectors

• Returns capability information and content-free Forge history while keeping run data out of public metadata.

src/client/src/lib/platform/connectors/scanner/crud.ts

forge-crud.tsCoordinate project-scoped Forge runs +111/-0

Coordinate project-scoped Forge runs

• Resolves policies, records running and completed entries, and retrieves or checks stored runs.

src/client/src/lib/platform/connectors/scanner/forge-crud.ts

forge-params.tsValidate Forge requests and construct commands +137/-0

Validate Forge requests and construct commands

• Normalizes policies and filenames, limits extra flags, and builds CLI arguments without output paths.

src/client/src/lib/platform/connectors/scanner/forge-params.ts

forge-policies.tsDerive Forge policies from Analyzer results +63/-0

Derive Forge policies from Analyzer results

• Maps detected SDKs and findings to accepted policies from the latest successful scan of the same repository.

src/client/src/lib/platform/connectors/scanner/forge-policies.ts

forge-runs.tsStore bounded Forge history in metadata +76/-0

Store bounded Forge history in metadata

• Keeps ten runs, excludes content from summaries, and reports abandoned running entries as failed.

src/client/src/lib/platform/connectors/scanner/forge-runs.ts

forge-skill.tsSummarize generated skills and checks +136/-0

Summarize generated skills and checks

• Extracts front matter, provenance, outline, and severity counts, and interprets Forge check exit codes.

src/client/src/lib/platform/connectors/scanner/forge-skill.ts

job-repos.tsInclude Forge-only repository targets +6/-1

Include Forge-only repository targets

• Extends repository grouping so generated skills remain selectable without a scan job.

src/client/src/lib/platform/connectors/scanner/job-repos.ts

runtime.tsDiscover installed Forge policies and flags +69/-7

Discover installed Forge policies and flags

• Probes Forge help and accepted policies, caches its schema, and isolates policy discovery in a temporary directory.

src/client/src/lib/platform/connectors/scanner/runtime.ts

adapter.tsImplement Trustabl Forge and check execution +147/-0

Implement Trustabl Forge and check execution

• Runs generation without cloning in an empty temporary directory, validates CLI output, and checks stored skills against rules.

src/client/src/lib/platform/connectors/scanner/trustabl/adapter.ts

types.tsDefine Forge capabilities and run contracts +89/-1

Define Forge capabilities and run contracts

• Adds adapter methods and types for parameters, policy provenance, run status, skill summaries, and freshness checks.

src/client/src/lib/platform/connectors/scanner/types.ts

Refactor (2) +5 / -5
scanner-run-params-dialog.tsxShare parameter form controls +3/-3

Share parameter form controls

• Exports existing section and field components for reuse in the Forge dialog.

src/client/src/components/(playground)/scanner/scanner-run-params-dialog.tsx

scanner-workspace.tsxShare workspace statistics components +2/-2

Share workspace statistics components

• Exports duration formatting and statistic display for the skill view.

src/client/src/components/(playground)/scanner/scanner-workspace.tsx

Tests (26) +4215 / -0
crontabIsolate crontab writes in E2E tests +9/-0

Isolate crontab writes in E2E tests

• Provides a shim that redirects crontab reads and writes to the test state directory.

src/client/e2e/fixtures/bin/crontab

trustablFake Trustabl CLI for browser tests +41/-0

Fake Trustabl CLI for browser tests

• Replays recorded CLI responses and supports delayed generation and controllable stale checks.

src/client/e2e/fixtures/bin/trustabl

forge-help.txtRecord Forge help output for E2E tests +48/-0

Record Forge help output for E2E tests

• Supplies CLI flag and command help to the fake Trustabl binary.

src/client/e2e/fixtures/cli/forge-help.txt

forge-no-policy.txtRecord accepted Forge policies +3/-0

Record accepted Forge policies

• Supplies the CLI error used to discover supported policy categories.

src/client/e2e/fixtures/cli/forge-no-policy.txt

forge-skill.mdProvide generated skill for browser tests +861/-0

Provide generated skill for browser tests

• Records a representative SKILL.md containing provenance and Claude SDK and MCP rules.

src/client/e2e/fixtures/cli/forge-skill.md

scan-help.txtRecord scan help for browser tests +80/-0

Record scan help for browser tests

• Provides scan flag discovery output to the fake CLI.

src/client/e2e/fixtures/cli/scan-help.txt

scan-report.jsonProvide Analyzer report for browser tests +36/-0

Provide Analyzer report for browser tests

• Supplies SDK, MCP, and finding data used to exercise policy prefill.

src/client/e2e/fixtures/cli/scan-report.json

version.txtRecord Trustabl version for browser tests +3/-0

Record Trustabl version for browser tests

• Provides recorded version output for CLI runtime probing.

src/client/e2e/fixtures/cli/version.txt

prepare.jsPrepare isolated E2E database +17/-0

Prepare isolated E2E database

• Resets test state, deploys Prisma migrations, and seeds the dedicated SQLite database.

src/client/e2e/prepare.js

scanner-forge.spec.tsExercise Forge through the browser +126/-0

Exercise Forge through the browser

• Covers Analyzer policy prefill, Forge generation, skill review and copy, parameters, stale detection, and regeneration.

src/client/e2e/scanner-forge.spec.ts

playwright.config.tsConfigure isolated scanner E2E server +52/-0

Configure isolated scanner E2E server

• Starts a single-worker Chromium suite against a dedicated SQLite database, build directory, fake CLI, and crontab shim.

src/client/playwright.config.ts

forge-route.test.tsTest Forge route validation and responses +151/-0

Test Forge route validation and responses

• Checks authentication, malformed input, run ID validation, and run and check responses.

src/client/src/tests/app/api/scanners/forge-route.test.ts

forge.integration.test.tsTest Forge across API and connector layers +220/-0

Test Forge across API and connector layers

• Exercises generation through retrieval and stale checks, including concurrency rejection and project isolation.

src/client/src/tests/app/api/scanners/forge.integration.test.ts

scanner-forge-panel.test.tsxTest skill panel states and actions +207/-0

Test skill panel states and actions

• Covers empty, running, failed, current, and stale states, plus content loading and clipboard behavior.

src/client/src/tests/components/scanner-forge-panel.test.tsx

scanner-forge-params-dialog.test.tsxTest Forge parameter selection +129/-0

Test Forge parameter selection

• Verifies prefilled and manual policies, dynamic flags, reset behavior, and required inputs.

src/client/src/tests/components/scanner-forge-params-dialog.test.tsx

scanner-page-forge.test.tsxTest scanner-page Forge integration +276/-0

Test scanner-page Forge integration

• Checks capability-gated tabs, run submission and cancellation, polling, parameter entry, and repository selection.

src/client/src/tests/components/scanner-page-forge.test.tsx

forge-help.txtProvide Forge help fixture for unit tests +48/-0

Provide Forge help fixture for unit tests

• Records Trustabl help text for schema and runtime tests.

src/client/src/tests/fixtures/trustabl/forge-help.txt

forge-skill.mdProvide skill fixture for unit tests +861/-0

Provide skill fixture for unit tests

• Supplies a representative generated skill for parsing, adapter, and component tests.

src/client/src/tests/fixtures/trustabl/forge-skill.md

scanner-forge-adapter.test.tsTest Trustabl Forge execution +221/-0

Test Trustabl Forge execution

• Verifies isolated execution, CLI arguments, output limits, failures, and temporary-file freshness checks.

src/client/src/tests/lib/platform/connectors/scanner-forge-adapter.test.ts

scanner-forge-crud.test.tsTest Forge persistence and access +298/-0

Test Forge persistence and access

• Covers policy defaults, metadata storage, run reads, concurrent-run rejection, and project scoping.

src/client/src/tests/lib/platform/connectors/scanner-forge-crud.test.ts

scanner-forge-params.test.tsTest Forge input and CLI arguments +162/-0

Test Forge input and CLI arguments

• Checks policy and filename validation, request shaping, blocked flags, and help-derived CLI schemas.

src/client/src/tests/lib/platform/connectors/scanner-forge-params.test.ts

scanner-forge-policies.test.tsTest policy derivation from Analyzer jobs +74/-0

Test policy derivation from Analyzer jobs

• Verifies SDK aliases, MCP and skill detection, supported-policy filtering, and repository matching.

src/client/src/tests/lib/platform/connectors/scanner-forge-policies.test.ts

scanner-forge-runs.test.tsTest bounded Forge run history +118/-0

Test bounded Forge run history

• Checks summary redaction, abandoned-run reporting, run IDs, and the ten-run metadata limit.

src/client/src/tests/lib/platform/connectors/scanner-forge-runs.test.ts

scanner-forge-runtime.test.tsTest Forge CLI discovery +77/-0

Test Forge CLI discovery

• Verifies help and policy probing in temporary directories and handling of CLIs without Forge.

src/client/src/tests/lib/platform/connectors/scanner-forge-runtime.test.ts

scanner-forge-skill.test.tsTest skill and freshness parsing +90/-0

Test skill and freshness parsing

• Checks provenance, headings, rule and severity counts, preview cleanup, and check exit codes.

src/client/src/tests/lib/platform/connectors/scanner-forge-skill.test.ts

scanner-job-repos.test.tsTest repositories with only Forge runs +7/-0

Test repositories with only Forge runs

• Confirms repository grouping includes targets without Analyzer jobs.

src/client/src/tests/lib/platform/connectors/scanner-job-repos.test.ts

Documentation (9) +526 / -11
docs.jsonAdd Forge API pages to navigation +4/-1

Add Forge API pages to navigation

• Lists the run, detail, and check reference pages under scanner endpoints.

docs/docs.json

overview.mdxInclude Forge in connector capabilities +1/-1

Include Forge in connector capabilities

• Updates the scanner capability overview to mention Analyzer and Forge.

docs/latest/openlit/connectors/overview.mdx

scanner.mdxDocument the Forge skill workflow +37/-8

Document the Forge skill workflow

• Explains policy prefill, manual selection, skill use, freshness checks, history, and the no-clone behavior. Renames the scan UI action to Run Analyzer.

docs/latest/openlit/connectors/scanner.mdx

forge-check.mdxDocument the Forge check endpoint +6/-0

Document the Forge check endpoint

• Describes current, stale, and error results for checking a stored skill.

docs/latest/openlit/developer-resources/api-reference/endpoint/scanners/forge-check.mdx

forge-run.mdxDocument Forge run retrieval +6/-0

Document Forge run retrieval

• Identifies the endpoint that returns a run with its generated skill content.

docs/latest/openlit/developer-resources/api-reference/endpoint/scanners/forge-run.mdx

forge.mdxDocument Forge generation +10/-0

Document Forge generation

• Describes policy fallback, no-clone execution, and how to retrieve generated content.

docs/latest/openlit/developer-resources/api-reference/endpoint/scanners/forge.mdx

list.mdxDescribe Forge runs in scanner listings +1/-1

Describe Forge runs in scanner listings

• Clarifies that connector listings include Forge run summaries without skill content.

docs/latest/openlit/developer-resources/api-reference/endpoint/scanners/list.mdx

scanners.ymlSpecify Forge endpoints in documentation schema +211/-0

Specify Forge endpoints in documentation schema

• Adds run, detail, and check operations with request, response, and run schemas.

docs/latest/openlit/developer-resources/api-reference/endpoint/scanners/scanners.yml

openapi.yamlPublish Forge API contracts +250/-0

Publish Forge API contracts

• Adds the three Forge operations and schemas for requests, run summaries, skill content, and check results.

src/client/public/openapi.yaml

Other (4) +8 / -2
jest.config.jsExclude browser tests from Jest +1/-0

Exclude browser tests from Jest

• Prevents the Playwright E2E directory from being collected as Jest tests.

src/client/jest.config.js

next.config.jsAllow an isolated Next.js build directory +3/-0

Allow an isolated Next.js build directory

• Reads OPENLIT_NEXT_DIST_DIR so the E2E dev server does not share the normal build directory.

src/client/next.config.js

package.jsonAdd Playwright test command and dependency +3/-1

Add Playwright test command and dependency

• Introduces a test:e2e script and the Playwright test runner.

src/client/package.json

tsconfig.jsonInclude E2E-generated Next.js types +1/-1

Include E2E-generated Next.js types

• Adds the isolated Next.js build directory to TypeScript's included generated types.

src/client/tsconfig.json

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (10) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Forge skills leak across environments 🐞 Bug ⛨ Security
Description
getScannerForgeRun loads a connector by project and ID without checking the request environment,
then returns the stored run including content. A caller in another environment of the same project
who supplies that connector ID and run ID can read its skill, whereas Forge execution and connector
listing enforce the environment.
Code

src/client/src/lib/platform/connectors/scanner/forge-crud.ts[R99-100]

+	const row = await getScannerConnector(id);
+	const run = forgeRunsFromMetadata(row.metadata || "{}").find((item) => item.id === runId);
Evidence
The new endpoint returns the full run from a lookup that lacks an environment predicate; the runtime
lookup used by POST does have one.

src/client/src/app/api/scanners/[id]/forge/[runId]/route.ts[13-20]
src/client/src/lib/platform/connectors/scanner/forge-crud.ts[97-103]
src/client/src/lib/platform/connectors/scanner/crud.ts[470-514]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The single-run endpoint can return skill content from another environment in the same project.
## Fix Focus Areas
- src/client/src/lib/platform/connectors/scanner/forge-crud.ts[97-102]
- src/client/src/lib/platform/connectors/scanner/crud.ts[470-514]
## Recommended Fix
Resolve the request environment and require it in the connector lookup before reading run metadata; cover same-project cross-environment requests in a test.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Concurrent scans can erase Forge runs 🐞 Bug ☼ Reliability
Description
prependScannerForgeRun reads and rewrites the entire connector metadata document rather than
updating Forge history atomically. If an Analyzer job and a Forge run write from overlapping
snapshots, the later update can erase the other's newly recorded job or run.
Code

src/client/src/lib/platform/connectors/scanner/forge-runs.ts[R65-72]

+	await prisma.connectorInstance.update({
+		where: { id: instanceId },
+		data: {
+			metadata: JSON.stringify({
+				...metadata,
+				category: "scanner",
+				forgeRuns: next,
+			}),
Evidence
Both persistence paths reconstruct the full JSON value from a separately read snapshot and perform
unconditional writes to the same column.

src/client/src/lib/platform/connectors/scanner/forge-runs.ts[52-74]
src/client/src/lib/platform/connectors/scanner/jobs.ts[26-65]
src/client/src/lib/platform/connectors/scanner/forge-crud.ts[71-83]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Analyzer jobs and Forge runs share a JSON metadata column, and overlapping read-modify-write operations can lose either history entry.
## Fix Focus Areas
- src/client/src/lib/platform/connectors/scanner/forge-runs.ts[52-74]
- src/client/src/lib/platform/connectors/scanner/jobs.ts[26-65]
## Recommended Fix
Coordinate both writers with a transaction and conditional update or another serialization mechanism, retrying when the metadata version changes. Test overlapping Analyzer and Forge persistence.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Run Analyzer API docs page disappears 🐞 Bug ≡ Correctness
Description
The PR removes all content from endpoint/scanners/scan.mdx, including its front matter and
endpoint description, while docs.json, the updated list.mdx, and
api-reference/introduction.mdx still reference it. When the docs build or a reader follows those
references, they reach an empty or missing page instead of the reference for `POST
/api/scanners/{id}/scan`.
Code

docs/latest/openlit/developer-resources/api-reference/endpoint/scanners/scan.mdx[L1-4]

----
-title: 'Run scan'
-openapi: 'POST /api/scanners/{id}/scan'
----
Evidence
The scan page is empty on the PR branch, but the navigation still names it. The list page edited in
this PR and the API introduction also link to it, so all three references point to a page with no
endpoint documentation.

docs/docs.json[335-342]
docs/latest/openlit/developer-resources/api-reference/endpoint/scanners/list.mdx[6-6]
docs/latest/openlit/developer-resources/api-reference/introduction.mdx[30-36]
docs/docs.json[335-341]
docs/latest/openlit/developer-resources/api-reference/endpoint/scanners/scan.mdx[1-1]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR removes the Analyzer scan endpoint page while the navigation, scanner list page, and API introduction still reference it.

## Fix Focus Areas
- docs/latest/openlit/developer-resources/api-reference/endpoint/scanners/scan.mdx[1-10]
- docs/docs.json[335-341]
- docs/latest/openlit/developer-resources/api-reference/endpoint/scanners/list.mdx[6-6]
- docs/latest/openlit/developer-resources/api-reference/introduction.mdx[33-33]

## Recommended Fix
Restore `scan.mdx` with its front matter and endpoint description, retitle it `Run Analyzer scan`, and set `openapi: 'POST /api/scanners/{id}/scan'`. Keep the existing references pointing to the restored page.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

4. Parallel Forge runs can evade the guard 🐞 Bug ☼ Reliability
Description
runScannerForge checks a previously loaded metadata snapshot before separately inserting its
running entry, so two requests can both pass the single-run guard. When either finishes,
prependScannerForgeRun also removes every other running entry, hiding the still-active request
from history and subsequent guard checks.
Code

src/client/src/lib/platform/connectors/scanner/forge-crud.ts[R48-50]

+	const { adapter, connector, row } = await getScannerRuntime(id);
+	if (!adapter.forge) throw new Error(SCANNER_FORGE_UNSUPPORTED);
+	if (hasRunningForgeRun(row.metadata || "{}")) throw new Error(SCANNER_FORGE_RUNNING);
Evidence
The guard and insert are separate operations, and the completion filter discards all other running
records.

src/client/src/lib/platform/connectors/scanner/forge-crud.ts[47-50]
src/client/src/lib/platform/connectors/scanner/forge-crud.ts[71-92]
src/client/src/lib/platform/connectors/scanner/forge-runs.ts[52-74]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Concurrent requests can both start Forge, and completing one run can delete the other's running entry.
## Fix Focus Areas
- src/client/src/lib/platform/connectors/scanner/forge-crud.ts[47-79]
- src/client/src/lib/platform/connectors/scanner/forge-runs.ts[59-74]
## Recommended Fix
Make the no-active-run check and insertion one serialized operation, and remove only the completing run's prior entry rather than unrelated running entries. Test two simultaneous starts and out-of-order completions.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Forge runs can claim the wrong scan 🐞 Bug ≡ Correctness
Description
runScannerForge accepts an explicit sourceJobId as Analyzer provenance when that ID merely
exists in the connector's jobs. A request targeting another repository, or naming a failed job,
records that job as the source even though its scan did not establish the selected policies for this
target.
Code

src/client/src/lib/platform/connectors/scanner/forge-crud.ts[R58-61]

+		const source = input.sourceJobId
+			? jobs.find((job) => job.id === input.sourceJobId)
+			: undefined;
+		if (source) policySource = { kind: "analyzer", jobId: source.id, scannedAt: source.startedAt };
Evidence
The explicit-source lookup checks only the ID, unlike the automatic lookup's succeeded-status and
repository checks.

src/client/src/lib/platform/connectors/scanner/forge-crud.ts[53-76]
src/client/src/lib/platform/connectors/scanner/forge-policies.ts[53-62]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Caller-supplied source job IDs can attribute Forge policies to a failed scan or a different repository.
## Fix Focus Areas
- src/client/src/lib/platform/connectors/scanner/forge-crud.ts[53-67]
- src/client/src/lib/platform/connectors/scanner/forge-policies.ts[53-62]
## Recommended Fix
Accept a source job as Analyzer provenance only when it succeeded and its normalized repository matches the Forge target; otherwise reject the claim or record manual provenance.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Finishing Forge changes the chosen connector 🐞 Bug ≡ Correctness
Description
runForge calls the load function captured when the request started, and that function restores
its captured connector ID. If a user switches connectors while Forge is running, completion reloads
the original connector and replaces the user's current selection.
Code

src/client/src/components/(playground)/scanner/scanner-page.tsx[R482-484]

+			if (forgeAbortRef.current === controller) forgeAbortRef.current = null;
+			setForging(undefined);
+			await load({ quiet: true });
Evidence
The selector remains available during forging, while the captured reload writes its resolved
connector ID back into page state.

src/client/src/components/(playground)/scanner/scanner-page.tsx[332-359]
src/client/src/components/(playground)/scanner/scanner-page.tsx[452-485]
src/client/src/components/(playground)/scanner/scanner-page.tsx[605-630]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An in-flight Forge request can switch the page back after the user selects another connector.
## Fix Focus Areas
- src/client/src/components/(playground)/scanner/scanner-page.tsx[319-359]
- src/client/src/components/(playground)/scanner/scanner-page.tsx[412-485]
## Recommended Fix
Refresh connector data on completion without applying the initiating request's captured selection, or ignore its selection updates when the current connector has changed.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View review recommended (3)
7. Failed regeneration leaves an old skill open 🐞 Bug ≡ Correctness
Description
runForge retains forgeRunId when POST fails, because it updates the selection only for a
response containing a run. After a failed regeneration is persisted and the list reloads,
selectedForgeRun still prefers the previous successful ID, so the panel shows that older skill
rather than the new failure.
Code

src/client/src/components/(playground)/scanner/scanner-page.tsx[R462-464]

+			const run = body?.run as ScannerForgeRun | undefined;
+			if (run?.id) {
+				setForgeRunId(run.id);
Evidence
The server stores the failure before returning an error; the client does not change its preferred ID
on that error.

src/client/src/components/(playground)/scanner/scanner-page.tsx[283-285]
src/client/src/components/(playground)/scanner/scanner-page.tsx[458-485]
src/client/src/lib/platform/connectors/scanner/forge-crud.ts[85-94]
src/client/src/components/(playground)/scanner/scanner-forge-panel.tsx[293-326]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A failed regeneration is recorded in history but the panel returns to the previously selected successful skill.
## Fix Focus Areas
- src/client/src/components/(playground)/scanner/scanner-page.tsx[283-285]
- src/client/src/components/(playground)/scanner/scanner-page.tsx[458-485]
## Recommended Fix
On failure, clear the pinned run ID before reloading or return and select the persisted failed run. Ensure the panel displays the failure while retaining access to older history.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. Parallel test runs delete each other's data 🐞 Bug ☼ Reliability
Description
playwright.config.ts gives every invocation the same temporary state directory, which prepare.js
recursively deletes before starting its server. Two suites started on different ports can therefore
remove or replace the SQLite database used by the other live suite.
Code

src/client/playwright.config.ts[R5-7]

+const PORT = Number(process.env.E2E_PORT || 3011);
+const BASE_URL = `http://localhost:${PORT}`;
+const STATE_DIR = join(tmpdir(), "openlit-e2e");
Evidence
The state path is constant across invocations and preparation deletes it; the server's SQLite URL
points inside it.

src/client/playwright.config.ts[5-20]
src/client/e2e/prepare.js[9-17]
src/client/prisma/schema.prisma[6-9]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Concurrent Playwright invocations share a directory that each invocation deletes during preparation.
## Fix Focus Areas
- src/client/playwright.config.ts[5-16]
- src/client/e2e/prepare.js[9-17]
## Recommended Fix
Use an invocation-specific state directory for the database and runtime cache, and pass that same directory to preparation and the dev server.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


9. Scanner list re-reads megabytes of skills 🐞 Bug ➹ Performance
Description
forgeRuns stores the full SKILL.md content (up to 512 KB each, 10 runs) inside
connector_instances.metadata. sanitize parses the whole blob three times per connector
(publicConnectorMetadata, jobsFromMetadata, forgeRunsFromMetadata), only to strip the content
out. Every scanner list request, every 3-second forge poll, and every prependScannerJob or
prependScannerForgeRun read-modify-write then handles up to ~5 MB of JSON per connector.
Code

src/client/src/lib/platform/connectors/scanner/forge-runs.ts[R64-72]

+	const next = [run, ...withoutStale].slice(0, MAX_FORGE_RUNS);
+	await prisma.connectorInstance.update({
+		where: { id: instanceId },
+		data: {
+			metadata: JSON.stringify({
+				...metadata,
+				category: "scanner",
+				forgeRuns: next,
+			}),
Evidence
Runs, including content, are stored in metadata, capped at 10. The list path parses all metadata and
drops the content. The page polls load every 3 seconds while a run is pending.

src/client/src/lib/platform/connectors/scanner/forge-runs.ts[48-76]
src/client/src/lib/platform/connectors/scanner/crud.ts[109-160]
src/client/src/lib/platform/connectors/scanner/trustabl/adapter.ts[285-294]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Forge skill bodies (up to 512 KB × 10) live in connector metadata. Every list, poll and job write parses and rewrites them.

## Fix Focus Areas
- src/client/src/lib/platform/connectors/scanner/forge-runs.ts[48-76]
- src/client/src/lib/platform/connectors/scanner/crud.ts[109-160]

## Recommended Fix
Store content separately: a dedicated table or row keyed by run id, or keep content only for the latest run per repository. Keep the summaries in metadata.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

10. Forge dialog edits reset during refresh 🐞 Bug ≡ Correctness
Description
forgeDefaults depends on forgePrefill?.policies, which forgePoliciesFromJob rebuilds as a new
array whenever jobs changes. The dialog's useEffect then calls setValues(seededValues) and
setPolicies(defaults.policies). While a server-side forge run is still running (after Cancel, or
started from another session), the page reloads every 3 seconds, and each reload wipes any policy or
field edits the user made in the open dialog.
Code

src/client/src/components/(playground)/scanner/scanner-forge-params-dialog.tsx[R80-84]

+	useEffect(() => {
+		if (!open) return;
+		setValues(seededValues);
+		setPolicies(defaults.policies);
+	}, [defaults.policies, open, seededValues]);
Evidence
Polling calls load({quiet:true}), which replaces the connectors and jobs. That produces new
forgePrefill and forgeDefaults objects, and the dialog effect reseeds its state whenever these
identities change while it is open.

src/client/src/components/(playground)/scanner/scanner-page.tsx[288-303]
src/client/src/components/(playground)/scanner/scanner-page.tsx[371-376]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The forge params dialog resets user edits whenever the page's defaults object identity changes, which happens on every background reload.

## Fix Focus Areas
- src/client/src/components/(playground)/scanner/scanner-forge-params-dialog.tsx[80-84]

## Recommended Fix
Reseed only when `open` changes from false to true: track the previous `open` value with a ref and drop `seededValues` and `defaults.policies` from the reset trigger.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: Auto: 🧠 Deep: Broad feature spans API, runtime, persistence, UI, CLI integration, and documentation.

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

This branch was previously deployed

1 inactive deployment
release-notes — 268cbd68 Deployed Nov 20, 2026 by ericksondelacruz via Normalize / Conventional title #868
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant