ai-saas-guard 0.33.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,7 +31,7 @@
31
31
 
32
32
  AI-built SaaS can look ready before it is ready: login works, checkout opens, the dashboard loads, and tests are green. The launch risk is usually hidden in trust-boundary code that decides who gets access, who pays, what data they can see, and whether failures are visible.
33
33
 
34
- Start with the 30-second copy-paste demo: `npx ai-saas-guard@latest demo --summary`. No signup, no code upload, no LLM call. See [docs/demo-terminal-output.txt](docs/demo-terminal-output.txt) and [compare with alternatives](docs/launch-gate-positioning.md).
34
+ Start with the 30-second copy-paste demo: `npx ai-saas-guard@latest demo --summary`. No signup, no code upload, no LLM call. See the [terminal screenshot](docs/demo-terminal-screenshot.svg), [saved output](docs/demo-terminal-output.txt), [compare with alternatives](docs/launch-gate-positioning.md), and the [30-second cold-start review](docs/cold-start-review.md).
35
35
 
36
36
  These are the failures that hurt after real users arrive:
37
37
 
@@ -54,7 +54,7 @@ No signup, no code upload, no LLM call:
54
54
  npx ai-saas-guard@latest demo --summary
55
55
  ```
56
56
 
57
- The demo scans two packaged fixtures: one risky AI-built SaaS and one safer version. See the saved terminal sample in [docs/demo-terminal-output.txt](docs/demo-terminal-output.txt), then compare with alternatives in [docs/launch-gate-positioning.md](docs/launch-gate-positioning.md).
57
+ The demo scans two packaged fixtures: one risky AI-built SaaS and one safer version. See the [terminal screenshot](docs/demo-terminal-screenshot.svg) or saved terminal sample in [docs/demo-terminal-output.txt](docs/demo-terminal-output.txt), then compare with alternatives in [docs/launch-gate-positioning.md](docs/launch-gate-positioning.md).
58
58
 
59
59
  ## 60-Second Local Check
60
60
 
@@ -138,6 +138,14 @@ One command returns a launch-readiness report with:
138
138
 
139
139
  For a concise comparison with Semgrep, zizmor, OpenSSF Scorecard, Snyk, and GitHub code scanning, see [docs/launch-gate-positioning.md](docs/launch-gate-positioning.md).
140
140
 
141
+ ## Three Ways To Use It
142
+
143
+ | Path | Best for | Status |
144
+ | --- | --- | --- |
145
+ | Local CLI | Private code, first local launch review, founder or reviewer workflow | Published on npm; local-first, read-only, no code upload, no LLM calls |
146
+ | GitHub Action | CI review queue, SARIF upload, PR summary artifacts, controlled fail thresholds | Available through `zr9959/ai-saas-guard@v0` and fixed version tags |
147
+ | Hosted GitHub App | Future hosted Check Run experience for selected repositories | Limited trial gate only; not the complete hosted SaaS, not a public hosted scanner |
148
+
141
149
  ## Quick Start
142
150
 
143
151
  Run the published CLI without installing it globally:
@@ -199,13 +207,13 @@ The CLI is published on npm as `ai-saas-guard`, and the GitHub Action is availab
199
207
  | Area | Status |
200
208
  | --- | --- |
201
209
  | Public GitHub repository | Available |
202
- | npm CLI | `ai-saas-guard@0.33.0` |
203
- | GitHub Action | `zr9959/ai-saas-guard@v0` or fixed tag `v0.33.0` |
210
+ | npm CLI | `ai-saas-guard@0.35.0` |
211
+ | GitHub Action | `zr9959/ai-saas-guard@v0` or fixed tag `v0.35.0` |
204
212
  | Outputs | Short summary, terminal, JSON, SARIF, and PR-focused markdown |
205
213
  | Project config | `.ai-saas-guard.json` rule toggles, severity overrides, suppressions, and fail thresholds |
206
214
  | Privacy model | Local-first, read-only scan commands, no LLM calls, no code upload |
207
- | Versioned Action tags | `v0.33.0`, `v0` |
208
- | Current release | `0.33.0` sharpens the README first screen, adds a saved terminal demo output, and adds deployed worker staging evidence automation that validates safe logs before building hosted release-gate input |
215
+ | Versioned Action tags | `v0.35.0`, `v0` |
216
+ | Current release | `0.35.0` adds a hosted GitHub App limited-trial gate, read-only checkout scan gate, three usage paths, a realistic AI SaaS case-study fixture, and a local scan resource budget helper |
209
217
  | npm publishing | Trusted Publisher/OIDC, no long-lived publish token |
210
218
  | Repository trust hardening | Strict branch protection, Dependabot, CodeQL, fast-check fuzzing, signed release provenance assets, private vulnerability reporting, secret scanning, and push protection |
211
219
  | Cloudflare hosted ingress | Deployed at `https://ai-saas-guard-hosted.zr9959.workers.dev`; signed GitHub App webhook delivery and compact Check Run smoke now pass in staging |
