vibecheck-ai 2.0.1 → 5.0.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/bin/.generated +25 -0
- package/bin/_deprecations.js +463 -0
- package/bin/_router.js +46 -0
- package/bin/cli-hygiene.js +241 -0
- package/bin/dev/run-v2-torture.js +30 -0
- package/bin/registry.js +656 -0
- package/bin/runners/CLI_REFACTOR_SUMMARY.md +229 -0
- package/bin/runners/ENHANCEMENT_GUIDE.md +121 -0
- package/bin/runners/REPORT_AUDIT.md +64 -0
- package/bin/runners/cli-utils.js +1070 -0
- package/bin/runners/context/ai-task-decomposer.js +337 -0
- package/bin/runners/context/analyzer.js +513 -0
- package/bin/runners/context/api-contracts.js +427 -0
- package/bin/runners/context/context-diff.js +342 -0
- package/bin/runners/context/context-pruner.js +291 -0
- package/bin/runners/context/dependency-graph.js +414 -0
- package/bin/runners/context/generators/claude.js +107 -0
- package/bin/runners/context/generators/codex.js +108 -0
- package/bin/runners/context/generators/copilot.js +119 -0
- package/bin/runners/context/generators/cursor-enhanced.js +2525 -0
- package/bin/runners/context/generators/cursor.js +514 -0
- package/bin/runners/context/generators/mcp.js +169 -0
- package/bin/runners/context/generators/windsurf.js +180 -0
- package/bin/runners/context/git-context.js +304 -0
- package/bin/runners/context/index.js +1110 -0
- package/bin/runners/context/insights.js +173 -0
- package/bin/runners/context/mcp-server/generate-rules.js +337 -0
- package/bin/runners/context/mcp-server/index.js +1176 -0
- package/bin/runners/context/mcp-server/package.json +24 -0
- package/bin/runners/context/memory.js +200 -0
- package/bin/runners/context/monorepo.js +215 -0
- package/bin/runners/context/multi-repo-federation.js +404 -0
- package/bin/runners/context/patterns.js +253 -0
- package/bin/runners/context/proof-context.js +1264 -0
- package/bin/runners/context/security-scanner.js +541 -0
- package/bin/runners/context/semantic-search.js +350 -0
- package/bin/runners/context/shared.js +264 -0
- package/bin/runners/context/team-conventions.js +336 -0
- package/bin/runners/lib/__tests__/entitlements-v2.test.js +295 -0
- package/bin/runners/lib/agent-firewall/ai/false-positive-analyzer.js +474 -0
- package/bin/runners/lib/agent-firewall/change-packet/builder.js +488 -0
- package/bin/runners/lib/agent-firewall/change-packet/schema.json +228 -0
- package/bin/runners/lib/agent-firewall/change-packet/store.js +200 -0
- package/bin/runners/lib/agent-firewall/claims/claim-types.js +21 -0
- package/bin/runners/lib/agent-firewall/claims/extractor.js +303 -0
- package/bin/runners/lib/agent-firewall/claims/patterns.js +24 -0
- package/bin/runners/lib/agent-firewall/critic/index.js +151 -0
- package/bin/runners/lib/agent-firewall/critic/judge.js +432 -0
- package/bin/runners/lib/agent-firewall/critic/prompts.js +305 -0
- package/bin/runners/lib/agent-firewall/enforcement/gateway.js +1059 -0
- package/bin/runners/lib/agent-firewall/enforcement/index.js +98 -0
- package/bin/runners/lib/agent-firewall/enforcement/mode.js +318 -0
- package/bin/runners/lib/agent-firewall/enforcement/orchestrator.js +484 -0
- package/bin/runners/lib/agent-firewall/enforcement/proof-artifact.js +418 -0
- package/bin/runners/lib/agent-firewall/enforcement/schemas/change-event.schema.json +173 -0
- package/bin/runners/lib/agent-firewall/enforcement/schemas/intent.schema.json +181 -0
- package/bin/runners/lib/agent-firewall/enforcement/schemas/verdict.schema.json +222 -0
- package/bin/runners/lib/agent-firewall/enforcement/verdict-v2.js +333 -0
- package/bin/runners/lib/agent-firewall/evidence/auth-evidence.js +88 -0
- package/bin/runners/lib/agent-firewall/evidence/contract-evidence.js +75 -0
- package/bin/runners/lib/agent-firewall/evidence/env-evidence.js +127 -0
- package/bin/runners/lib/agent-firewall/evidence/resolver.js +102 -0
- package/bin/runners/lib/agent-firewall/evidence/route-evidence.js +213 -0
- package/bin/runners/lib/agent-firewall/evidence/side-effect-evidence.js +145 -0
- package/bin/runners/lib/agent-firewall/fs-hook/daemon.js +19 -0
- package/bin/runners/lib/agent-firewall/fs-hook/installer.js +87 -0
- package/bin/runners/lib/agent-firewall/fs-hook/watcher.js +184 -0
- package/bin/runners/lib/agent-firewall/git-hook/pre-commit.js +163 -0
- package/bin/runners/lib/agent-firewall/ide-extension/cursor.js +107 -0
- package/bin/runners/lib/agent-firewall/ide-extension/vscode.js +68 -0
- package/bin/runners/lib/agent-firewall/ide-extension/windsurf.js +66 -0
- package/bin/runners/lib/agent-firewall/index.js +200 -0
- package/bin/runners/lib/agent-firewall/integration/index.js +20 -0
- package/bin/runners/lib/agent-firewall/integration/ship-gate.js +437 -0
- package/bin/runners/lib/agent-firewall/intent/alignment-engine.js +634 -0
- package/bin/runners/lib/agent-firewall/intent/auto-detect.js +426 -0
- package/bin/runners/lib/agent-firewall/intent/index.js +102 -0
- package/bin/runners/lib/agent-firewall/intent/schema.js +352 -0
- package/bin/runners/lib/agent-firewall/intent/store.js +283 -0
- package/bin/runners/lib/agent-firewall/interception/fs-interceptor.js +502 -0
- package/bin/runners/lib/agent-firewall/interception/index.js +23 -0
- package/bin/runners/lib/agent-firewall/interceptor/base.js +308 -0
- package/bin/runners/lib/agent-firewall/interceptor/cursor.js +35 -0
- package/bin/runners/lib/agent-firewall/interceptor/vscode.js +35 -0
- package/bin/runners/lib/agent-firewall/interceptor/windsurf.js +34 -0
- package/bin/runners/lib/agent-firewall/lawbook/distributor.js +465 -0
- package/bin/runners/lib/agent-firewall/lawbook/evaluator.js +604 -0
- package/bin/runners/lib/agent-firewall/lawbook/index.js +304 -0
- package/bin/runners/lib/agent-firewall/lawbook/registry.js +514 -0
- package/bin/runners/lib/agent-firewall/lawbook/schema.js +420 -0
- package/bin/runners/lib/agent-firewall/logger.js +141 -0
- package/bin/runners/lib/agent-firewall/policy/default-policy.json +90 -0
- package/bin/runners/lib/agent-firewall/policy/engine.js +103 -0
- package/bin/runners/lib/agent-firewall/policy/loader.js +451 -0
- package/bin/runners/lib/agent-firewall/policy/rules/auth-drift.js +50 -0
- package/bin/runners/lib/agent-firewall/policy/rules/contract-drift.js +50 -0
- package/bin/runners/lib/agent-firewall/policy/rules/fake-success.js +79 -0
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-env.js +227 -0
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-route.js +191 -0
- package/bin/runners/lib/agent-firewall/policy/rules/scope.js +93 -0
- package/bin/runners/lib/agent-firewall/policy/rules/unsafe-side-effect.js +57 -0
- package/bin/runners/lib/agent-firewall/policy/schema.json +183 -0
- package/bin/runners/lib/agent-firewall/policy/verdict.js +54 -0
- package/bin/runners/lib/agent-firewall/proposal/extractor.js +394 -0
- package/bin/runners/lib/agent-firewall/proposal/index.js +212 -0
- package/bin/runners/lib/agent-firewall/proposal/schema.js +251 -0
- package/bin/runners/lib/agent-firewall/proposal/validator.js +386 -0
- package/bin/runners/lib/agent-firewall/reality/index.js +332 -0
- package/bin/runners/lib/agent-firewall/reality/state.js +625 -0
- package/bin/runners/lib/agent-firewall/reality/watcher.js +322 -0
- package/bin/runners/lib/agent-firewall/risk/index.js +173 -0
- package/bin/runners/lib/agent-firewall/risk/scorer.js +328 -0
- package/bin/runners/lib/agent-firewall/risk/thresholds.js +322 -0
- package/bin/runners/lib/agent-firewall/risk/vectors.js +421 -0
- package/bin/runners/lib/agent-firewall/session/collector.js +451 -0
- package/bin/runners/lib/agent-firewall/session/index.js +26 -0
- package/bin/runners/lib/agent-firewall/simulator/diff-simulator.js +472 -0
- package/bin/runners/lib/agent-firewall/simulator/import-resolver.js +346 -0
- package/bin/runners/lib/agent-firewall/simulator/index.js +181 -0
- package/bin/runners/lib/agent-firewall/simulator/route-validator.js +380 -0
- package/bin/runners/lib/agent-firewall/time-machine/incident-correlator.js +661 -0
- package/bin/runners/lib/agent-firewall/time-machine/index.js +267 -0
- package/bin/runners/lib/agent-firewall/time-machine/replay-engine.js +436 -0
- package/bin/runners/lib/agent-firewall/time-machine/state-reconstructor.js +490 -0
- package/bin/runners/lib/agent-firewall/time-machine/timeline-builder.js +530 -0
- package/bin/runners/lib/agent-firewall/truthpack/index.js +67 -0
- package/bin/runners/lib/agent-firewall/truthpack/loader.js +137 -0
- package/bin/runners/lib/agent-firewall/unblock/planner.js +337 -0
- package/bin/runners/lib/agent-firewall/utils/ignore-checker.js +118 -0
- package/bin/runners/lib/ai-bridge.js +416 -0
- package/bin/runners/lib/analysis-core.js +309 -0
- package/bin/runners/lib/analyzers.js +2500 -0
- package/bin/runners/lib/api-client.js +269 -0
- package/bin/runners/lib/approve-output.js +235 -0
- package/bin/runners/lib/artifact-envelope.js +540 -0
- package/bin/runners/lib/assets/vibecheck-logo.png +0 -0
- package/bin/runners/lib/audit-bridge.js +391 -0
- package/bin/runners/lib/auth-shared.js +977 -0
- package/bin/runners/lib/auth-truth.js +193 -0
- package/bin/runners/lib/auth.js +215 -0
- package/bin/runners/lib/authority-badge.js +425 -0
- package/bin/runners/lib/backup.js +62 -0
- package/bin/runners/lib/billing.js +107 -0
- package/bin/runners/lib/checkpoint.js +941 -0
- package/bin/runners/lib/claims.js +118 -0
- package/bin/runners/lib/classify-output.js +204 -0
- package/bin/runners/lib/cleanup/engine.js +571 -0
- package/bin/runners/lib/cleanup/index.js +53 -0
- package/bin/runners/lib/cleanup/output.js +375 -0
- package/bin/runners/lib/cleanup/rules.js +1060 -0
- package/bin/runners/lib/cli-output.js +400 -0
- package/bin/runners/lib/cli-ui.js +540 -0
- package/bin/runners/lib/compliance-bridge-new.js +0 -0
- package/bin/runners/lib/compliance-bridge.js +165 -0
- package/bin/runners/lib/contracts/auth-contract.js +202 -0
- package/bin/runners/lib/contracts/env-contract.js +181 -0
- package/bin/runners/lib/contracts/external-contract.js +206 -0
- package/bin/runners/lib/contracts/guard.js +168 -0
- package/bin/runners/lib/contracts/index.js +89 -0
- package/bin/runners/lib/contracts/plan-validator.js +311 -0
- package/bin/runners/lib/contracts/route-contract.js +199 -0
- package/bin/runners/lib/contracts.js +804 -0
- package/bin/runners/lib/default-config.js +127 -0
- package/bin/runners/lib/detect.js +89 -0
- package/bin/runners/lib/detectors-v2.js +622 -0
- package/bin/runners/lib/doctor/autofix.js +254 -0
- package/bin/runners/lib/doctor/diagnosis-receipt.js +454 -0
- package/bin/runners/lib/doctor/failure-signatures.js +526 -0
- package/bin/runners/lib/doctor/fix-script.js +336 -0
- package/bin/runners/lib/doctor/index.js +37 -0
- package/bin/runners/lib/doctor/modules/build-tools.js +453 -0
- package/bin/runners/lib/doctor/modules/dependencies.js +325 -0
- package/bin/runners/lib/doctor/modules/index.js +105 -0
- package/bin/runners/lib/doctor/modules/network.js +250 -0
- package/bin/runners/lib/doctor/modules/os-quirks.js +706 -0
- package/bin/runners/lib/doctor/modules/project.js +312 -0
- package/bin/runners/lib/doctor/modules/repo-integrity.js +485 -0
- package/bin/runners/lib/doctor/modules/runtime.js +224 -0
- package/bin/runners/lib/doctor/modules/security.js +350 -0
- package/bin/runners/lib/doctor/modules/system.js +213 -0
- package/bin/runners/lib/doctor/modules/vibecheck.js +394 -0
- package/bin/runners/lib/doctor/reporter.js +262 -0
- package/bin/runners/lib/doctor/safe-repair.js +384 -0
- package/bin/runners/lib/doctor/service.js +262 -0
- package/bin/runners/lib/doctor/types.js +113 -0
- package/bin/runners/lib/doctor/ui.js +263 -0
- package/bin/runners/lib/doctor-enhanced.js +233 -0
- package/bin/runners/lib/doctor-output.js +226 -0
- package/bin/runners/lib/doctor-v2.js +608 -0
- package/bin/runners/lib/drift.js +425 -0
- package/bin/runners/lib/enforcement.js +72 -0
- package/bin/runners/lib/engine/ast-cache.js +210 -0
- package/bin/runners/lib/engine/auth-extractor.js +211 -0
- package/bin/runners/lib/engine/billing-extractor.js +112 -0
- package/bin/runners/lib/engine/enforcement-extractor.js +100 -0
- package/bin/runners/lib/engine/env-extractor.js +207 -0
- package/bin/runners/lib/engine/express-extractor.js +208 -0
- package/bin/runners/lib/engine/extractors.js +849 -0
- package/bin/runners/lib/engine/index.js +207 -0
- package/bin/runners/lib/engine/repo-index.js +514 -0
- package/bin/runners/lib/engine/types.js +124 -0
- package/bin/runners/lib/engines/accessibility-engine.js +190 -0
- package/bin/runners/lib/engines/api-consistency-engine.js +162 -0
- package/bin/runners/lib/engines/ast-cache.js +99 -0
- package/bin/runners/lib/engines/attack-detector.js +1192 -0
- package/bin/runners/lib/engines/code-quality-engine.js +255 -0
- package/bin/runners/lib/engines/console-logs-engine.js +115 -0
- package/bin/runners/lib/engines/cross-file-analysis-engine.js +268 -0
- package/bin/runners/lib/engines/dead-code-engine.js +198 -0
- package/bin/runners/lib/engines/deprecated-api-engine.js +226 -0
- package/bin/runners/lib/engines/empty-catch-engine.js +150 -0
- package/bin/runners/lib/engines/file-filter.js +131 -0
- package/bin/runners/lib/engines/hardcoded-secrets-engine.js +251 -0
- package/bin/runners/lib/engines/mock-data-engine.js +272 -0
- package/bin/runners/lib/engines/parallel-processor.js +71 -0
- package/bin/runners/lib/engines/performance-issues-engine.js +265 -0
- package/bin/runners/lib/engines/security-vulnerabilities-engine.js +243 -0
- package/bin/runners/lib/engines/todo-fixme-engine.js +115 -0
- package/bin/runners/lib/engines/type-aware-engine.js +152 -0
- package/bin/runners/lib/engines/unsafe-regex-engine.js +225 -0
- package/bin/runners/lib/engines/vibecheck-engines/README.md +53 -0
- package/bin/runners/lib/engines/vibecheck-engines/index.js +15 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/ast-cache.js +164 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/code-quality-engine.js +291 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/console-logs-engine.js +83 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/dead-code-engine.js +198 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/deprecated-api-engine.js +275 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/empty-catch-engine.js +167 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/file-filter.js +217 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/hardcoded-secrets-engine.js +139 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/mock-data-engine.js +140 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/parallel-processor.js +164 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/performance-issues-engine.js +234 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/type-aware-engine.js +217 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/unsafe-regex-engine.js +78 -0
- package/bin/runners/lib/engines/vibecheck-engines/package.json +13 -0
- package/bin/runners/lib/enterprise-detect.js +603 -0
- package/bin/runners/lib/enterprise-init.js +942 -0
- package/bin/runners/lib/entitlements-v2.js +265 -0
- package/bin/runners/lib/entitlements.generated.js +0 -0
- package/bin/runners/lib/entitlements.js +340 -0
- package/bin/runners/lib/env-resolver.js +417 -0
- package/bin/runners/lib/env-template.js +66 -0
- package/bin/runners/lib/env.js +189 -0
- package/bin/runners/lib/error-handler.js +368 -0
- package/bin/runners/lib/error-messages.js +289 -0
- package/bin/runners/lib/evidence-pack.js +684 -0
- package/bin/runners/lib/exit-codes.js +275 -0
- package/bin/runners/lib/extractors/client-calls.js +990 -0
- package/bin/runners/lib/extractors/fastify-route-dump.js +573 -0
- package/bin/runners/lib/extractors/fastify-routes.js +426 -0
- package/bin/runners/lib/extractors/index.js +363 -0
- package/bin/runners/lib/extractors/next-routes.js +524 -0
- package/bin/runners/lib/extractors/proof-graph.js +431 -0
- package/bin/runners/lib/extractors/route-matcher.js +451 -0
- package/bin/runners/lib/extractors/truthpack-v2.js +377 -0
- package/bin/runners/lib/extractors/ui-bindings.js +547 -0
- package/bin/runners/lib/finding-id.js +69 -0
- package/bin/runners/lib/finding-sorter.js +89 -0
- package/bin/runners/lib/findings-schema.js +281 -0
- package/bin/runners/lib/fingerprint.js +377 -0
- package/bin/runners/lib/firewall-prompt.js +50 -0
- package/bin/runners/lib/fix-output.js +228 -0
- package/bin/runners/lib/global-flags.js +250 -0
- package/bin/runners/lib/graph/graph-builder.js +265 -0
- package/bin/runners/lib/graph/html-renderer.js +413 -0
- package/bin/runners/lib/graph/index.js +32 -0
- package/bin/runners/lib/graph/runtime-collector.js +215 -0
- package/bin/runners/lib/graph/static-extractor.js +518 -0
- package/bin/runners/lib/help-formatter.js +413 -0
- package/bin/runners/lib/html-proof-report.js +913 -0
- package/bin/runners/lib/html-report.js +650 -0
- package/bin/runners/lib/init-wizard.js +601 -0
- package/bin/runners/lib/interactive-menu.js +1496 -0
- package/bin/runners/lib/json-output.js +76 -0
- package/bin/runners/lib/llm.js +75 -0
- package/bin/runners/lib/logger.js +38 -0
- package/bin/runners/lib/meter.js +61 -0
- package/bin/runners/lib/missions/briefing.js +427 -0
- package/bin/runners/lib/missions/checkpoint.js +753 -0
- package/bin/runners/lib/missions/evidence.js +126 -0
- package/bin/runners/lib/missions/hardening.js +851 -0
- package/bin/runners/lib/missions/plan.js +648 -0
- package/bin/runners/lib/missions/safety-gates.js +645 -0
- package/bin/runners/lib/missions/schema.js +478 -0
- package/bin/runners/lib/missions/templates.js +317 -0
- package/bin/runners/lib/next-action.js +560 -0
- package/bin/runners/lib/packs/bundle.js +675 -0
- package/bin/runners/lib/packs/evidence-pack.js +671 -0
- package/bin/runners/lib/packs/pack-factory.js +837 -0
- package/bin/runners/lib/packs/permissions-pack.js +686 -0
- package/bin/runners/lib/packs/proof-graph-pack.js +779 -0
- package/bin/runners/lib/patch.js +40 -0
- package/bin/runners/lib/permissions/auth-model.js +213 -0
- package/bin/runners/lib/permissions/idor-prover.js +205 -0
- package/bin/runners/lib/permissions/index.js +45 -0
- package/bin/runners/lib/permissions/matrix-builder.js +198 -0
- package/bin/runners/lib/pkgjson.js +28 -0
- package/bin/runners/lib/policy.js +295 -0
- package/bin/runners/lib/polish/accessibility.js +62 -0
- package/bin/runners/lib/polish/analyzer.js +93 -0
- package/bin/runners/lib/polish/backend.js +87 -0
- package/bin/runners/lib/polish/configuration.js +83 -0
- package/bin/runners/lib/polish/documentation.js +83 -0
- package/bin/runners/lib/polish/frontend.js +817 -0
- package/bin/runners/lib/polish/index.js +27 -0
- package/bin/runners/lib/polish/infrastructure.js +80 -0
- package/bin/runners/lib/polish/internationalization.js +85 -0
- package/bin/runners/lib/polish/libraries.js +180 -0
- package/bin/runners/lib/polish/observability.js +75 -0
- package/bin/runners/lib/polish/performance.js +64 -0
- package/bin/runners/lib/polish/privacy.js +110 -0
- package/bin/runners/lib/polish/resilience.js +92 -0
- package/bin/runners/lib/polish/security.js +78 -0
- package/bin/runners/lib/polish/seo.js +71 -0
- package/bin/runners/lib/polish/styles.js +62 -0
- package/bin/runners/lib/polish/utils.js +104 -0
- package/bin/runners/lib/preflight.js +142 -0
- package/bin/runners/lib/prerequisites.js +149 -0
- package/bin/runners/lib/prove-output.js +220 -0
- package/bin/runners/lib/reality/correlation-detectors.js +359 -0
- package/bin/runners/lib/reality/index.js +318 -0
- package/bin/runners/lib/reality/request-hashing.js +416 -0
- package/bin/runners/lib/reality/request-mapper.js +453 -0
- package/bin/runners/lib/reality/safety-rails.js +463 -0
- package/bin/runners/lib/reality/semantic-snapshot.js +408 -0
- package/bin/runners/lib/reality/toast-detector.js +393 -0
- package/bin/runners/lib/reality-findings.js +84 -0
- package/bin/runners/lib/reality-output.js +231 -0
- package/bin/runners/lib/receipts.js +179 -0
- package/bin/runners/lib/redact.js +29 -0
- package/bin/runners/lib/replay/capsule-manager.js +154 -0
- package/bin/runners/lib/replay/index.js +263 -0
- package/bin/runners/lib/replay/player.js +348 -0
- package/bin/runners/lib/replay/recorder.js +331 -0
- package/bin/runners/lib/report-engine.js +626 -0
- package/bin/runners/lib/report-html.js +1233 -0
- package/bin/runners/lib/report-output.js +366 -0
- package/bin/runners/lib/report-templates.js +967 -0
- package/bin/runners/lib/report.js +135 -0
- package/bin/runners/lib/route-detection.js +1209 -0
- package/bin/runners/lib/route-truth.js +1322 -0
- package/bin/runners/lib/safelist/index.js +96 -0
- package/bin/runners/lib/safelist/integration.js +334 -0
- package/bin/runners/lib/safelist/matcher.js +696 -0
- package/bin/runners/lib/safelist/schema.js +948 -0
- package/bin/runners/lib/safelist/store.js +438 -0
- package/bin/runners/lib/sandbox/index.js +59 -0
- package/bin/runners/lib/sandbox/proof-chain.js +399 -0
- package/bin/runners/lib/sandbox/sandbox-runner.js +205 -0
- package/bin/runners/lib/sandbox/worktree.js +174 -0
- package/bin/runners/lib/scan-cache.js +330 -0
- package/bin/runners/lib/scan-output-schema.js +344 -0
- package/bin/runners/lib/scan-output.js +631 -0
- package/bin/runners/lib/scan-runner.js +135 -0
- package/bin/runners/lib/schema-validator.js +350 -0
- package/bin/runners/lib/schemas/ajv-validator.js +464 -0
- package/bin/runners/lib/schemas/contracts.schema.json +160 -0
- package/bin/runners/lib/schemas/error-envelope.schema.json +105 -0
- package/bin/runners/lib/schemas/finding-v3.schema.json +151 -0
- package/bin/runners/lib/schemas/finding.schema.json +100 -0
- package/bin/runners/lib/schemas/mission-pack.schema.json +206 -0
- package/bin/runners/lib/schemas/proof-graph.schema.json +176 -0
- package/bin/runners/lib/schemas/reality-report.schema.json +162 -0
- package/bin/runners/lib/schemas/report-artifact.schema.json +120 -0
- package/bin/runners/lib/schemas/run-request.schema.json +108 -0
- package/bin/runners/lib/schemas/share-pack.schema.json +180 -0
- package/bin/runners/lib/schemas/ship-manifest.schema.json +251 -0
- package/bin/runners/lib/schemas/ship-report.schema.json +117 -0
- package/bin/runners/lib/schemas/truthpack-v2.schema.json +303 -0
- package/bin/runners/lib/schemas/validator.js +465 -0
- package/bin/runners/lib/schemas/verdict.schema.json +140 -0
- package/bin/runners/lib/score-history.js +282 -0
- package/bin/runners/lib/security-bridge.js +249 -0
- package/bin/runners/lib/server-usage.js +513 -0
- package/bin/runners/lib/share-pack.js +239 -0
- package/bin/runners/lib/ship-gate.js +832 -0
- package/bin/runners/lib/ship-manifest.js +1153 -0
- package/bin/runners/lib/ship-output-enterprise.js +239 -0
- package/bin/runners/lib/ship-output.js +1128 -0
- package/bin/runners/lib/snippets.js +67 -0
- package/bin/runners/lib/status-output.js +340 -0
- package/bin/runners/lib/terminal-ui.js +356 -0
- package/bin/runners/lib/truth.js +1691 -0
- package/bin/runners/lib/ui.js +562 -0
- package/bin/runners/lib/unified-cli-output.js +947 -0
- package/bin/runners/lib/unified-output.js +197 -0
- package/bin/runners/lib/upsell.js +410 -0
- package/bin/runners/lib/usage.js +153 -0
- package/bin/runners/lib/validate-patch.js +156 -0
- package/bin/runners/lib/verdict-engine.js +628 -0
- package/bin/runners/lib/verification.js +345 -0
- package/bin/runners/lib/why-tree.js +650 -0
- package/bin/runners/reality/engine.js +917 -0
- package/bin/runners/reality/flows.js +122 -0
- package/bin/runners/reality/report.js +378 -0
- package/bin/runners/reality/session.js +193 -0
- package/bin/runners/runAIAgent.js +229 -0
- package/bin/runners/runAgent.d.ts +5 -0
- package/bin/runners/runAgent.js +161 -0
- package/bin/runners/runAllowlist.js +418 -0
- package/bin/runners/runApprove.js +320 -0
- package/bin/runners/runAudit.js +692 -0
- package/bin/runners/runAuth.js +731 -0
- package/bin/runners/runCI.js +353 -0
- package/bin/runners/runCheckpoint.js +530 -0
- package/bin/runners/runClassify.js +928 -0
- package/bin/runners/runCleanup.js +343 -0
- package/bin/runners/runContext.d.ts +4 -0
- package/bin/runners/runContext.js +175 -0
- package/bin/runners/runDoctor.js +877 -0
- package/bin/runners/runEvidencePack.js +362 -0
- package/bin/runners/runFirewall.d.ts +5 -0
- package/bin/runners/runFirewall.js +134 -0
- package/bin/runners/runFirewallHook.d.ts +5 -0
- package/bin/runners/runFirewallHook.js +56 -0
- package/bin/runners/runFix.js +1355 -0
- package/bin/runners/runForge.js +451 -0
- package/bin/runners/runGuard.js +262 -0
- package/bin/runners/runInit.js +1927 -0
- package/bin/runners/runIntent.js +906 -0
- package/bin/runners/runKickoff.js +878 -0
- package/bin/runners/runLabs.js +424 -0
- package/bin/runners/runLaunch.js +2000 -0
- package/bin/runners/runLink.js +785 -0
- package/bin/runners/runMcp.js +1875 -0
- package/bin/runners/runPacks.js +2089 -0
- package/bin/runners/runPolish.d.ts +4 -0
- package/bin/runners/runPolish.js +390 -0
- package/bin/runners/runPromptFirewall.js +211 -0
- package/bin/runners/runProve.js +1411 -0
- package/bin/runners/runQuickstart.js +531 -0
- package/bin/runners/runReality.js +2260 -0
- package/bin/runners/runReport.js +726 -0
- package/bin/runners/runRuntime.js +110 -0
- package/bin/runners/runSafelist.js +1190 -0
- package/bin/runners/runScan.js +688 -0
- package/bin/runners/runShield.js +1282 -0
- package/bin/runners/runShip.js +1660 -0
- package/bin/runners/runTruth.d.ts +5 -0
- package/bin/runners/runTruth.js +101 -0
- package/bin/runners/runValidate.js +179 -0
- package/bin/runners/runWatch.js +478 -0
- package/bin/runners/utils.js +360 -0
- package/bin/scan.js +617 -0
- package/bin/vibecheck.js +1617 -0
- package/dist/guardrail/index.d.ts +2405 -0
- package/dist/guardrail/index.js +9747 -0
- package/dist/guardrail/index.js.map +1 -0
- package/dist/scanner/index.d.ts +282 -0
- package/dist/scanner/index.js +3395 -0
- package/dist/scanner/index.js.map +1 -0
- package/package.json +123 -104
- package/README.md +0 -491
- package/dist/index.js +0 -99711
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intent Alignment Engine - Core Enforcement Logic
|
|
3
|
+
*
|
|
4
|
+
* ═══════════════════════════════════════════════════════════════════════════════
|
|
5
|
+
* AGENT FIREWALL™ - INTENT ALIGNMENT ENGINE
|
|
6
|
+
* ═══════════════════════════════════════════════════════════════════════════════
|
|
7
|
+
*
|
|
8
|
+
* For every Change Event:
|
|
9
|
+
* - Compare change against declared intent
|
|
10
|
+
* - Enforce STRICT matching rules
|
|
11
|
+
* - BLOCK if intent is violated
|
|
12
|
+
*
|
|
13
|
+
* This is NOT advisory. This is enforcement.
|
|
14
|
+
*
|
|
15
|
+
* @module intent/alignment-engine
|
|
16
|
+
* @version 2.0.0
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
const path = require("path");
|
|
22
|
+
|
|
23
|
+
// Try to load minimatch, fallback to simple pattern matching if not available
|
|
24
|
+
let minimatch = null;
|
|
25
|
+
try {
|
|
26
|
+
minimatch = require("minimatch").minimatch;
|
|
27
|
+
} catch {
|
|
28
|
+
// minimatch not available, will use fallback
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Violation codes for machine-readable errors
|
|
33
|
+
*/
|
|
34
|
+
const VIOLATION_CODES = {
|
|
35
|
+
NO_INTENT: "NO_INTENT_DECLARED",
|
|
36
|
+
INTENT_EXPIRED: "INTENT_EXPIRED",
|
|
37
|
+
INTENT_CORRUPTED: "INTENT_INTEGRITY_FAILED",
|
|
38
|
+
UNDECLARED_ROUTE: "UNDECLARED_ROUTE",
|
|
39
|
+
UNDECLARED_ENV: "UNDECLARED_ENV_VAR",
|
|
40
|
+
UNDECLARED_FILE: "UNDECLARED_FILE_CHANGE",
|
|
41
|
+
CONSTRAINT_VIOLATED: "CONSTRAINT_VIOLATED",
|
|
42
|
+
SCOPE_VIOLATION: "SCOPE_VIOLATION",
|
|
43
|
+
DOMAIN_VIOLATION: "DOMAIN_NOT_ALLOWED",
|
|
44
|
+
PERMISSION_CHANGE: "UNAUTHORIZED_PERMISSION_CHANGE",
|
|
45
|
+
AUTH_MODIFICATION: "UNAUTHORIZED_AUTH_MODIFICATION",
|
|
46
|
+
PAYMENT_MODIFICATION: "UNAUTHORIZED_PAYMENT_MODIFICATION",
|
|
47
|
+
MOCK_DATA_DETECTED: "MOCK_DATA_IN_PRODUCTION_CODE",
|
|
48
|
+
TODO_DETECTED: "UNRESOLVED_TODO_PLACEHOLDER",
|
|
49
|
+
FAKE_HANDLER: "FAKE_HANDLER_DETECTED",
|
|
50
|
+
UI_WITHOUT_BACKEND: "UI_SUCCESS_WITHOUT_BACKEND_PROOF",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Alignment Check Result
|
|
55
|
+
* @typedef {Object} AlignmentResult
|
|
56
|
+
* @property {boolean} aligned - Whether change is aligned with intent
|
|
57
|
+
* @property {string} decision - PASS or BLOCK
|
|
58
|
+
* @property {Object[]} violations - Array of violations
|
|
59
|
+
* @property {string} intent_hash - Hash of intent used for checking
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Violation object structure
|
|
64
|
+
* @typedef {Object} Violation
|
|
65
|
+
* @property {string} code - Machine-readable violation code
|
|
66
|
+
* @property {string} rule - Human-readable rule name
|
|
67
|
+
* @property {string} message - Detailed violation message
|
|
68
|
+
* @property {string} resource - Resource that caused violation
|
|
69
|
+
* @property {string} intent_ref - Reference to violated intent element
|
|
70
|
+
* @property {string} severity - Always "block" for violations
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Check if a path matches any allowed pattern
|
|
75
|
+
* @param {string} filePath - Path to check
|
|
76
|
+
* @param {Object[]} allowed_changes - Allowed changes from intent
|
|
77
|
+
* @returns {boolean} True if allowed
|
|
78
|
+
*/
|
|
79
|
+
function isFileChangeAllowed(filePath, allowed_changes = []) {
|
|
80
|
+
const normalizedPath = filePath.replace(/\\/g, "/");
|
|
81
|
+
|
|
82
|
+
for (const allowed of allowed_changes) {
|
|
83
|
+
if (allowed.type === "file_create" || allowed.type === "file_modify" || allowed.type === "file_delete") {
|
|
84
|
+
// Check exact target match
|
|
85
|
+
if (allowed.target && allowed.target.replace(/\\/g, "/") === normalizedPath) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Check pattern match
|
|
90
|
+
if (allowed.pattern) {
|
|
91
|
+
try {
|
|
92
|
+
// Use minimatch if available, otherwise simple glob
|
|
93
|
+
if (typeof minimatch === "function") {
|
|
94
|
+
if (minimatch(normalizedPath, allowed.pattern, { matchBase: true })) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
// Simple pattern matching fallback using placeholders
|
|
99
|
+
// Use placeholders to avoid escaping issues
|
|
100
|
+
const regex = new RegExp(
|
|
101
|
+
"^" + allowed.pattern
|
|
102
|
+
.replace(/\*\*\//g, "{{DIRSTAR}}") // Placeholder for **/
|
|
103
|
+
.replace(/\*\*/g, "{{GLOBSTAR}}") // Placeholder for **
|
|
104
|
+
.replace(/\?/g, "{{QMARK}}") // Placeholder for ?
|
|
105
|
+
.replace(/\./g, "\\.") // Escape dots
|
|
106
|
+
.replace(/\*/g, "[^/]*") // * matches anything except /
|
|
107
|
+
.replace(/{{DIRSTAR}}/g, "(?:.*/)?") // **/ matches zero or more dirs
|
|
108
|
+
.replace(/{{GLOBSTAR}}/g, ".*") // ** matches anything
|
|
109
|
+
.replace(/{{QMARK}}/g, ".") + "$" // ? matches single char
|
|
110
|
+
);
|
|
111
|
+
if (regex.test(normalizedPath)) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} catch {
|
|
116
|
+
// Skip invalid patterns
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Check if a route is allowed by intent
|
|
127
|
+
* @param {string} method - HTTP method
|
|
128
|
+
* @param {string} routePath - Route path
|
|
129
|
+
* @param {Object[]} allowed_changes - Allowed changes from intent
|
|
130
|
+
* @returns {boolean} True if allowed
|
|
131
|
+
*/
|
|
132
|
+
function isRouteAllowed(method, routePath, allowed_changes = []) {
|
|
133
|
+
for (const allowed of allowed_changes) {
|
|
134
|
+
if (allowed.type === "route_add" || allowed.type === "route_modify") {
|
|
135
|
+
// Check exact match
|
|
136
|
+
if (allowed.target === routePath) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Check pattern match (e.g., /api/users/*)
|
|
141
|
+
if (allowed.pattern) {
|
|
142
|
+
try {
|
|
143
|
+
const regex = new RegExp(
|
|
144
|
+
"^" + allowed.pattern
|
|
145
|
+
.replace(/\*/g, "[^/]+")
|
|
146
|
+
.replace(/\*\*/g, ".*") + "$"
|
|
147
|
+
);
|
|
148
|
+
if (regex.test(routePath)) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
} catch {
|
|
152
|
+
// Skip invalid patterns
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Check if env var addition is allowed by intent
|
|
163
|
+
* @param {string} envVar - Environment variable name
|
|
164
|
+
* @param {Object[]} allowed_changes - Allowed changes from intent
|
|
165
|
+
* @returns {boolean} True if allowed
|
|
166
|
+
*/
|
|
167
|
+
function isEnvVarAllowed(envVar, allowed_changes = []) {
|
|
168
|
+
for (const allowed of allowed_changes) {
|
|
169
|
+
if (allowed.type === "env_add") {
|
|
170
|
+
if (allowed.target === envVar) {
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
// Pattern match (e.g., STRIPE_*)
|
|
174
|
+
if (allowed.pattern) {
|
|
175
|
+
try {
|
|
176
|
+
const regex = new RegExp("^" + allowed.pattern.replace(/\*/g, ".*") + "$");
|
|
177
|
+
if (regex.test(envVar)) {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
} catch {
|
|
181
|
+
// Skip invalid patterns
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Check if path is within allowed scope
|
|
192
|
+
* @param {string} filePath - File path to check
|
|
193
|
+
* @param {Object} scope - Intent scope restrictions
|
|
194
|
+
* @returns {boolean} True if within scope
|
|
195
|
+
*/
|
|
196
|
+
function isWithinScope(filePath, scope) {
|
|
197
|
+
if (!scope) return true; // No scope = everything allowed
|
|
198
|
+
|
|
199
|
+
const normalizedPath = filePath.replace(/\\/g, "/");
|
|
200
|
+
|
|
201
|
+
// Check excluded paths first
|
|
202
|
+
if (scope.excluded_paths) {
|
|
203
|
+
for (const excluded of scope.excluded_paths) {
|
|
204
|
+
const normalizedExcluded = excluded.replace(/\\/g, "/");
|
|
205
|
+
if (normalizedPath.startsWith(normalizedExcluded) || normalizedPath === normalizedExcluded) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Check directory restrictions
|
|
212
|
+
if (scope.directories && scope.directories.length > 0) {
|
|
213
|
+
const inAllowedDir = scope.directories.some(dir => {
|
|
214
|
+
const normalizedDir = dir.replace(/\\/g, "/");
|
|
215
|
+
return normalizedPath.startsWith(normalizedDir);
|
|
216
|
+
});
|
|
217
|
+
if (!inAllowedDir) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Check file pattern restrictions
|
|
223
|
+
if (scope.file_patterns && scope.file_patterns.length > 0) {
|
|
224
|
+
const matchesPattern = scope.file_patterns.some(pattern => {
|
|
225
|
+
try {
|
|
226
|
+
if (typeof minimatch === "function") {
|
|
227
|
+
return minimatch(normalizedPath, pattern, { matchBase: true });
|
|
228
|
+
}
|
|
229
|
+
const regex = new RegExp(
|
|
230
|
+
"^" + pattern
|
|
231
|
+
.replace(/\*\*/g, "{{GLOBSTAR}}")
|
|
232
|
+
.replace(/\*/g, "[^/]*")
|
|
233
|
+
.replace(/{{GLOBSTAR}}/g, ".*") + "$"
|
|
234
|
+
);
|
|
235
|
+
return regex.test(normalizedPath);
|
|
236
|
+
} catch {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
if (!matchesPattern) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Check if domain is allowed by intent
|
|
250
|
+
* @param {string} domain - Domain classification
|
|
251
|
+
* @param {Object} scope - Intent scope restrictions
|
|
252
|
+
* @returns {boolean} True if allowed
|
|
253
|
+
*/
|
|
254
|
+
function isDomainAllowed(domain, scope) {
|
|
255
|
+
if (!scope || !scope.domains || scope.domains.length === 0) {
|
|
256
|
+
return true; // No domain restrictions
|
|
257
|
+
}
|
|
258
|
+
return scope.domains.includes(domain);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Check constraint violations
|
|
263
|
+
* @param {string[]} constraints - Intent constraints
|
|
264
|
+
* @param {Object} changeEvent - Change event to check
|
|
265
|
+
* @returns {Object[]} Array of constraint violations
|
|
266
|
+
*/
|
|
267
|
+
function checkConstraintViolations(constraints, changeEvent) {
|
|
268
|
+
const violations = [];
|
|
269
|
+
|
|
270
|
+
for (let i = 0; i < constraints.length; i++) {
|
|
271
|
+
const constraint = constraints[i].toLowerCase();
|
|
272
|
+
|
|
273
|
+
// No new routes
|
|
274
|
+
if (constraint.includes("no new routes") || constraint.includes("no_new_routes")) {
|
|
275
|
+
if (changeEvent.type === "route_add" ||
|
|
276
|
+
(changeEvent.claims && changeEvent.claims.some(c => c.type === "route"))) {
|
|
277
|
+
violations.push({
|
|
278
|
+
code: VIOLATION_CODES.CONSTRAINT_VIOLATED,
|
|
279
|
+
rule: "constraint_no_new_routes",
|
|
280
|
+
message: "New route addition blocked by constraint",
|
|
281
|
+
resource: changeEvent.location,
|
|
282
|
+
intent_ref: `constraints[${i}]`,
|
|
283
|
+
severity: "block",
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// No auth changes
|
|
289
|
+
if (constraint.includes("no auth") || constraint.includes("no_auth_changes")) {
|
|
290
|
+
if (changeEvent.domain === "auth" ||
|
|
291
|
+
(changeEvent.claims && changeEvent.claims.some(c => c.type === "auth_boundary"))) {
|
|
292
|
+
violations.push({
|
|
293
|
+
code: VIOLATION_CODES.AUTH_MODIFICATION,
|
|
294
|
+
rule: "constraint_no_auth_changes",
|
|
295
|
+
message: "Auth modification blocked by constraint",
|
|
296
|
+
resource: changeEvent.location,
|
|
297
|
+
intent_ref: `constraints[${i}]`,
|
|
298
|
+
severity: "block",
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// No new environment variables
|
|
304
|
+
if (constraint.includes("no new env") || constraint.includes("no_env_additions")) {
|
|
305
|
+
if (changeEvent.type === "env_ref" && !changeEvent.env_exists) {
|
|
306
|
+
violations.push({
|
|
307
|
+
code: VIOLATION_CODES.UNDECLARED_ENV,
|
|
308
|
+
rule: "constraint_no_env_additions",
|
|
309
|
+
message: `New env var '${changeEvent.resource}' blocked by constraint`,
|
|
310
|
+
resource: changeEvent.resource,
|
|
311
|
+
intent_ref: `constraints[${i}]`,
|
|
312
|
+
severity: "block",
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// No payment changes
|
|
318
|
+
if (constraint.includes("no payment") || constraint.includes("no_payment_changes")) {
|
|
319
|
+
if (changeEvent.domain === "payments") {
|
|
320
|
+
violations.push({
|
|
321
|
+
code: VIOLATION_CODES.PAYMENT_MODIFICATION,
|
|
322
|
+
rule: "constraint_no_payment_changes",
|
|
323
|
+
message: "Payment code modification blocked by constraint",
|
|
324
|
+
resource: changeEvent.location,
|
|
325
|
+
intent_ref: `constraints[${i}]`,
|
|
326
|
+
severity: "block",
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Tests required
|
|
332
|
+
if (constraint.includes("tests required") || constraint.includes("tests_required")) {
|
|
333
|
+
if (!changeEvent.includes_tests) {
|
|
334
|
+
violations.push({
|
|
335
|
+
code: VIOLATION_CODES.CONSTRAINT_VIOLATED,
|
|
336
|
+
rule: "constraint_tests_required",
|
|
337
|
+
message: "Tests required by constraint but none provided",
|
|
338
|
+
resource: changeEvent.location,
|
|
339
|
+
intent_ref: `constraints[${i}]`,
|
|
340
|
+
severity: "block",
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Single file only
|
|
346
|
+
if (constraint.includes("single file") || constraint.includes("single_file_only")) {
|
|
347
|
+
if (changeEvent.file_count > 1) {
|
|
348
|
+
violations.push({
|
|
349
|
+
code: VIOLATION_CODES.CONSTRAINT_VIOLATED,
|
|
350
|
+
rule: "constraint_single_file",
|
|
351
|
+
message: `Multiple files (${changeEvent.file_count}) modified but constraint requires single file`,
|
|
352
|
+
resource: changeEvent.location,
|
|
353
|
+
intent_ref: `constraints[${i}]`,
|
|
354
|
+
severity: "block",
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return violations;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Detect code quality violations (mock data, TODOs, fake handlers)
|
|
365
|
+
* @param {Object} changeEvent - Change event with diff
|
|
366
|
+
* @returns {Object[]} Array of violations
|
|
367
|
+
*/
|
|
368
|
+
function detectCodeQualityViolations(changeEvent) {
|
|
369
|
+
const violations = [];
|
|
370
|
+
const content = changeEvent.diff?.after || changeEvent.content || "";
|
|
371
|
+
|
|
372
|
+
// Mock data detection
|
|
373
|
+
const mockPatterns = [
|
|
374
|
+
/mock\s*data/i,
|
|
375
|
+
/fake\s*response/i,
|
|
376
|
+
/stub\s*data/i,
|
|
377
|
+
/dummy\s*data/i,
|
|
378
|
+
/\[\s*"test"\s*,\s*"data"\s*\]/,
|
|
379
|
+
/return\s+\{\s*success:\s*true\s*\}/,
|
|
380
|
+
/setTimeout\s*\(\s*\(\)\s*=>\s*\{[^}]*success/i,
|
|
381
|
+
];
|
|
382
|
+
|
|
383
|
+
for (const pattern of mockPatterns) {
|
|
384
|
+
if (pattern.test(content)) {
|
|
385
|
+
violations.push({
|
|
386
|
+
code: VIOLATION_CODES.MOCK_DATA_DETECTED,
|
|
387
|
+
rule: "no_mock_data",
|
|
388
|
+
message: "Mock/fake data detected in production code",
|
|
389
|
+
resource: changeEvent.location,
|
|
390
|
+
intent_ref: "enforcement_rule",
|
|
391
|
+
severity: "block",
|
|
392
|
+
});
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// TODO/FIXME detection
|
|
398
|
+
const todoPattern = /\b(TODO|FIXME|XXX|HACK|BUG)[\s:]/i;
|
|
399
|
+
if (todoPattern.test(content)) {
|
|
400
|
+
violations.push({
|
|
401
|
+
code: VIOLATION_CODES.TODO_DETECTED,
|
|
402
|
+
rule: "no_todos",
|
|
403
|
+
message: "Unresolved TODO/FIXME comment detected",
|
|
404
|
+
resource: changeEvent.location,
|
|
405
|
+
intent_ref: "enforcement_rule",
|
|
406
|
+
severity: "block",
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Fake handler detection
|
|
411
|
+
const fakeHandlerPatterns = [
|
|
412
|
+
/async\s+function\s+\w+\s*\([^)]*\)\s*\{\s*\}/,
|
|
413
|
+
/const\s+\w+\s*=\s*async\s*\([^)]*\)\s*=>\s*\{\s*\}/,
|
|
414
|
+
/\w+Handler\s*=\s*\(\)\s*=>\s*\{\s*\}/,
|
|
415
|
+
/notImplemented/i,
|
|
416
|
+
/throw\s+new\s+Error\s*\(\s*["']not\s+implemented/i,
|
|
417
|
+
];
|
|
418
|
+
|
|
419
|
+
for (const pattern of fakeHandlerPatterns) {
|
|
420
|
+
if (pattern.test(content)) {
|
|
421
|
+
violations.push({
|
|
422
|
+
code: VIOLATION_CODES.FAKE_HANDLER,
|
|
423
|
+
rule: "no_fake_handlers",
|
|
424
|
+
message: "Empty or placeholder handler detected",
|
|
425
|
+
resource: changeEvent.location,
|
|
426
|
+
intent_ref: "enforcement_rule",
|
|
427
|
+
severity: "block",
|
|
428
|
+
});
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return violations;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Main alignment check function
|
|
438
|
+
*
|
|
439
|
+
* @param {Object} intent - Declared intent
|
|
440
|
+
* @param {Object} changeEvent - Normalized change event
|
|
441
|
+
* @returns {AlignmentResult} Alignment result
|
|
442
|
+
*/
|
|
443
|
+
function checkAlignment(intent, changeEvent) {
|
|
444
|
+
const violations = [];
|
|
445
|
+
|
|
446
|
+
// BLOCK if no intent
|
|
447
|
+
if (!intent) {
|
|
448
|
+
return {
|
|
449
|
+
aligned: false,
|
|
450
|
+
decision: "BLOCK",
|
|
451
|
+
violations: [{
|
|
452
|
+
code: VIOLATION_CODES.NO_INTENT,
|
|
453
|
+
rule: "intent_required",
|
|
454
|
+
message: "No intent declared - all changes blocked by default",
|
|
455
|
+
resource: changeEvent.location || "unknown",
|
|
456
|
+
intent_ref: "system",
|
|
457
|
+
severity: "block",
|
|
458
|
+
}],
|
|
459
|
+
intent_hash: null,
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// Check intent is the blocking intent
|
|
464
|
+
if (intent.summary?.includes("NO INTENT DECLARED")) {
|
|
465
|
+
return {
|
|
466
|
+
aligned: false,
|
|
467
|
+
decision: "BLOCK",
|
|
468
|
+
violations: [{
|
|
469
|
+
code: VIOLATION_CODES.NO_INTENT,
|
|
470
|
+
rule: "intent_required",
|
|
471
|
+
message: "No intent declared - all changes blocked by default",
|
|
472
|
+
resource: changeEvent.location || "unknown",
|
|
473
|
+
intent_ref: "system",
|
|
474
|
+
severity: "block",
|
|
475
|
+
}],
|
|
476
|
+
intent_hash: intent.hash,
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// 1. Check file changes against allowed_changes
|
|
481
|
+
if (changeEvent.type === "file_write" || changeEvent.type === "file_create" || changeEvent.type === "file_modify") {
|
|
482
|
+
if (intent.allowed_changes && intent.allowed_changes.length > 0) {
|
|
483
|
+
if (!isFileChangeAllowed(changeEvent.location, intent.allowed_changes)) {
|
|
484
|
+
violations.push({
|
|
485
|
+
code: VIOLATION_CODES.UNDECLARED_FILE,
|
|
486
|
+
rule: "file_change_not_declared",
|
|
487
|
+
message: `File change not declared in intent: ${changeEvent.location}`,
|
|
488
|
+
resource: changeEvent.location,
|
|
489
|
+
intent_ref: "allowed_changes",
|
|
490
|
+
severity: "block",
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// 2. Check routes against allowed_changes
|
|
497
|
+
if (changeEvent.type === "route_add") {
|
|
498
|
+
if (!isRouteAllowed(changeEvent.method, changeEvent.resource, intent.allowed_changes)) {
|
|
499
|
+
violations.push({
|
|
500
|
+
code: VIOLATION_CODES.UNDECLARED_ROUTE,
|
|
501
|
+
rule: "route_not_declared",
|
|
502
|
+
message: `Route not declared in intent: ${changeEvent.method || "?"} ${changeEvent.resource}`,
|
|
503
|
+
resource: changeEvent.resource,
|
|
504
|
+
intent_ref: "allowed_changes",
|
|
505
|
+
severity: "block",
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// 3. Check env vars against allowed_changes
|
|
511
|
+
if (changeEvent.type === "env_ref" && !changeEvent.env_exists) {
|
|
512
|
+
if (!isEnvVarAllowed(changeEvent.resource, intent.allowed_changes)) {
|
|
513
|
+
violations.push({
|
|
514
|
+
code: VIOLATION_CODES.UNDECLARED_ENV,
|
|
515
|
+
rule: "env_var_not_declared",
|
|
516
|
+
message: `Environment variable not declared in intent or missing: ${changeEvent.resource}`,
|
|
517
|
+
resource: changeEvent.resource,
|
|
518
|
+
intent_ref: "allowed_changes",
|
|
519
|
+
severity: "block",
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// 4. Check scope restrictions
|
|
525
|
+
if (intent.scope && changeEvent.location) {
|
|
526
|
+
if (!isWithinScope(changeEvent.location, intent.scope)) {
|
|
527
|
+
violations.push({
|
|
528
|
+
code: VIOLATION_CODES.SCOPE_VIOLATION,
|
|
529
|
+
rule: "scope_violation",
|
|
530
|
+
message: `Change outside allowed scope: ${changeEvent.location}`,
|
|
531
|
+
resource: changeEvent.location,
|
|
532
|
+
intent_ref: "scope",
|
|
533
|
+
severity: "block",
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// 5. Check domain restrictions
|
|
539
|
+
if (intent.scope && changeEvent.domain) {
|
|
540
|
+
if (!isDomainAllowed(changeEvent.domain, intent.scope)) {
|
|
541
|
+
violations.push({
|
|
542
|
+
code: VIOLATION_CODES.DOMAIN_VIOLATION,
|
|
543
|
+
rule: "domain_not_allowed",
|
|
544
|
+
message: `Domain '${changeEvent.domain}' not allowed by intent`,
|
|
545
|
+
resource: changeEvent.location,
|
|
546
|
+
intent_ref: "scope.domains",
|
|
547
|
+
severity: "block",
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// 6. Check constraints
|
|
553
|
+
if (intent.constraints && intent.constraints.length > 0) {
|
|
554
|
+
const constraintViolations = checkConstraintViolations(intent.constraints, changeEvent);
|
|
555
|
+
violations.push(...constraintViolations);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// 7. Check code quality (mock data, TODOs, fake handlers)
|
|
559
|
+
const qualityViolations = detectCodeQualityViolations(changeEvent);
|
|
560
|
+
violations.push(...qualityViolations);
|
|
561
|
+
|
|
562
|
+
// 8. Check UI success without backend proof
|
|
563
|
+
if (changeEvent.claims) {
|
|
564
|
+
const uiSuccessClaims = changeEvent.claims.filter(c => c.type === "ui_success_claim");
|
|
565
|
+
for (const claim of uiSuccessClaims) {
|
|
566
|
+
if (!claim.backend_verified) {
|
|
567
|
+
violations.push({
|
|
568
|
+
code: VIOLATION_CODES.UI_WITHOUT_BACKEND,
|
|
569
|
+
rule: "ui_success_requires_proof",
|
|
570
|
+
message: `UI success state without backend proof: ${claim.value || claim.pointer}`,
|
|
571
|
+
resource: claim.file || changeEvent.location,
|
|
572
|
+
intent_ref: "enforcement_rule",
|
|
573
|
+
severity: "block",
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// Final decision
|
|
580
|
+
const aligned = violations.length === 0;
|
|
581
|
+
|
|
582
|
+
return {
|
|
583
|
+
aligned,
|
|
584
|
+
decision: aligned ? "PASS" : "BLOCK",
|
|
585
|
+
violations,
|
|
586
|
+
intent_hash: intent.hash,
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Batch alignment check for multiple change events
|
|
592
|
+
* @param {Object} intent - Declared intent
|
|
593
|
+
* @param {Object[]} changeEvents - Array of change events
|
|
594
|
+
* @returns {AlignmentResult} Aggregated alignment result
|
|
595
|
+
*/
|
|
596
|
+
function checkAlignmentBatch(intent, changeEvents) {
|
|
597
|
+
const allViolations = [];
|
|
598
|
+
|
|
599
|
+
for (const event of changeEvents) {
|
|
600
|
+
const result = checkAlignment(intent, event);
|
|
601
|
+
allViolations.push(...result.violations);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// De-duplicate violations by code + resource
|
|
605
|
+
const seen = new Set();
|
|
606
|
+
const uniqueViolations = allViolations.filter(v => {
|
|
607
|
+
const key = `${v.code}:${v.resource}`;
|
|
608
|
+
if (seen.has(key)) return false;
|
|
609
|
+
seen.add(key);
|
|
610
|
+
return true;
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
const aligned = uniqueViolations.length === 0;
|
|
614
|
+
|
|
615
|
+
return {
|
|
616
|
+
aligned,
|
|
617
|
+
decision: aligned ? "PASS" : "BLOCK",
|
|
618
|
+
violations: uniqueViolations,
|
|
619
|
+
intent_hash: intent?.hash || null,
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
module.exports = {
|
|
624
|
+
checkAlignment,
|
|
625
|
+
checkAlignmentBatch,
|
|
626
|
+
isFileChangeAllowed,
|
|
627
|
+
isRouteAllowed,
|
|
628
|
+
isEnvVarAllowed,
|
|
629
|
+
isWithinScope,
|
|
630
|
+
isDomainAllowed,
|
|
631
|
+
checkConstraintViolations,
|
|
632
|
+
detectCodeQualityViolations,
|
|
633
|
+
VIOLATION_CODES,
|
|
634
|
+
};
|