@@ -318,6 +326,8 @@ The hosted production adapter layer is documented in [docs/hosted-production-ada
318
326
 
319
327
  The hosted read-only checkout worker is exported from `ai-saas-guard/hosted/worker`. It creates a temporary checkout from trusted GitHub App identity, uses a runtime installation token only through git askpass, removes askpass material before the CLI phase, rejects mutated command/checkout/token-scope plans, runs the fixed `ai-saas-guard pr-risk --json` command with bounded timeout/output, converts CLI JSON into compact findings, and deletes the checkout after success or failure. It does not return source, diffs, secrets, checkout paths, PR-authored commands, or installation tokens.
320
328
 
329
+ The read-only checkout scan gate is exported as `evaluateHostedReadOnlyCheckoutScanGate` from `ai-saas-guard/hosted/worker`. It records whether the real worker path observed trusted git stages, CLI scan, compact report storage, Check Run publication, checkout cleanup, token removal before CLI, and bounded timeout/output settings before a hosted trial can proceed.
330
+
321
331
  The hosted Node/container app skeleton is documented in [docs/hosted-node-container-app.md](docs/hosted-node-container-app.md). It exports `createHostedHttpApp`, `createInMemoryHostedAppPlatform`, `createHostedNodeCheckoutAppPlatform`, and `planHostedNodeContainerDeployment` from `ai-saas-guard/hosted/app`. It adds a safe `/healthz` route, signed `/github/webhook` ingress, one-job worker tick, in-memory provider adapters for tests, a concrete read-only checkout worker composition with visible timeout/output safety budgets, and deployment-plan validation for secret manager, queue, compact report store, worker sandbox, and GitHub Checks publisher references. It still does not deploy or expose a public hosted service by itself.
322
332
 
323
333
  The hosted staging deployment planner is documented in [docs/hosted-staging-deployment.md](docs/hosted-staging-deployment.md). It exports `planHostedProviderBinding`, `planHostedStagingDeployment`, and `planHostedGitHubAppPromotion` from `ai-saas-guard/hosted/staging`. It composes real provider references, the Node/container deployment plan, hosted operational release-gate evidence, and GitHub App deployment planning so staging and production promotion stay blocked until the required queue, store, worker sandbox, Check Run publisher, logs, metrics, rollback, and incident-response references are present. It still does not call a cloud provider, create a GitHub App, or expose a public hosted service by itself.
@@ -336,8 +346,14 @@ Hosted pricing and packaging boundaries are documented in [docs/hosted-pricing-p
336
346
 
337
347
  Hosted pre-implementation pure contracts are documented in [docs/hosted-preimplementation-contracts.md](docs/hosted-preimplementation-contracts.md). They now include a pull request webhook intake planner that verifies signatures before parsing or queueing, a durable scan queue planner that reuses queued, running, and completed jobs for the same trusted scan key, a worker read-only scan planner that fixes the CLI command and requires repository `contents: read`, a concrete Node read-only checkout scan runner, and a Check Run publication planner that requires repository `checks: write` and builds bounded check-only payloads from compact reports. They also cover queue-safe webhook event parsing, bounded check-run summary rendering, idempotent queue cleanup planning, worker checkout cleanup planning, a retention/deletion cleanup planner, an operational release gate evaluator, the production adapter plans needed for GitHub App auth and bounded worker execution, the Node/container app skeleton needed for real provider wiring, the staging deployment planner needed before production GitHub App promotion, the local staging harness needed to rehearse webhook replay, persistence, publication, and cleanup without cloud calls, and the deployed worker staging evidence helper needed to evaluate public HTTPS health, deployed cleanup, and log-boundary evidence without storing raw hosted data. The service runtime composes these contracts behind replaceable adapters. PR comments remain a later workflow or paid hosted feature, not part of the hosted MVP contract.
338
348
 
349
+ The limited hosted GitHub App trial gate is exported as `createHostedGitHubAppTrialGate` from `ai-saas-guard/hosted/contracts`. It keeps trial use scoped to selected repositories and requires Check Run publication, compact report storage, worker cleanup, and safe log-boundary evidence before treating a small trial as ready. It does not claim the complete hosted SaaS is available.
350
+
339
351
  A public hosted compact report schema fixture is available at [examples/hosted-compact-report.json](examples/hosted-compact-report.json). It is synthetic and public-safe: compact evidence only, no raw source, raw diffs, secrets, webhook payload bodies, customer payloads, private URLs, or worker checkout paths.
340
352
 
353
+ The case-study fixture in [examples/case-study-ai-saas](examples/case-study-ai-saas) and [docs/case-study-ai-saas.md](docs/case-study-ai-saas.md) shows a more realistic AI-built SaaS shape across auth-adjacent routes, billing, Stripe, Supabase, Next/Vercel, and GitHub Actions.
354
+
355
+ For large repositories, `createLocalScanResourceBudget` exposes the conservative local scan budget: bounded text files, per-file bytes, total bytes, ignored build/dependency directories, no code upload, and no LLM calls.
356
+
341
357
  The proposed hosted app permission boundary is intentionally narrow: repository contents read, pull requests read, checks write, and metadata read for the first version. Optional PR comments require repository policy opt-in, and broad permissions such as administration, deployments, Actions write, and repository secrets are out of scope.
342
358
 
343
359
  The repository also includes hosted contract helpers and runtime tests for webhook intake order, webhook verification, installation token scoping, durable queue idempotency, compact reports, retention limits, uninstall cleanup, repeated cleanup idempotency, scoped deletion planning, operational release gate blocking, provider-independent hosted service orchestration, and GitHub App deployment planning. These helpers do not deploy a public hosted service.
@@ -374,7 +390,7 @@ Use `suppressions` for narrower false-positive handling when one rule is noisy o
374
390
 
375
391
  ## GitHub Action
376
392
 
377
- The repo includes a composite Action. Use `v0` for the latest compatible pre-1.0 Action, a specific release tag such as `v0.33.0` for controlled upgrades, or pin a reviewed commit SHA for stricter supply-chain control:
393
+ The repo includes a composite Action. Use `v0` for the latest compatible pre-1.0 Action, a specific release tag such as `v0.35.0` for controlled upgrades, or pin a reviewed commit SHA for stricter supply-chain control:
378
394
 
379
395
  ```yaml
380
396
  name: ai-saas-guard
@@ -453,6 +453,54 @@ export interface HostedCheckRunPublicationPlan {
453
453
  modelTraining: "disabled";
454
454
  };
455
455
  }
456
+ export type HostedGitHubAppTrialGateBlockedReason = "trial_repository_limit_exceeded" | "trial_repository_not_selected" | "check_run_publication_missing" | "compact_report_missing" | "worker_cleanup_missing" | "safe_log_boundary_rejected";
457
+ export interface HostedGitHubAppTrialGateInput {
458
+ requestedAt: string;
459
+ appName: string;
460
+ installationId: number;
461
+ selectedRepositoryIds: number[];
462
+ trialRepositoryIds: number[];
463
+ completedCheckRuns: Array<{
464
+ repositoryId: number;
465
+ pullRequestNumber: number;
466
+ headSha: string;
467
+ conclusion: HostedCheckRunConclusion;
468
+ compactReportStored: boolean;
469
+ checkRunPublished: boolean;
470
+ workerCleanupVerified: boolean;
471
+ }>;
472
+ safeLogBoundary: {
473
+ accepted: boolean;
474
+ sampleCount: number;
475
+ blockedReasons: string[];
476
+ };
477
+ maxTrialRepositories?: number;
478
+ rawSource?: string;
479
+ rawDiff?: string;
480
+ secretValues?: string[];
481
+ customerPayload?: unknown;
482
+ }
483
+ export interface HostedGitHubAppTrialGate {
484
+ readyForTrial: boolean;
485
+ blockedReasons: HostedGitHubAppTrialGateBlockedReason[];
486
+ requestedAt: string;
487
+ scope: {
488
+ appName: string;
489
+ installationId: number;
490
+ trialRepositoryIds: number[];
491
+ maxTrialRepositories: number;
492
+ };
493
+ checkRunsReady: boolean;
494
+ safeLogBoundaryReady: boolean;
495
+ requiredNextProof: string[];
496
+ privacy: {
497
+ includesRawSource: false;
498
+ includesRawDiffs: false;
499
+ includesSecrets: false;
500
+ includesCustomerPayloads: false;
501
+ claimsCompleteHostedSaas: false;
502
+ };
503
+ }
456
504
  export type HostedDeletionTrigger = "repository_removed" | "installation_deleted" | "repeated_cleanup";
457
505
  export interface HostedDeletionPlanInput {
458
506
  trigger: HostedDeletionTrigger;
@@ -690,6 +738,7 @@ export declare function resolveHostedRetentionDays(input?: {
690
738
  export declare function createCompactHostedReport(input: CompactHostedReportInput): CompactHostedReport;
691
739
  export declare function createHostedCheckRunSummary(input: HostedCheckRunSummaryInput): HostedCheckRunSummary;
692
740
  export declare function planHostedCheckRunPublication(input: HostedCheckRunPublicationInput): HostedCheckRunPublicationPlan;
741
+ export declare function createHostedGitHubAppTrialGate(input: HostedGitHubAppTrialGateInput): HostedGitHubAppTrialGate;
693
742
  export declare function getHostedDeletionIdempotencyKey(input: {
694
743
  trigger: HostedDeletionTrigger;
695
744
  installationId: number;
@@ -485,7 +485,7 @@ export function createHostedCheckRunSummary(input) {
485
485
  conclusion,
486
486
  output: {
487
487
  title: formatCheckRunTitle(totalFindings, conclusion, input.failOnSeverity),
488
- summary: `Launch gate: ${launchGate}. Review first: verify this signal before release; it is not a full security audit, pentest, or certification.`,
488
+ summary: `Launch gate: ${launchGate}. Review first: What changed at the launch boundary? Manual proof required before release; it is not a full security audit, pentest, or certification.`,
489
489
  text: truncateMarkdown(formatCheckRunMarkdown(report, conclusion, localCliCommand, launchGate), input.maxMarkdownChars)
490
490
  },
491
491
  annotations: report.evidence.slice(0, MAX_CHECK_RUN_ANNOTATIONS).map((finding) => {
@@ -559,6 +559,59 @@ export function planHostedCheckRunPublication(input) {
559
559
  privacy: hostedCheckRunPublicationPrivacy()
560
560
  };
561
561
  }
562
+ export function createHostedGitHubAppTrialGate(input) {
563
+ const maxTrialRepositories = input.maxTrialRepositories ?? 3;
564
+ const selectedRepositoryIds = new Set(input.selectedRepositoryIds);
565
+ const blockedReasons = [];
566
+ const trialRepositoryLimitExceeded = input.trialRepositoryIds.length > maxTrialRepositories;
567
+ const trialRepositoryNotSelected = input.trialRepositoryIds.some((repositoryId) => !selectedRepositoryIds.has(repositoryId));
568
+ const matchingRuns = input.completedCheckRuns.filter((run) => input.trialRepositoryIds.includes(run.repositoryId));
569
+ const checkRunPublicationMissing = matchingRuns.length === 0 || matchingRuns.some((run) => !run.checkRunPublished);
570
+ const compactReportMissing = matchingRuns.length === 0 || matchingRuns.some((run) => !run.compactReportStored);
571
+ const workerCleanupMissing = matchingRuns.length === 0 || matchingRuns.some((run) => !run.workerCleanupVerified);
572
+ const safeLogBoundaryRejected = !input.safeLogBoundary.accepted || input.safeLogBoundary.sampleCount <= 0;
573
+ if (trialRepositoryLimitExceeded)
574
+ blockedReasons.push("trial_repository_limit_exceeded");
575
+ if (trialRepositoryNotSelected)
576
+ blockedReasons.push("trial_repository_not_selected");
577
+ if (checkRunPublicationMissing)
578
+ blockedReasons.push("check_run_publication_missing");
579
+ if (compactReportMissing)
580
+ blockedReasons.push("compact_report_missing");
581
+ if (workerCleanupMissing)
582
+ blockedReasons.push("worker_cleanup_missing");
583
+ if (safeLogBoundaryRejected)
584
+ blockedReasons.push("safe_log_boundary_rejected");
585
+ return {
586
+ readyForTrial: blockedReasons.length === 0,
587
+ blockedReasons,
588
+ requestedAt: input.requestedAt,
589
+ scope: {
590
+ appName: input.appName,
591
+ installationId: input.installationId,
592
+ trialRepositoryIds: [...input.trialRepositoryIds].sort((a, b) => a - b),
593
+ maxTrialRepositories
594
+ },
595
+ checkRunsReady: matchingRuns.length > 0 &&
596
+ !checkRunPublicationMissing &&
597
+ !compactReportMissing &&
598
+ !workerCleanupMissing,
599
+ safeLogBoundaryReady: !safeLogBoundaryRejected,
600
+ requiredNextProof: [
601
+ "Install only on selected trial repositories.",
602
+ "Publish one bounded Check Run from compact report data only.",
603
+ "Verify worker checkout cleanup after success and failure.",
604
+ "Sample logs and confirm raw source, raw diffs, secrets, customer payloads, and tokens are absent."
605
+ ],
606
+ privacy: {
607
+ includesRawSource: false,
608
+ includesRawDiffs: false,
609
+ includesSecrets: false,
610
+ includesCustomerPayloads: false,
611
+ claimsCompleteHostedSaas: false
612
+ }
613
+ };
614
+ }
562
615
  export function getHostedDeletionIdempotencyKey(input) {
563
616
  return [input.trigger, input.installationId, input.repositoryId ?? "all"].join(":");
564
617
  }
@@ -1111,6 +1164,11 @@ function formatCheckRunMarkdown(report, conclusion, localCliCommand, launchGate)
1111
1164
  "Files to review first:",
1112
1165
  ...(filesToReview.length === 0 ? ["- None"] : filesToReview.map((file) => `- ${file}`)),
1113
1166
  "",
1167
+ "Launch-boundary reviewer checklist:",
1168
+ "- What changed at the launch boundary?",
1169
+ "- Why this auth billing data or deploy decision is safe?",
1170
+ "- What manual test proves it fails closed?",
1171
+ "",
1114
1172
  "Verification steps:",
1115
1173
  "- Review each listed file before release or merge.",
1116
1174
  "- Reproduce locally with the CLI command above.",
@@ -1,5 +1,6 @@
1
1
  import type { HostedServiceScanRunner, HostedServiceScanRunnerInput, HostedServiceScanRunnerResult } from "./service.js";
2
2
  export type HostedReadOnlyCheckoutCommandStage = "git_init" | "git_remote_add" | "git_fetch_head" | "git_fetch_base" | "git_checkout" | "cli_scan";
3
+ export type HostedReadOnlyCheckoutScanGateBlockedReason = `missing_command_stage_${HostedReadOnlyCheckoutCommandStage}` | "compact_report_missing" | "check_run_missing" | "checkout_cleanup_missing" | "token_boundary_missing" | "output_budget_exceeded" | "timeout_budget_exceeded";
3
4
  export interface HostedReadOnlyCheckoutCommand {
4
5
  stage: HostedReadOnlyCheckoutCommandStage;
5
6
  command: string;
@@ -26,6 +27,39 @@ export interface HostedReadOnlyCheckoutScanRunnerOptions {
26
27
  installationTokenProvider: HostedInstallationTokenProvider;
27
28
  commandRunner?: HostedReadOnlyCheckoutCommandRunner;
28
29
  }
30
+ export interface HostedReadOnlyCheckoutScanGateInput {
31
+ requestedAt: string;
32
+ jobKey: string;
33
+ commandStages: HostedReadOnlyCheckoutCommandStage[];
34
+ summaryCounts: Record<string, number>;
35
+ compactFindingCount: number;
36
+ compactReportStored: boolean;
37
+ checkRunPublished: boolean;
38
+ checkoutDeleted: boolean;
39
+ tokenRemovedBeforeCli: boolean;
40
+ maxOutputBytes: number;
41
+ timeoutMs: number;
42
+ rawSource?: string;
43
+ rawDiff?: string;
44
+ checkoutPath?: string;
45
+ installationToken?: string;
46
+ }
47
+ export interface HostedReadOnlyCheckoutScanGate {
48
+ readyForHostedTrial: boolean;
49
+ blockedReasons: HostedReadOnlyCheckoutScanGateBlockedReason[];
50
+ requestedAt: string;
51
+ jobKey: string;
52
+ summaryCounts: Record<string, number>;
53
+ compactFindingCount: number;
54
+ commandStagesObserved: HostedReadOnlyCheckoutCommandStage[];
55
+ privacy: {
56
+ includesRawSource: false;
57
+ includesRawDiffs: false;
58
+ includesPrivateCheckoutPath: false;
59
+ includesInstallationToken: false;
60
+ claimsCompleteHostedSaas: false;
61
+ };
62
+ }
29
63
  export type HostedReadOnlyCheckoutScanSafeReason = "invalid_worker_plan" | "invalid_repository_full_name" | "invalid_clone_base_url" | "missing_installation_token" | "git_init_failed" | "git_remote_add_failed" | "git_fetch_head_failed" | "git_fetch_base_failed" | "git_checkout_failed" | "cli_scan_failed" | "invalid_cli_output" | "cleanup_failed";
30
64
  export declare class HostedReadOnlyCheckoutScanError extends Error {
31
65
  readonly safeReason: HostedReadOnlyCheckoutScanSafeReason;
@@ -40,4 +74,5 @@ export declare class HostedReadOnlyCheckoutScanError extends Error {
40
74
  constructor(safeReason: HostedReadOnlyCheckoutScanSafeReason);
41
75
  }
42
76
  export declare function createHostedReadOnlyCheckoutScanRunner(options: HostedReadOnlyCheckoutScanRunnerOptions): HostedServiceScanRunner;
77
+ export declare function evaluateHostedReadOnlyCheckoutScanGate(input: HostedReadOnlyCheckoutScanGateInput): HostedReadOnlyCheckoutScanGate;
43
78
  export declare function runHostedReadOnlyCheckoutScan(input: HostedServiceScanRunnerInput, options: HostedReadOnlyCheckoutScanRunnerOptions): Promise<HostedServiceScanRunnerResult>;
@@ -28,6 +28,52 @@ export class HostedReadOnlyCheckoutScanError extends Error {
28
28
  export function createHostedReadOnlyCheckoutScanRunner(options) {
29
29
  return (input) => runHostedReadOnlyCheckoutScan(input, options);
30
30
  }
31
+ export function evaluateHostedReadOnlyCheckoutScanGate(input) {
32
+ const requiredStages = [
33
+ "git_init",
34
+ "git_remote_add",
35
+ "git_fetch_head",
36
+ "git_fetch_base",
37
+ "git_checkout",
38
+ "cli_scan"
39
+ ];
40
+ const observedStages = new Set(input.commandStages);
41
+ const blockedReasons = [];
42
+ for (const stage of requiredStages) {
43
+ if (!observedStages.has(stage))
44
+ blockedReasons.push(`missing_command_stage_${stage}`);
45
+ }
46
+ if (!input.compactReportStored)
47
+ blockedReasons.push("compact_report_missing");
48
+ if (!input.checkRunPublished)
49
+ blockedReasons.push("check_run_missing");
50
+ if (!input.checkoutDeleted)
51
+ blockedReasons.push("checkout_cleanup_missing");
52
+ if (!input.tokenRemovedBeforeCli)
53
+ blockedReasons.push("token_boundary_missing");
54
+ if (input.maxOutputBytes > HOSTED_WORKER_MAX_OUTPUT_BYTES) {
55
+ blockedReasons.push("output_budget_exceeded");
56
+ }
57
+ if (input.timeoutMs > HOSTED_WORKER_MAX_TIMEOUT_MS) {
58
+ blockedReasons.push("timeout_budget_exceeded");
59
+ }
60
+ return {
61
+ readyForHostedTrial: blockedReasons.length === 0,
62
+ blockedReasons,
63
+ requestedAt: input.requestedAt,
64
+ jobKey: input.jobKey,
65
+ summaryCounts: { ...input.summaryCounts },
66
+ compactFindingCount: input.compactFindingCount,
67
+ commandStagesObserved: input.commandStages.filter((stage, index, stages) => stages.indexOf(stage) === index),
68
+ privacy: {
69
+ includesRawSource: false,
70
+ includesRawDiffs: false,
71
+ includesPrivateCheckoutPath: false,
72
+ includesInstallationToken: false,
73
+ claimsCompleteHostedSaas: false
74
+ }
75
+ };
76
+ }
31
77
  export async function runHostedReadOnlyCheckoutScan(input, options) {
32
78
  const { plan } = input;
33
79
  const { checkout, cli } = plan;
package/dist/index.d.ts CHANGED
@@ -9,7 +9,9 @@ export { applyGuardConfig, defaultConfigFileName, loadGuardConfig } from "./conf
9
9
  export { createScanContext } from "./context.js";
10
10
  export { getRuleMetadata, RULE_CATALOG } from "./rules/catalog.js";
11
11
  export { formatSummaryReport } from "./report/summary.js";
12
+ export { createLocalScanResourceBudget } from "./performance.js";
12
13
  export type { BaseReport, CommandName, Evidence, Finding, ActionsReport, McpOptions, McpPolicyTemplate, McpReport, McpServerInventory, McpSideEffect, PrRiskFile, PrRiskReport, ScanOptions, ShowcaseReport, StripeReport, SupabaseOptions, SupabaseDoctorReport, SupabaseReport } from "./types.js";
13
14
  export type { ScanContext, ScanInput } from "./context.js";
14
15
  export type { FindingSuppression, GuardConfig, RuleConfigValue } from "./config.js";
15
16
  export type { RuleMetadata, RuleStability } from "./rules/catalog.js";
17
+ export type { LocalScanResourceBudget, LocalScanResourceBudgetInput } from "./performance.js";
package/dist/index.js CHANGED
@@ -9,3 +9,4 @@ export { applyGuardConfig, defaultConfigFileName, loadGuardConfig } from "./conf
9
9
  export { createScanContext } from "./context.js";
10
10
  export { getRuleMetadata, RULE_CATALOG } from "./rules/catalog.js";
11
11
  export { formatSummaryReport } from "./report/summary.js";
12
+ export { createLocalScanResourceBudget } from "./performance.js";
@@ -0,0 +1,21 @@
1
+ export interface LocalScanResourceBudgetInput {
2
+ repositoryKind?: string;
3
+ maxFiles?: number;
4
+ maxTotalBytes?: number;
5
+ maxFileBytes?: number;
6
+ }
7
+ export interface LocalScanResourceBudget {
8
+ repositoryKind: string;
9
+ localFirst: true;
10
+ deterministic: true;
11
+ uploadsCode: false;
12
+ callsLlm: false;
13
+ limits: {
14
+ maxFiles: number;
15
+ maxTotalBytes: number;
16
+ maxFileBytes: number;
17
+ };
18
+ ignoredDirectories: string[];
19
+ operatorNote: string;
20
+ }
21
+ export declare function createLocalScanResourceBudget(input?: LocalScanResourceBudgetInput): LocalScanResourceBudget;
@@ -0,0 +1,23 @@
1
+ import { DEFAULT_MAX_TEXT_FILE_BYTES, DEFAULT_MAX_TEXT_FILES, DEFAULT_MAX_TOTAL_TEXT_BYTES } from "./utils/files.js";
2
+ export function createLocalScanResourceBudget(input = {}) {
3
+ return {
4
+ repositoryKind: input.repositoryKind ?? "ai-built-saas",
5
+ localFirst: true,
6
+ deterministic: true,
7
+ uploadsCode: false,
8
+ callsLlm: false,
9
+ limits: {
10
+ maxFiles: positiveIntegerOrDefault(input.maxFiles, DEFAULT_MAX_TEXT_FILES),
11
+ maxTotalBytes: positiveIntegerOrDefault(input.maxTotalBytes, DEFAULT_MAX_TOTAL_TEXT_BYTES),
12
+ maxFileBytes: positiveIntegerOrDefault(input.maxFileBytes, DEFAULT_MAX_TEXT_FILE_BYTES)
13
+ },
14
+ ignoredDirectories: [".git", ".next", ".turbo", "coverage", "dist", "build", "node_modules", "out"],
15
+ operatorNote: "This keeps local scans bounded for large AI SaaS repositories without uploading code or calling an LLM."
16
+ };
17
+ }
18
+ function positiveIntegerOrDefault(value, fallback) {
19
+ if (value === undefined)
20
+ return fallback;
21
+ const normalized = Math.floor(value);
22
+ return Number.isFinite(normalized) && normalized > 0 ? normalized : fallback;
23
+ }
@@ -10,11 +10,17 @@ function formatDemoMarkdown(report) {
10
10
  const lines = [];
11
11
  lines.push("## ai-saas-guard demo");
12
12
  lines.push("");
13
- lines.push("Synthetic public demo for the local-first launch gate. This is not a pentest, full audit, or certification.");
13
+ lines.push("AI-built SaaS can look ready while launch risks stay hidden. This is not a pentest, full audit, or certification.");
14
14
  lines.push("");
15
15
  lines.push(`- Risky demo: ${escapeMarkdownInline(summaryText(report.demos.risky))}`);
16
16
  lines.push(`- Safe demo: ${escapeMarkdownInline(summaryText(report.demos.safe))}`);
17
17
  lines.push("");
18
+ lines.push("### What This Proves");
19
+ appendList(lines, [
20
+ "The same SaaS surfaces can look finished while auth, billing, data, deploy, and CI risks still need review.",
21
+ "The safe demo keeps the same SaaS surfaces but removes the intentional launch-risk patterns."
22
+ ].map(escapeMarkdownInline));
23
+ lines.push("");
18
24
  lines.push("### Review First");
19
25
  appendList(lines, reviewFirst(report.demos.risky.findings).map(escapeMarkdownInline));
20
26
  lines.push("");
@@ -35,13 +35,17 @@ export function formatSummaryReport(report) {
35
35
  function formatShowcaseSummary(report) {
36
36
  const lines = [];
37
37
  lines.push("ai-saas-guard demo summary");
38
- lines.push("Synthetic public demo for the local-first launch gate.");
38
+ lines.push("AI-built SaaS can look ready while launch risks stay hidden.");
39
39
  lines.push("This is not a pentest, full audit, or certification.");
40
40
  lines.push("");
41
41
  lines.push(`Risky demo: ${summaryText(report.demos.risky)}`);
42
42
  lines.push(`Safe demo: ${summaryText(report.demos.safe)}`);
43
43
  lines.push(`Launch gate: ${launchGateVerdict(report.demos.risky)}`);
44
44
  lines.push("");
45
+ lines.push("What this proves:");
46
+ lines.push("- The same SaaS surfaces can look finished while auth, billing, data, deploy, and CI risks still need review.");
47
+ lines.push("- The safe demo keeps the same SaaS surfaces but removes the intentional launch-risk patterns.");
48
+ lines.push("");
45
49
  lines.push("Top risks:");
46
50
  appendList(lines, reviewFirst(report.demos.risky.findings, 3));
47
51
  lines.push("");
@@ -48,12 +48,16 @@ export function formatTerminalReport(report) {
48
48
  function formatDemoTerminalReport(report) {
49
49
  const lines = [];
50
50
  lines.push("ai-saas-guard demo");
51
- lines.push("Synthetic public demo for the local-first launch gate.");
51
+ lines.push("AI-built SaaS can look ready while launch risks stay hidden.");
52
52
  lines.push("This is not a pentest, full audit, or certification.");
53
53
  lines.push("");
54
54
  lines.push(`Risky demo: ${summaryText(report.demos.risky)}`);
55
55
  lines.push(`Safe demo: ${summaryText(report.demos.safe)}`);
56
56
  lines.push("");
57
+ lines.push("What this proves:");
58
+ lines.push("- The same SaaS surfaces can look finished while auth, billing, data, deploy, and CI risks still need review.");
59
+ lines.push("- The safe demo keeps the same SaaS surfaces but removes the intentional launch-risk patterns.");
60
+ lines.push("");
57
61
  lines.push("Review first:");
58
62
  for (const item of reviewFirst(report.demos.risky.findings)) {
59
63
  lines.push(`- ${item}`);
@@ -51,7 +51,7 @@ AI 构建的 SaaS 很容易“看起来已经能上线”:能登录、能打
51
51
  npx ai-saas-guard@latest demo --summary
52
52
  ```
53
53
 
54
- 这个 demo 会扫描两个包内 fixture:一个故意有上线风险的 AI-built SaaS,和一个同类场景下更安全的版本。可以先看保存好的终端样例:[docs/demo-terminal-output.txt](demo-terminal-output.txt),再看它[和替代方案的区别](launch-gate-positioning.md)。
54
+ 这个 demo 会扫描两个包内 fixture:一个故意有上线风险的 AI-built SaaS,和一个同类场景下更安全的版本。可以先看[终端截图](docs/demo-terminal-screenshot.svg)和保存好的终端样例:[docs/demo-terminal-output.txt](demo-terminal-output.txt),再看它[和替代方案的区别](launch-gate-positioning.md)。
55
55
 
56
56
  ## 60 秒本地检查
57
57
 
@@ -135,6 +135,14 @@ Next steps
135
135
 
136
136
  如果想看它和 Semgrep、zizmor、OpenSSF Scorecard、Snyk、GitHub code scanning 的边界区别,见 [launch-gate-positioning.md](launch-gate-positioning.md)。
137
137
 
138
+ ## 三种使用路径
139
+
140
+ | 路径 | 适合什么场景 | 当前状态 |
141
+ | --- | --- | --- |
142
+ | 本地 CLI | 私有代码、本机首次上线 review、founder 或 reviewer 自查 | 已发布到 npm;本地优先、只读、不上传代码、不调用 LLM |
143
+ | GitHub Action | CI 里的 review queue、SARIF、PR summary artifact、可控 fail threshold | 可通过 `zr9959/ai-saas-guard@v0` 或固定版本标签使用 |
144
+ | Hosted GitHub App | 未来面向 selected repositories 的 hosted Check Run 体验 | 目前只是 limited trial gate,不是完整 hosted SaaS,也不是公开 hosted scanner |
145
+
138
146
  ## 快速开始
139
147
 
140
148
  无需全局安装,直接运行:
@@ -179,18 +187,18 @@ node dist/cli.js scan --root /path/to/your-saas
179
187
 
180
188
  这个仓库是公开 GitHub 仓库。
181
189
 
182
- CLI 已发布到 npm:`ai-saas-guard@0.33.0`。GitHub Action 支持 `v0` 浮动标签,也支持固定版本标签,例如 `v0.33.0`。
190
+ CLI 已发布到 npm:`ai-saas-guard@0.35.0`。GitHub Action 支持 `v0` 浮动标签,也支持固定版本标签,例如 `v0.35.0`。
183
191
 
184
192
  | 模块 | 状态 |
185
193
  | --- | --- |
186
194
  | 公开 GitHub 仓库 | 已可用 |
187
- | npm CLI | `ai-saas-guard@0.33.0` |
188
- | GitHub Action | `zr9959/ai-saas-guard@v0` 或固定标签 `v0.33.0` |
195
+ | npm CLI | `ai-saas-guard@0.35.0` |
196
+ | GitHub Action | `zr9959/ai-saas-guard@v0` 或固定标签 `v0.35.0` |
189
197
  | 输出格式 | 短 summary、Terminal、JSON、SARIF 和 PR markdown |
190
198
  | 项目配置 | `.ai-saas-guard.json` 支持规则开关、severity 覆盖、suppressions 和 fail threshold |
191
199
  | 隐私模型 | 本地优先、只读扫描、不调用 LLM、不上传代码 |
192
- | 当前版本 | `0.33.0` 优化 README 首屏、增加保存好的终端 demo 输出,并新增 deployed worker staging evidence automation:先验证 safe log samples,再生成 hosted release-gate input |
193
- | Action 标签 | `v0.33.0`、`v0` |
200
+ | 当前版本 | `0.35.0` 新增 hosted GitHub App limited-trial gate、read-only checkout scan gate、三种使用路径、真实 AI SaaS case-study fixture 和本地扫描资源预算 helper |
201
+ | Action 标签 | `v0.35.0`、`v0` |
194
202
  | npm 发布 | GitHub Actions Trusted Publisher/OIDC,无需长期 npm token |
195
203
  | 仓库可信度加固 | 严格 branch protection、Dependabot、CodeQL、fast-check fuzzing、signed release provenance assets、private vulnerability reporting、secret scanning 和 push protection |
196
204
  | Cloudflare hosted ingress | 已部署到 `https://ai-saas-guard-hosted.zr9959.workers.dev`;签名 GitHub App webhook delivery 和 compact Check Run staging smoke 已通过 |
@@ -375,10 +383,14 @@ GitHub Marketplace wrapper 决策见 [docs/github-marketplace-wrapper-decision.m
375
383
  - GitHub App deployment planner:`ai-saas-guard/hosted/github-app` 导出 `planHostedGitHubAppDeployment`,生成 first slice 最小权限 manifest,并在 release gate、公开 HTTPS URL、container digest、secret 引用、原始 secret 输入、permission 或 event 不安全时阻止创建
376
384
  - Hosted production adapter layer:`ai-saas-guard/hosted/production-adapters` 导出 `createHostedGitHubAppJwt`、`planHostedGitHubInstallationTokenRequest` 和 `planHostedProductionWorkerExecution`,用于 GitHub App RS256 JWT、selected-repository installation token 请求规划、worker/check-run 分离 token scope、固定只读 worker 命令、timeout/output 预算、compact JSON-only 输出,以及 success/failure/timeout/cancellation 的 cleanup 规划;它本身仍然不部署公开 hosted 服务
377
385
  - Hosted Node/container app skeleton:`ai-saas-guard/hosted/app` 导出 `createHostedHttpApp`、`createInMemoryHostedAppPlatform`、`createHostedNodeCheckoutAppPlatform` 和 `planHostedNodeContainerDeployment`,提供安全 `/healthz`、签名 `/github/webhook` ingress、单 job worker tick、测试用 in-memory provider adapters、真实 read-only checkout worker 组合入口、可见 timeout/output 安全预算,以及 secret manager、queue、compact report store、worker sandbox、GitHub Checks publisher 的部署引用校验;它本身仍然不部署或暴露公开 hosted 服务
386
+ - Read-only checkout scan gate:`ai-saas-guard/hosted/worker` 导出 `evaluateHostedReadOnlyCheckoutScanGate`,要求真实 worker 路径证明 trusted git stages、CLI scan、compact report storage、Check Run publication、checkout cleanup、CLI 前 token removal 以及 timeout/output budgets 都满足后,才能进入 hosted trial
378
387
  - Hosted staging deployment planner:`ai-saas-guard/hosted/staging` 导出 `planHostedProviderBinding`、`planHostedStagingDeployment` 和 `planHostedGitHubAppPromotion`,把真实 provider 引用、Node/container deployment plan、hosted operational release-gate evidence 和 GitHub App deployment planning 组合起来;缺少 queue、store、worker sandbox、Check Run publisher、logs、metrics、rollback 或 incident-response 引用时,会阻止 staging exposure 和 production promotion;它本身仍然不会调用云平台、创建 GitHub App 或暴露公开 hosted 服务
379
388
  - Hosted staging harness:`ai-saas-guard/hosted/staging-harness` 导出 `createFileBackedHostedStagingHarness`、`createHostedStagingHarnessEvidence`、`createHostedStagingReleaseEvidenceBundle`、`evaluateHostedStagingReleaseEvidenceBundle` 和 `validateHostedLogBoundary`,可以在本地用 file-backed queue、compact report、Check Run request 和 worker sandbox 跑通签名 webhook replay、worker tick 和 cleanup 校验,把 success/failure cleanup probes 与 log-boundary samples 转成 release-gate evidence,并直接执行 hosted release gate 判断;它只是 staging 演练工具,不会调用云平台、创建 GitHub App、写真实 Check Run 或暴露公开 hosted 服务
380
389
  - Deployed worker staging evidence:`ai-saas-guard/hosted/deployed-staging` 导出 `createHostedDeployedWorkerStagingEvidenceAutomation`、`createHostedDeployedWorkerStagingEvidenceBundle` 和 `evaluateHostedDeployedWorkerStagingReleaseGate`,先验证 safe log samples,再把 public HTTPS health、signed webhook replay、deployed worker cleanup 以及外部 CI/scan/rollback evidence 转成 hosted release gate evidence;它不会部署云资源,也不会宣称 production hosted exposure
381
390
  - Cloudflare hosted ingress:`hosted/cloudflare-worker` 已部署到 `https://ai-saas-guard-hosted.zr9959.workers.dev`,提供 `/healthz`、`/github/app/manifest-callback` 和签名 `/github/webhook` intake;Worker 已具备 compact pull request identity、file/category risk signal 和 Check Run metadata 路径;staging GitHub App ID 为 `3834787`,installation ID 为 `135085075`;真实 GitHub App webhook delivery 和 Check Run smoke 已通过;完整 source checkout worker deployment、monitoring、rollback 和 incident-response evidence 仍需要通过 hosted operational release gate
391
+ - Hosted GitHub App limited trial gate:`ai-saas-guard/hosted/contracts` 导出 `createHostedGitHubAppTrialGate`,确保 trial 只作用于 selected repositories,并要求 Check Run publication、compact report、worker cleanup 和 safe log-boundary evidence;它不宣称完整 hosted SaaS 已可用
392
+ - Case-study fixture:`examples/case-study-ai-saas` 和 [case-study-ai-saas.md](case-study-ai-saas.md) 展示一个更接近真实 AI SaaS 的 auth、billing、Supabase、Next/Vercel 和 GitHub Actions 风险组合
393
+ - Resource budget:`createLocalScanResourceBudget` 暴露大仓库本地扫描的保守预算:文件数、单文件字节、总字节、忽略 build/dependency 目录、不上传代码、不调用 LLM
382
394
  - webhook event parser
383
395
  - check-run summary renderer
384
396
  - Check Run publication planner:要求 repository `checks: write`,只从 compact report 生成有长度上限的 Check Run payload,包含 review categories、优先 review 文件、verification steps 和本地 CLI 复现命令;MVP 不发 PR comment
@@ -0,0 +1,21 @@
1
+ # AI SaaS Case Study Fixture
2
+
3
+ `examples/case-study-ai-saas` is a synthetic case study for a realistic AI-built SaaS shape: auth-adjacent API routes, billing checkout, Stripe webhook, Supabase RLS, Next/Vercel config, and GitHub Actions.
4
+
5
+ The fixture is intentionally not safe to launch. It helps readers see why a local-first launch gate is useful even when an app appears to have the expected product surfaces.
6
+
7
+ Expected findings include:
8
+
9
+ - missing Stripe webhook signature verification
10
+ - silent-success billing fallback
11
+ - broad Supabase RLS policy
12
+ - missing Next/Vercel security headers
13
+ - broad GitHub Actions permissions
14
+
15
+ Use it locally:
16
+
17
+ ```bash
18
+ npx ai-saas-guard@latest scan --root examples/case-study-ai-saas --summary
19
+ ```
20
+
21
+ This fixture is public-safe and synthetic. It is not a SaaS starter template, pentest target, certification artifact, or full audit.
@@ -0,0 +1,22 @@
1
+ # 30-Second GitHub Cold-Start Review
2
+
3
+ Use this checklist when reading the repository as a first-time visitor.
4
+
5
+ ## First Screen
6
+
7
+ - Does the first screen explain the painful problem before listing features?
8
+ - Does it say AI-built SaaS can look ready while auth, billing, data, deploy, and CI risks stay hidden?
9
+ - Is the no-signup demo command visible without scrolling far?
10
+ - Are the local-first boundaries visible: no code upload and no LLM call?
11
+
12
+ ## First Command
13
+
14
+ - Can the visitor run `npx ai-saas-guard@latest demo --summary` without cloning a repository?
15
+ - Does the output show risky versus safe SaaS surfaces in under a minute?
16
+ - Does it point to manual proof instead of implying certification?
17
+
18
+ ## First Decision
19
+
20
+ - Can the visitor tell when to use this beside Semgrep, CodeQL, zizmor, Scorecard, Snyk, and GitHub code scanning?
21
+ - Can the visitor tell this is a launch review queue, not a pentest, full audit, or certification?
22
+ - Can the visitor tell whether they should run `scan`, `pr-risk`, or the GitHub Action next?
@@ -1,8 +1,14 @@
1
1
  ai-saas-guard demo --summary
2
2
 
3
+ AI-built SaaS can look ready while launch risks stay hidden.
4
+
3
5
  Risky demo: 19 findings
4
6
  Launch gate: blocked
5
7
 
8
+ What this proves:
9
+ - The same SaaS surfaces can look finished while auth, billing, data, deploy, and CI risks still need review.
10
+ - The safe demo keeps the same SaaS surfaces but removes the intentional launch-risk patterns.
11
+
6
12
  Top risks:
7
13
  - CRITICAL stripe.webhook.missing-signature at app/api/stripe/webhook/route.ts:1
8
14
  - CRITICAL supabase.rls.broad-policy at supabase/migrations/001_accounts.sql:10
@@ -0,0 +1,20 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="960" height="560" viewBox="0 0 960 560" role="img" aria-labelledby="title desc">
2
+ <title id="title">ai-saas-guard demo terminal screenshot</title>
3
+ <desc id="desc">Terminal-style screenshot showing risky and safe demo summaries.</desc>
4
+ <rect width="960" height="560" fill="#0b1020"/>
5
+ <rect x="32" y="32" width="896" height="496" rx="8" fill="#111827" stroke="#334155"/>
6
+ <circle cx="62" cy="58" r="7" fill="#ef4444"/>
7
+ <circle cx="86" cy="58" r="7" fill="#f59e0b"/>
8
+ <circle cx="110" cy="58" r="7" fill="#22c55e"/>
9
+ <text x="48" y="104" fill="#e5e7eb" font-family="Menlo, Consolas, monospace" font-size="22">npx ai-saas-guard@latest demo --summary</text>
10
+ <text x="48" y="152" fill="#93c5fd" font-family="Menlo, Consolas, monospace" font-size="20">ai-saas-guard demo summary</text>
11
+ <text x="48" y="190" fill="#e5e7eb" font-family="Menlo, Consolas, monospace" font-size="18">AI-built SaaS can look ready while launch risks stay hidden.</text>
12
+ <text x="48" y="232" fill="#fca5a5" font-family="Menlo, Consolas, monospace" font-size="20">Risky demo: 19 findings: 2 critical, 6 high, 7 medium, 3 low, 1 info</text>
13
+ <text x="48" y="270" fill="#86efac" font-family="Menlo, Consolas, monospace" font-size="20">Safe demo: 0 findings</text>
14
+ <text x="48" y="320" fill="#fde68a" font-family="Menlo, Consolas, monospace" font-size="18">What this proves:</text>
15
+ <text x="72" y="356" fill="#e5e7eb" font-family="Menlo, Consolas, monospace" font-size="17">- same SaaS surfaces, different launch-risk patterns</text>
16
+ <text x="72" y="388" fill="#e5e7eb" font-family="Menlo, Consolas, monospace" font-size="17">- review auth, billing, data, deploy, CI before real users</text>
17
+ <text x="48" y="438" fill="#fde68a" font-family="Menlo, Consolas, monospace" font-size="18">Top risks:</text>
18
+ <text x="72" y="474" fill="#e5e7eb" font-family="Menlo, Consolas, monospace" font-size="16">- CRITICAL stripe.webhook.missing-signature</text>
19
+ <text x="72" y="504" fill="#e5e7eb" font-family="Menlo, Consolas, monospace" font-size="16">- CRITICAL supabase.rls.broad-policy</text>
20
+ </svg>
@@ -91,6 +91,19 @@ Privacy boundaries:
91
91
 
92
92
  - do not return temporary checkout paths, raw source, raw diffs, evidence snippets, secrets, customer payloads, PR-authored commands, PR-authored repository names, or installation tokens
93
93
  - do not persist source checkout contents beyond the worker run
94
+
95
+ The read-only checkout scan gate turns a real worker observation into a small release/trial decision. The exported helper is `evaluateHostedReadOnlyCheckoutScanGate`.
96
+
97
+ It requires:
98
+
99
+ - trusted git setup, fetch, checkout, and CLI scan stages
100
+ - compact report storage
101
+ - bounded Check Run publication
102
+ - checkout cleanup
103
+ - installation token removal before the CLI phase
104
+ - timeout and output budgets within the hosted worker limits
105
+
106
+ It returns only compact counts, observed stages, blocked reasons, and privacy flags. It does not return raw source, raw diffs, checkout paths, or installation tokens.
94
107
  - rely on the deployment sandbox for network egress restrictions around the CLI phase; the runner itself removes GitHub credentials before invoking the CLI
95
108
 
96
109
  The exported helper is `createHostedReadOnlyCheckoutScanRunner`.
@@ -266,6 +279,21 @@ Privacy boundaries:
266
279
 
267
280
  The exported helper is `planHostedCheckRunPublication`. It is intended to be the GitHub-API-independent contract for the first real Check Run writer. PR comments remain an explicit later workflow or paid hosted feature, not part of this MVP contract.
268
281
 
282
+ ## Hosted GitHub App Limited Trial Gate
283
+
284
+ The limited trial gate decides whether the hosted GitHub App can be tried on a small selected-repository set. The exported helper is `createHostedGitHubAppTrialGate`.
285
+
286
+ It requires:
287
+
288
+ - trial repositories are a subset of selected GitHub App repositories
289
+ - the trial repository count stays under the configured cap
290
+ - compact Check Runs were published
291
+ - compact reports were stored
292
+ - worker cleanup was verified
293
+ - safe log-boundary samples were accepted
294
+
295
+ It does not install a GitHub App, call GitHub, run workers, or claim the complete hosted SaaS is ready. It is a deterministic gate for small controlled trials.
296
+
269
297
  ## Queue Cleanup Planner
270
298
 
271
299
  The queue cleanup planner turns repository removal, installation deletion, and repeated cleanup events into a safe cancellation plan for hosted scan jobs. It is a pure planner only: it does not connect to a queue provider, mutate jobs, delete worker files, call GitHub, or retry work.
@@ -4,6 +4,10 @@
4
4
 
5
5
  The narrow bet is simple: a founder or reviewer should know which launch-risk files to inspect first, what manual proof to run, and what fix direction to try before traffic reaches real users.
6
6
 
7
+ ## What This Adds In One Line
8
+
9
+ `ai-saas-guard` turns AI-built SaaS launch risks into a short local review queue; it is not intended to substitute for broad SAST, dependency scanning, workflow security analysis, or repository scorecards.
10
+
7
11
  ## Where It Fits
8
12
 
9
13
  | Tool category | Typical strength | How ai-saas-guard fits beside it |
@@ -5,11 +5,11 @@
5
5
  ## Current State
6
6
 
7
7
  - Package name: `ai-saas-guard`
8
- - Current published version: `0.33.0`
8
+ - Current published version: `0.35.0`
9
9
  - Next source candidate: none
10
10
  - npm registry state: published at <https://www.npmjs.com/package/ai-saas-guard>
11
11
  - First npm-published version: `0.1.1`
12
- - GitHub Release: `v0.33.0`
12
+ - GitHub Release: `v0.35.0`
13
13
  - Publish workflow: `.github/workflows/npm-publish.yml`
14
14
  - Trusted Publisher: GitHub Actions, `zr9959/ai-saas-guard`, workflow `npm-publish.yml`, allowed action `npm publish`
15
15
  - Long-lived npm publish token: not required
@@ -18,7 +18,7 @@
18
18
 
19
19
  Use GitHub Actions with npm Trusted Publisher/OIDC:
20
20
 
21
- 1. Create and review a release tag such as `v0.33.0`.
21
+ 1. Create and review a release tag such as `v0.35.0`.
22
22
  2. Publish from the GitHub Release or run the `Publish npm` workflow manually with `ref` set to that tag.
23
23
  3. Keep `permissions.id-token: write` in the workflow so npm can exchange the GitHub Actions OIDC identity for a short-lived publish credential.
24
24
  4. Run `npm publish --access public` from the workflow. Trusted publishing automatically generates provenance for this public package from this public repository.
@@ -0,0 +1,19 @@
1
+ name: ci
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+
7
+ permissions:
8
+ contents: write
9
+ pull-requests: write
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-node@v4
17
+ with:
18
+ node-version: 24
19
+ - run: npm test
@@ -0,0 +1,13 @@
1
+ # Case Study AI SaaS Fixture
2
+
3
+ This synthetic fixture looks like a small AI-built SaaS with auth, billing, Supabase, Vercel/Next.js deploy config, and GitHub Actions.
4
+
5
+ It is intentionally risky:
6
+
7
+ - billing checkout swallows provider failure and returns fake success
8
+ - Stripe webhook does not verify signatures
9
+ - Supabase RLS policy is broad
10
+ - Next.js config lacks production security headers
11
+ - GitHub Actions grants broad permissions
12
+
13
+ It is not a complete SaaS template and does not contain real secrets.
@@ -0,0 +1,11 @@
1
+ export async function POST() {
2
+ try {
3
+ return Response.json({ checkoutUrl: await createCheckoutSession() });
4
+ } catch {
5
+ return Response.json({ success: true, checkoutUrl: "/billing/demo-success" });
6
+ }
7
+ }
8
+
9
+ async function createCheckoutSession() {
10
+ throw new Error("provider unavailable");
11
+ }
@@ -0,0 +1,8 @@
1
+ export async function GET(_request: Request, context: { params: { projectId: string } }) {
2
+ return Response.json({
3
+ project: {
4
+ id: context.params.projectId,
5
+ tenantId: "demo-tenant"
6
+ }
7
+ });
8
+ }
@@ -0,0 +1,13 @@
1
+ export async function POST(request: Request) {
2
+ const event = await request.json();
3
+
4
+ if (event.type === "checkout.session.completed") {
5
+ await grantEntitlement(event.data.object.customer);
6
+ }
7
+
8
+ return Response.json({ received: true });
9
+ }
10
+
11
+ async function grantEntitlement(customerId: string) {
12
+ console.log("grant", customerId);
13
+ }
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ images: {
3
+ remotePatterns: [
4
+ {
5
+ protocol: "https",
6
+ hostname: "**"
7
+ }
8
+ ]
9
+ }
10
+ };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "case-study-ai-saas",
3
+ "private": true,
4
+ "scripts": {
5
+ "build": "next build",
6
+ "test": "node --test"
7
+ },
8
+ "dependencies": {
9
+ "next": "15.0.0",
10
+ "stripe": "17.0.0"
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ create table public.projects (
2
+ id uuid primary key,
3
+ tenant_id uuid not null,
4
+ name text not null
5
+ );
6
+
7
+ alter table public.projects enable row level security;
8
+
9
+ create policy "ai generated broad select"
10
+ on public.projects
11
+ for select
12
+ using (true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-saas-guard",
3
- "version": "0.33.0",
3
+ "version": "0.35.0",
4
4
  "description": "Local-first CLI that catches launch blockers in AI-built Next.js/Supabase/Stripe SaaS apps.",
5
5
  "readmeFilename": "README.md",
6
6
  "type": "module",