@lunora/advisor 1.0.0-alpha.292 → 1.0.0-alpha.294

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.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.mts +53 -2
  3. package/dist/index.d.ts +53 -2
  4. package/dist/index.mjs +1 -1
  5. package/dist/packem_shared/MAP_VERSION-BdyirFdd.mjs +1 -0
  6. package/dist/packem_shared/commitOrderedHardDelete-dmDVELQ0.mjs +1 -0
  7. package/dist/packem_shared/{compareToBaseline-CUG59IOy.mjs → compareToBaseline-CbHQTuNW.mjs} +1 -1
  8. package/dist/packem_shared/crossModuleTableWrite-DuIFwf3x.mjs +1 -0
  9. package/dist/packem_shared/duplicateIndex-DkuQfUJ7.mjs +1 -0
  10. package/dist/packem_shared/emptyIndex-CeS4ZF5O.mjs +1 -0
  11. package/dist/packem_shared/externalSourceIncrementalNoDeletePath-DrcLlb76.mjs +1 -0
  12. package/dist/packem_shared/externalSourceOnGlobal-WQbJ74fq.mjs +1 -0
  13. package/dist/packem_shared/geoIndexFieldNotGeopoint-DcFi2zOK.mjs +1 -0
  14. package/dist/packem_shared/geoIndexUnused-DgVtk2z_.mjs +1 -0
  15. package/dist/packem_shared/globalTableNearColumnLimit-CTvIcQ5e.mjs +1 -0
  16. package/dist/packem_shared/indexReferencesUnknownField-Bs2DiZqb.mjs +1 -0
  17. package/dist/packem_shared/maskUncoveredPiiColumn-BJ1prEd0.mjs +1 -0
  18. package/dist/packem_shared/{maskWeakHashStrategyOnPii-CwgAXFSx.mjs → maskWeakHashStrategyOnPii-dQPsGXl0.mjs} +1 -1
  19. package/dist/packem_shared/{plaintextSecretInWranglerVariables-bNkqmNqV.mjs → plaintextSecretInWranglerVariables-Bs1RvhjG.mjs} +1 -1
  20. package/dist/packem_shared/publicTableRlsOptoutConfusion-DMqePR7i.mjs +1 -0
  21. package/dist/packem_shared/relationReferencesUnknownField-Cb9BSxHl.mjs +1 -0
  22. package/dist/packem_shared/relationReferencesUnknownTable-COkvw71e.mjs +1 -0
  23. package/dist/packem_shared/tableWithoutInsert-CgQyPF1P.mjs +1 -0
  24. package/dist/packem_shared/throughRelationMissingUniqueIndex-DfVfPdjK.mjs +1 -0
  25. package/dist/packem_shared/topicTooManySubscriptions-B1SiGfHM.mjs +1 -0
  26. package/dist/packem_shared/ttlFieldNotTimestamp-BM9uNTT8.mjs +1 -0
  27. package/dist/packem_shared/unindexedForeignKey-ClyKvTnR.mjs +1 -0
  28. package/dist/packem_shared/unindexedRelationTarget-C2t48b-z.mjs +1 -0
  29. package/package.json +1 -1
  30. package/dist/packem_shared/MAP_VERSION-MQ5W2B6n.mjs +0 -1
  31. package/dist/packem_shared/commitOrderedHardDelete-BPdwOKA7.mjs +0 -1
  32. package/dist/packem_shared/crossModuleTableWrite-DjiVTAwK.mjs +0 -1
  33. package/dist/packem_shared/duplicateIndex-BJI90Cnj.mjs +0 -1
  34. package/dist/packem_shared/emptyIndex-BnHDcXza.mjs +0 -1
  35. package/dist/packem_shared/externalSourceIncrementalNoDeletePath-BCzm3HzF.mjs +0 -1
  36. package/dist/packem_shared/externalSourceOnGlobal-CH7xbJ49.mjs +0 -1
  37. package/dist/packem_shared/geoIndexFieldNotGeopoint-Cx_9INob.mjs +0 -1
  38. package/dist/packem_shared/geoIndexUnused-D7C9Qr4U.mjs +0 -1
  39. package/dist/packem_shared/globalTableNearColumnLimit-BFbBBd6A.mjs +0 -1
  40. package/dist/packem_shared/indexReferencesUnknownField-CV8STvk0.mjs +0 -1
  41. package/dist/packem_shared/maskUncoveredPiiColumn-axEka4nd.mjs +0 -1
  42. package/dist/packem_shared/publicTableRlsOptoutConfusion-W_jAkKFR.mjs +0 -1
  43. package/dist/packem_shared/relationReferencesUnknownField-hVsgaUKy.mjs +0 -1
  44. package/dist/packem_shared/relationReferencesUnknownTable-vYjirSxf.mjs +0 -1
  45. package/dist/packem_shared/tableWithoutInsert-DrDVc5Do.mjs +0 -1
  46. package/dist/packem_shared/throughRelationMissingUniqueIndex-Cg5e3GkS.mjs +0 -1
  47. package/dist/packem_shared/topicTooManySubscriptions-CiZhFm9r.mjs +0 -1
  48. package/dist/packem_shared/ttlFieldNotTimestamp-C8zgHJjp.mjs +0 -1
  49. package/dist/packem_shared/unindexedForeignKey-Dypgn8uH.mjs +0 -1
  50. package/dist/packem_shared/unindexedRelationTarget-Dj2_NOCm.mjs +0 -1
package/README.md CHANGED
@@ -109,7 +109,7 @@ const findings = runAdvisor(context, { source: "static" });
109
109
  const map = scoreAdvisor(context.procedureProtections ?? [], findings);
110
110
 
111
111
  console.log(map.score, map.grade); // e.g. 84 "good"
112
- console.log(map.summary); // { clean: 9, exempt: 0, failing: 1, procedures: 12, rulesFired: 6, warned: 2 }
112
+ console.log(map.summary); // { clean: 9, exempt: 0, failing: 1, procedures: 12, rulesFired: 6, suppressed: 0, warned: 2 }
113
113
  ```
114
114
 
115
115
  Each procedure starts at 100 and loses each fired **rule's** severity weight (`ERROR` 20 / `WARN` 10 / `INFO` 5 — severity is the only input; a lint carries no weight of its own) — charged once however many times that rule fires — then rolls up into a weighted global mean: public handlers count double, internal ones and queries half. Findings that name no procedure (schema shape, wrangler config) land in a project bucket weighted against the procedure population, so schema debt genuinely moves the grade.
package/dist/index.d.mts CHANGED
@@ -860,6 +860,8 @@ interface AdvisorMaskProcedure {
860
860
  exportName: string;
861
861
  /** Source file relative to the lunora dir, no extension. */
862
862
  file: string;
863
+ /** 1-based start line of the declaring statement, when the feeder recorded it. */
864
+ line?: number;
863
865
  /**
864
866
  * The `(table, column)` pairs declared by the `mask(policies)` object passed
865
867
  * to `.use(mask(...))` in this procedure's builder chain. Empty when the
@@ -1421,6 +1423,15 @@ interface AdvisorQueue {
1421
1423
  /** Push-consumer batch/retry tuning; the `deadLetterQueue`/`maxRetries` the queue lints read. */
1422
1424
  tuning: AdvisorQueueTuning;
1423
1425
  }
1426
+ /** One topic declared via a `defineTopic()` export in `lunora/queues.ts`. */
1427
+ interface AdvisorTopic {
1428
+ /** The `lunora/queues.ts` export name, e.g. `signups`. */
1429
+ exportName: string;
1430
+ /** Lunora-relative file the topic is declared in, without `.ts` (`queues`, or `billing/queues`). */
1431
+ file?: string;
1432
+ /** 1-based start line of the `defineTopic(...)` statement, under {@link AdvisorTopic.file}. */
1433
+ line?: number;
1434
+ }
1424
1435
  /**
1425
1436
  * One `ctx.r2sql` access discovered lexically inside a `query(...)` or
1426
1437
  * `mutation(...)` handler body — the input the `r2sql_outside_action` lint
@@ -1628,6 +1639,10 @@ interface AdvisorTable {
1628
1639
  * has implicitly — lints that resolve a column treat those as always valid.
1629
1640
  */
1630
1641
  fields: ReadonlyArray<string>;
1642
+ /**
1643
+ * Lunora-relative file the table is declared in, without `.ts`. Absent when the declaration is not source under `lunora/`.
1644
+ */
1645
+ file?: string;
1631
1646
  /** Every declared index, across all kinds (secondary / search / rank / vector). */
1632
1647
  indexes: ReadonlyArray<AdvisorIndex>;
1633
1648
  /**
@@ -1639,6 +1654,8 @@ interface AdvisorTable {
1639
1654
  * `allow_unauthenticated_shard_access_enabled`.
1640
1655
  */
1641
1656
  isPublic?: boolean;
1657
+ /** 1-based start line of the table's declaration, under {@link AdvisorTable.file}. */
1658
+ line?: number;
1642
1659
  /** Table name. */
1643
1660
  name: string;
1644
1661
  /** Declared relations (`.relations((r) => …)`). */
@@ -1685,7 +1702,11 @@ interface AdvisorTable {
1685
1702
  */
1686
1703
  interface AdvisorIndex {
1687
1704
  fields: ReadonlyArray<string>;
1705
+ /** Lunora-relative file the index is declared in, without `.ts`. Absent when not source under `lunora/`. */
1706
+ file?: string;
1688
1707
  kind: "geo" | "index" | "rank" | "search" | "vector";
1708
+ /** 1-based start line of the index's method name (`.index`, `.searchIndex`, …), under {@link AdvisorIndex.file}. */
1709
+ line?: number;
1689
1710
  name: string;
1690
1711
  unique?: boolean;
1691
1712
  }
@@ -1713,7 +1734,11 @@ interface AdvisorExternalSource {
1713
1734
  */
1714
1735
  interface AdvisorKeyedRelation {
1715
1736
  field: string;
1737
+ /** Lunora-relative file the relation's property is declared in, without `.ts`. */
1738
+ file?: string;
1716
1739
  kind: "many" | "one";
1740
+ /** 1-based start line of the relation's property in the `.relations(...)` object, under {@link AdvisorKeyedRelation.file}. */
1741
+ line?: number;
1717
1742
  name: string;
1718
1743
  onDelete?: "cascade" | "restrict" | "set null";
1719
1744
  references: string;
@@ -1725,7 +1750,11 @@ interface AdvisorKeyedRelation {
1725
1750
  * whose `from` column points at the declaring table and `to` at `table`. It has no `field` of its own.
1726
1751
  */
1727
1752
  interface AdvisorThroughRelation {
1753
+ /** Lunora-relative file the relation's property is declared in, without `.ts`. */
1754
+ file?: string;
1728
1755
  kind: "many";
1756
+ /** 1-based start line of the relation's property in the `.relations(...)` object, under {@link AdvisorThroughRelation.file}. */
1757
+ line?: number;
1729
1758
  name: string;
1730
1759
  table: string;
1731
1760
  through: {
@@ -2073,6 +2102,8 @@ interface AdvisorWranglerVariable {
2073
2102
  key: string;
2074
2103
  /** Heuristic that matched, e.g. `stripe_live_key` / `private_key` / `secret_named_var`. */
2075
2104
  kind: string;
2105
+ /** 1-based line of the key inside {@link AdvisorWranglerVariable.file}, when the reader could locate it. */
2106
+ line?: number;
2076
2107
  /** Redacted preview (first few chars + length) — never the full secret. */
2077
2108
  preview: string;
2078
2109
  }
@@ -2131,6 +2162,19 @@ interface Finding {
2131
2162
  name: string;
2132
2163
  /** How to fix it — a doc URL or short imperative guidance. */
2133
2164
  remediation: string;
2165
+ /**
2166
+ * Set when an inline `// lunora-advisor-exempt <rule> -- <reason>` directive
2167
+ * accepts this finding. The finding stays in the list so every surface can show
2168
+ * it and its reason, but the gate, the health map and the blocking check ignore it.
2169
+ */
2170
+ suppressed?: {
2171
+ /** The directive's site, relative to the project root. */
2172
+ file: string;
2173
+ /** 1-based line of the directive. */
2174
+ line: number;
2175
+ /** The directive's trimmed reason, required to be non-empty. */
2176
+ reason: string;
2177
+ };
2134
2178
  /** Short headline for the finding. */
2135
2179
  title: string;
2136
2180
  }
@@ -2676,6 +2720,10 @@ interface LintContext {
2676
2720
  * absent for runtime callers.
2677
2721
  */
2678
2722
  tableWrites?: ReadonlyArray<AdvisorTableWrite>;
2723
+ /**
2724
+ * Topics declared via `defineTopic` exports in `lunora/queues.ts`. The lint that reports a topic's subscription count reads its declaration site; absent for runtime callers.
2725
+ */
2726
+ topics?: ReadonlyArray<AdvisorTopic>;
2679
2727
  /**
2680
2728
  * Literal-infinite loops (`while (true)`, `for (;;)`, `do … while (true)`)
2681
2729
  * with no statically reachable exit — the `unbounded_loop` input. Supplied
@@ -4063,7 +4111,8 @@ declare const normalizeIdUsedAsAuthorization: Lint;
4063
4111
  *
4064
4112
  * This lint runs when the codegen feeder has supplied config evidence
4065
4113
  * (`context.notifyConfig` present); a runtime caller with no evidence flags
4066
- * nothing.
4114
+ * nothing. The finding carries no source location: its evidence is the channel
4115
+ * wiring plus the send sites across every handler, not one call to point at.
4067
4116
  */
4068
4117
  declare const notifyMissingPushConfig: Lint;
4069
4118
  /**
@@ -5148,6 +5197,8 @@ interface MapSummary {
5148
5197
  procedures: number;
5149
5198
  /** Findings attributed to a scored row, after per-rule deduplication. */
5150
5199
  rulesFired: number;
5200
+ /** Findings accepted by an inline `lunora-advisor-exempt <rule>` directive. They score nothing and are not in `rulesFired`. */
5201
+ suppressed: number;
5151
5202
  /** Procedures scoring at or above the failing floor, but not clean. */
5152
5203
  warned: number;
5153
5204
  }
@@ -5341,4 +5392,4 @@ interface RunAdvisorOptions {
5341
5392
  * `static` lints at build time and defer `runtime` lints to a live shard.
5342
5393
  */
5343
5394
  declare const runAdvisor: (context: LintContext, options?: RunAdvisorOptions) => Finding[];
5344
- export { ALL_LINTS, type AdvisorAdminRoute, type AdvisorAiRawRun, type AdvisorAiToolSideEffect, type AdvisorArgumentDerivedFetch, type AdvisorArgumentValidator, type AdvisorAuthApiCall, type AdvisorAuthConfig, type AdvisorBrowserUrlAccess, type AdvisorCallEdge, type AdvisorCallSiteScope, type AdvisorConfigCall, type AdvisorContainer, type AdvisorContainerKeyAccess, type AdvisorContainerOverride, type AdvisorCountRead, type AdvisorCron, type AdvisorExportSink, type AdvisorFailOpenGuard, type AdvisorFlagRead, type AdvisorFlagSecurityDefault, type AdvisorGeoIndexUsage, type AdvisorHttpActionGuard, type AdvisorHttpHeaderWrite, type AdvisorHyperdriveCall, type AdvisorIdentityClaimRead, type AdvisorImageDeliveryUrlAccess, type AdvisorIndex, type AdvisorIndexHit, type AdvisorInsertWrite, type AdvisorKeyedRelation, type AdvisorKvKeyAccess, type AdvisorMailRecipientAccess, type AdvisorMap, type AdvisorMaskProcedure, type AdvisorMaskStrategy, type AdvisorModule, type AdvisorMutatorDeclaration, type AdvisorMutatorWrite, type AdvisorNondeterministicCall, type AdvisorNormalizeIdAuthorization, type AdvisorNotifyCall, type AdvisorNotifyConfig, type AdvisorOpenShardAccess, type AdvisorOwnerFieldWrite, type AdvisorPaymentWebhook, type AdvisorPrivilegedDispatch, type AdvisorProcedureDocument, type AdvisorProcedureProtection, type AdvisorQueryRead, type AdvisorQueue, type AdvisorQueueTuning, type AdvisorR2sqlCall, type AdvisorRatelimitKeySelector, type AdvisorRawRowReturn, type AdvisorRelation, type AdvisorRelationLoad, type AdvisorRlsProcedure, type AdvisorRowEffect, type AdvisorSchema, type AdvisorSecretLiteral, type AdvisorShape, type AdvisorShardTraffic, type AdvisorSoftDeleteRead, type AdvisorSqlInterpolation, type AdvisorStaleMigrationImport, type AdvisorStorageKeyAccess, type AdvisorStorageUpload, type AdvisorTable, type AdvisorTableScan, type AdvisorTableWrite, type AdvisorThroughRelation, type AdvisorUnboundedLoop, type AdvisorVectorNamespaceAccess, type AdvisorWorkflow, type AdvisorWorkflowCall, type AdvisorWranglerVariable, type AnalyticsMetricsOptions, type AnalyticsMetricsSource, type AnalyticsRuntimeMetrics, type BaselineComparison, type CallSiteMetadata, type Category, type CheckResult, type Coverage, type Facing, type Finding, type Grade, type Level, type Lint, type LintContext, type LintSource, MAP_VERSION, type MapSummary, type ProcedureDelta, type ProcedureScore, type ProjectScore, RUNTIME_LINTS, RunAdvisorOptions, STATIC_LINTS, type ScoreAdvisorOptions, type Sensitivity, type SensitivityLevel, actionFetchSsrf, actionWithoutErrorHandling, adminRouteWithoutGuard, aiRawRunEscapeHatch, aiRunWithoutLogging, aiToolSideEffectPromptInjection, aiUnboundedGenerationPublic, allowUnauthenticatedShardAccessEnabled, authApiCallWithoutHeaders, authCsrfCheckDisabled, authEmailVerificationDisabled, authScimWithoutTransactions, authSecureCookiesDisabled, authSessionFreshageZero, authTrustedOriginsWildcard, browserAllowPrivateTargets, browserUserUrlWithoutAllowlist, byCodepoint, callSiteCallers, callSiteDescription, callSiteLabel, callSiteMetadata, circularFk, classifySensitivity, commitOrderedHardDelete, compareToBaseline, containerInstanceKeyFromUserInput, containerLongSleepAfter, containerOversizedInstance, containerPublicInternet, containerRuntimeEgressRelaxation, containerStartEnableInternetOverride, countWithoutIndex, cronEveryMinute, crossModuleTableWrite, dedupeCacheKeys, dispatchCycle, duplicateIndex, emptyIndex, errorWithoutCatalog, exportSinkMisconfigured, externalSourceIncrementalNoDeletePath, externalSourceOnGlobal, externalSourceUnscoped, fanOutBreadth, filterAfterIndexScan, filterOnPrimaryKey, filterWithoutIndex, flagGatesSecurityWithUnsafeDefault, flagReadInSubscription, fromServerSchema, geoIndexFieldNotGeopoint, geoIndexUnused, globalTableNearColumnLimit, gradeFromScore, hardcodedSecret, helperRole, hotShard, httpActionMissingAuthGuard, httpActionResponseHeaderInjection, hyperdriveOutsideAction, identityUndeclaredClaimTrusted, imagesUrlSourceFromUserInput, indexReferencesUnknownField, indexUtilization, insertManyUnsafeUserData, isReachableSite, kvUnscopedUserKeyIdor, mailInboundDispatchWithoutVerify, mailRecipientFromRequestInput, maskUncoveredPiiColumn, maskWeakHashStrategyOnPii, maskedRelationLeakViaWith, mutatorFullRowReplace, mutatorWithoutOwnerScope, nondeterministicQueryMutation, normalizeIdUsedAsAuthorization, notifyMissingPushConfig, notifySendOutsideAction, openShardAccess, outputProjectionMissingOnPublicRead, ownerFieldFromArgsNotAuth, parseAdvisorMap, paymentCreateWithoutAuthorize, paymentWebhookWideTolerance, plaintextSecretInWranglerVariables, policyReferencesUnknownTable, privilegedDispatchUnvalidatedPayload, privilegedFanoutFromPublicProcedure, procedureWithoutStructuredEvent, publicArgumentUsesAny, publicMutationWithoutRatelimit, publicTableRlsOptoutConfusion, queueDispatchCycle, queueWithoutDlq, r2sqlOutsideAction, ratelimitDefaultMemoryStore, ratelimitKeySpoofableOrGlobal, ratelimitMiddlewareFailOpen, readCallSiteCallers, relationReferencesUnknownField, relationReferencesUnknownTable, rlsUncoveredTable, runAdvisor, scoreAdvisor, selfRescheduleWithoutProgress, shapeTargetsGlobalTable, shapeUnknownTable, signupMutationWithoutDisposableGating, softDeleteIncludeDeletedFromArgs, sqlInjectionRisk, storageGenerateUploadUrlNoContentTypePin, storageKeyFromUserArgs, storagePresignedUrlForPrivateContent, storageUploadWithoutContentTypeAllowlist, storageUploadWithoutMaxSize, tableWithoutInsert, throughRelationMissingUniqueIndex, topicTooManySubscriptions, ttlFieldNotTimestamp, unboundedCollectOnOpenRange, unboundedLoop, unboundedStringArgument, unindexedForeignKey, unindexedRelationTarget, unrestrictedWhereBranch, userCreatingMutationWithoutCaptcha, vectorsNamespaceFromUserInput, workflowDuplicateStepName, workflowUnknownTarget, workflowUnused };
5395
+ export { ALL_LINTS, type AdvisorAdminRoute, type AdvisorAiRawRun, type AdvisorAiToolSideEffect, type AdvisorArgumentDerivedFetch, type AdvisorArgumentValidator, type AdvisorAuthApiCall, type AdvisorAuthConfig, type AdvisorBrowserUrlAccess, type AdvisorCallEdge, type AdvisorCallSiteScope, type AdvisorConfigCall, type AdvisorContainer, type AdvisorContainerKeyAccess, type AdvisorContainerOverride, type AdvisorCountRead, type AdvisorCron, type AdvisorExportSink, type AdvisorFailOpenGuard, type AdvisorFlagRead, type AdvisorFlagSecurityDefault, type AdvisorGeoIndexUsage, type AdvisorHttpActionGuard, type AdvisorHttpHeaderWrite, type AdvisorHyperdriveCall, type AdvisorIdentityClaimRead, type AdvisorImageDeliveryUrlAccess, type AdvisorIndex, type AdvisorIndexHit, type AdvisorInsertWrite, type AdvisorKeyedRelation, type AdvisorKvKeyAccess, type AdvisorMailRecipientAccess, type AdvisorMap, type AdvisorMaskProcedure, type AdvisorMaskStrategy, type AdvisorModule, type AdvisorMutatorDeclaration, type AdvisorMutatorWrite, type AdvisorNondeterministicCall, type AdvisorNormalizeIdAuthorization, type AdvisorNotifyCall, type AdvisorNotifyConfig, type AdvisorOpenShardAccess, type AdvisorOwnerFieldWrite, type AdvisorPaymentWebhook, type AdvisorPrivilegedDispatch, type AdvisorProcedureDocument, type AdvisorProcedureProtection, type AdvisorQueryRead, type AdvisorQueue, type AdvisorQueueTuning, type AdvisorR2sqlCall, type AdvisorRatelimitKeySelector, type AdvisorRawRowReturn, type AdvisorRelation, type AdvisorRelationLoad, type AdvisorRlsProcedure, type AdvisorRowEffect, type AdvisorSchema, type AdvisorSecretLiteral, type AdvisorShape, type AdvisorShardTraffic, type AdvisorSoftDeleteRead, type AdvisorSqlInterpolation, type AdvisorStaleMigrationImport, type AdvisorStorageKeyAccess, type AdvisorStorageUpload, type AdvisorTable, type AdvisorTableScan, type AdvisorTableWrite, type AdvisorThroughRelation, type AdvisorTopic, type AdvisorUnboundedLoop, type AdvisorVectorNamespaceAccess, type AdvisorWorkflow, type AdvisorWorkflowCall, type AdvisorWranglerVariable, type AnalyticsMetricsOptions, type AnalyticsMetricsSource, type AnalyticsRuntimeMetrics, type BaselineComparison, type CallSiteMetadata, type Category, type CheckResult, type Coverage, type Facing, type Finding, type Grade, type Level, type Lint, type LintContext, type LintSource, MAP_VERSION, type MapSummary, type ProcedureDelta, type ProcedureScore, type ProjectScore, RUNTIME_LINTS, RunAdvisorOptions, STATIC_LINTS, type ScoreAdvisorOptions, type Sensitivity, type SensitivityLevel, actionFetchSsrf, actionWithoutErrorHandling, adminRouteWithoutGuard, aiRawRunEscapeHatch, aiRunWithoutLogging, aiToolSideEffectPromptInjection, aiUnboundedGenerationPublic, allowUnauthenticatedShardAccessEnabled, authApiCallWithoutHeaders, authCsrfCheckDisabled, authEmailVerificationDisabled, authScimWithoutTransactions, authSecureCookiesDisabled, authSessionFreshageZero, authTrustedOriginsWildcard, browserAllowPrivateTargets, browserUserUrlWithoutAllowlist, byCodepoint, callSiteCallers, callSiteDescription, callSiteLabel, callSiteMetadata, circularFk, classifySensitivity, commitOrderedHardDelete, compareToBaseline, containerInstanceKeyFromUserInput, containerLongSleepAfter, containerOversizedInstance, containerPublicInternet, containerRuntimeEgressRelaxation, containerStartEnableInternetOverride, countWithoutIndex, cronEveryMinute, crossModuleTableWrite, dedupeCacheKeys, dispatchCycle, duplicateIndex, emptyIndex, errorWithoutCatalog, exportSinkMisconfigured, externalSourceIncrementalNoDeletePath, externalSourceOnGlobal, externalSourceUnscoped, fanOutBreadth, filterAfterIndexScan, filterOnPrimaryKey, filterWithoutIndex, flagGatesSecurityWithUnsafeDefault, flagReadInSubscription, fromServerSchema, geoIndexFieldNotGeopoint, geoIndexUnused, globalTableNearColumnLimit, gradeFromScore, hardcodedSecret, helperRole, hotShard, httpActionMissingAuthGuard, httpActionResponseHeaderInjection, hyperdriveOutsideAction, identityUndeclaredClaimTrusted, imagesUrlSourceFromUserInput, indexReferencesUnknownField, indexUtilization, insertManyUnsafeUserData, isReachableSite, kvUnscopedUserKeyIdor, mailInboundDispatchWithoutVerify, mailRecipientFromRequestInput, maskUncoveredPiiColumn, maskWeakHashStrategyOnPii, maskedRelationLeakViaWith, mutatorFullRowReplace, mutatorWithoutOwnerScope, nondeterministicQueryMutation, normalizeIdUsedAsAuthorization, notifyMissingPushConfig, notifySendOutsideAction, openShardAccess, outputProjectionMissingOnPublicRead, ownerFieldFromArgsNotAuth, parseAdvisorMap, paymentCreateWithoutAuthorize, paymentWebhookWideTolerance, plaintextSecretInWranglerVariables, policyReferencesUnknownTable, privilegedDispatchUnvalidatedPayload, privilegedFanoutFromPublicProcedure, procedureWithoutStructuredEvent, publicArgumentUsesAny, publicMutationWithoutRatelimit, publicTableRlsOptoutConfusion, queueDispatchCycle, queueWithoutDlq, r2sqlOutsideAction, ratelimitDefaultMemoryStore, ratelimitKeySpoofableOrGlobal, ratelimitMiddlewareFailOpen, readCallSiteCallers, relationReferencesUnknownField, relationReferencesUnknownTable, rlsUncoveredTable, runAdvisor, scoreAdvisor, selfRescheduleWithoutProgress, shapeTargetsGlobalTable, shapeUnknownTable, signupMutationWithoutDisposableGating, softDeleteIncludeDeletedFromArgs, sqlInjectionRisk, storageGenerateUploadUrlNoContentTypePin, storageKeyFromUserArgs, storagePresignedUrlForPrivateContent, storageUploadWithoutContentTypeAllowlist, storageUploadWithoutMaxSize, tableWithoutInsert, throughRelationMissingUniqueIndex, topicTooManySubscriptions, ttlFieldNotTimestamp, unboundedCollectOnOpenRange, unboundedLoop, unboundedStringArgument, unindexedForeignKey, unindexedRelationTarget, unrestrictedWhereBranch, userCreatingMutationWithoutCaptcha, vectorsNamespaceFromUserInput, workflowDuplicateStepName, workflowUnknownTarget, workflowUnused };
package/dist/index.d.ts CHANGED
@@ -860,6 +860,8 @@ interface AdvisorMaskProcedure {
860
860
  exportName: string;
861
861
  /** Source file relative to the lunora dir, no extension. */
862
862
  file: string;
863
+ /** 1-based start line of the declaring statement, when the feeder recorded it. */
864
+ line?: number;
863
865
  /**
864
866
  * The `(table, column)` pairs declared by the `mask(policies)` object passed
865
867
  * to `.use(mask(...))` in this procedure's builder chain. Empty when the
@@ -1421,6 +1423,15 @@ interface AdvisorQueue {
1421
1423
  /** Push-consumer batch/retry tuning; the `deadLetterQueue`/`maxRetries` the queue lints read. */
1422
1424
  tuning: AdvisorQueueTuning;
1423
1425
  }
1426
+ /** One topic declared via a `defineTopic()` export in `lunora/queues.ts`. */
1427
+ interface AdvisorTopic {
1428
+ /** The `lunora/queues.ts` export name, e.g. `signups`. */
1429
+ exportName: string;
1430
+ /** Lunora-relative file the topic is declared in, without `.ts` (`queues`, or `billing/queues`). */
1431
+ file?: string;
1432
+ /** 1-based start line of the `defineTopic(...)` statement, under {@link AdvisorTopic.file}. */
1433
+ line?: number;
1434
+ }
1424
1435
  /**
1425
1436
  * One `ctx.r2sql` access discovered lexically inside a `query(...)` or
1426
1437
  * `mutation(...)` handler body — the input the `r2sql_outside_action` lint
@@ -1628,6 +1639,10 @@ interface AdvisorTable {
1628
1639
  * has implicitly — lints that resolve a column treat those as always valid.
1629
1640
  */
1630
1641
  fields: ReadonlyArray<string>;
1642
+ /**
1643
+ * Lunora-relative file the table is declared in, without `.ts`. Absent when the declaration is not source under `lunora/`.
1644
+ */
1645
+ file?: string;
1631
1646
  /** Every declared index, across all kinds (secondary / search / rank / vector). */
1632
1647
  indexes: ReadonlyArray<AdvisorIndex>;
1633
1648
  /**
@@ -1639,6 +1654,8 @@ interface AdvisorTable {
1639
1654
  * `allow_unauthenticated_shard_access_enabled`.
1640
1655
  */
1641
1656
  isPublic?: boolean;
1657
+ /** 1-based start line of the table's declaration, under {@link AdvisorTable.file}. */
1658
+ line?: number;
1642
1659
  /** Table name. */
1643
1660
  name: string;
1644
1661
  /** Declared relations (`.relations((r) => …)`). */
@@ -1685,7 +1702,11 @@ interface AdvisorTable {
1685
1702
  */
1686
1703
  interface AdvisorIndex {
1687
1704
  fields: ReadonlyArray<string>;
1705
+ /** Lunora-relative file the index is declared in, without `.ts`. Absent when not source under `lunora/`. */
1706
+ file?: string;
1688
1707
  kind: "geo" | "index" | "rank" | "search" | "vector";
1708
+ /** 1-based start line of the index's method name (`.index`, `.searchIndex`, …), under {@link AdvisorIndex.file}. */
1709
+ line?: number;
1689
1710
  name: string;
1690
1711
  unique?: boolean;
1691
1712
  }
@@ -1713,7 +1734,11 @@ interface AdvisorExternalSource {
1713
1734
  */
1714
1735
  interface AdvisorKeyedRelation {
1715
1736
  field: string;
1737
+ /** Lunora-relative file the relation's property is declared in, without `.ts`. */
1738
+ file?: string;
1716
1739
  kind: "many" | "one";
1740
+ /** 1-based start line of the relation's property in the `.relations(...)` object, under {@link AdvisorKeyedRelation.file}. */
1741
+ line?: number;
1717
1742
  name: string;
1718
1743
  onDelete?: "cascade" | "restrict" | "set null";
1719
1744
  references: string;
@@ -1725,7 +1750,11 @@ interface AdvisorKeyedRelation {
1725
1750
  * whose `from` column points at the declaring table and `to` at `table`. It has no `field` of its own.
1726
1751
  */
1727
1752
  interface AdvisorThroughRelation {
1753
+ /** Lunora-relative file the relation's property is declared in, without `.ts`. */
1754
+ file?: string;
1728
1755
  kind: "many";
1756
+ /** 1-based start line of the relation's property in the `.relations(...)` object, under {@link AdvisorThroughRelation.file}. */
1757
+ line?: number;
1729
1758
  name: string;
1730
1759
  table: string;
1731
1760
  through: {
@@ -2073,6 +2102,8 @@ interface AdvisorWranglerVariable {
2073
2102
  key: string;
2074
2103
  /** Heuristic that matched, e.g. `stripe_live_key` / `private_key` / `secret_named_var`. */
2075
2104
  kind: string;
2105
+ /** 1-based line of the key inside {@link AdvisorWranglerVariable.file}, when the reader could locate it. */
2106
+ line?: number;
2076
2107
  /** Redacted preview (first few chars + length) — never the full secret. */
2077
2108
  preview: string;
2078
2109
  }
@@ -2131,6 +2162,19 @@ interface Finding {
2131
2162
  name: string;
2132
2163
  /** How to fix it — a doc URL or short imperative guidance. */
2133
2164
  remediation: string;
2165
+ /**
2166
+ * Set when an inline `// lunora-advisor-exempt <rule> -- <reason>` directive
2167
+ * accepts this finding. The finding stays in the list so every surface can show
2168
+ * it and its reason, but the gate, the health map and the blocking check ignore it.
2169
+ */
2170
+ suppressed?: {
2171
+ /** The directive's site, relative to the project root. */
2172
+ file: string;
2173
+ /** 1-based line of the directive. */
2174
+ line: number;
2175
+ /** The directive's trimmed reason, required to be non-empty. */
2176
+ reason: string;
2177
+ };
2134
2178
  /** Short headline for the finding. */
2135
2179
  title: string;
2136
2180
  }
@@ -2676,6 +2720,10 @@ interface LintContext {
2676
2720
  * absent for runtime callers.
2677
2721
  */
2678
2722
  tableWrites?: ReadonlyArray<AdvisorTableWrite>;
2723
+ /**
2724
+ * Topics declared via `defineTopic` exports in `lunora/queues.ts`. The lint that reports a topic's subscription count reads its declaration site; absent for runtime callers.
2725
+ */
2726
+ topics?: ReadonlyArray<AdvisorTopic>;
2679
2727
  /**
2680
2728
  * Literal-infinite loops (`while (true)`, `for (;;)`, `do … while (true)`)
2681
2729
  * with no statically reachable exit — the `unbounded_loop` input. Supplied
@@ -4063,7 +4111,8 @@ declare const normalizeIdUsedAsAuthorization: Lint;
4063
4111
  *
4064
4112
  * This lint runs when the codegen feeder has supplied config evidence
4065
4113
  * (`context.notifyConfig` present); a runtime caller with no evidence flags
4066
- * nothing.
4114
+ * nothing. The finding carries no source location: its evidence is the channel
4115
+ * wiring plus the send sites across every handler, not one call to point at.
4067
4116
  */
4068
4117
  declare const notifyMissingPushConfig: Lint;
4069
4118
  /**
@@ -5148,6 +5197,8 @@ interface MapSummary {
5148
5197
  procedures: number;
5149
5198
  /** Findings attributed to a scored row, after per-rule deduplication. */
5150
5199
  rulesFired: number;
5200
+ /** Findings accepted by an inline `lunora-advisor-exempt <rule>` directive. They score nothing and are not in `rulesFired`. */
5201
+ suppressed: number;
5151
5202
  /** Procedures scoring at or above the failing floor, but not clean. */
5152
5203
  warned: number;
5153
5204
  }
@@ -5341,4 +5392,4 @@ interface RunAdvisorOptions {
5341
5392
  * `static` lints at build time and defer `runtime` lints to a live shard.
5342
5393
  */
5343
5394
  declare const runAdvisor: (context: LintContext, options?: RunAdvisorOptions) => Finding[];
5344
- export { ALL_LINTS, type AdvisorAdminRoute, type AdvisorAiRawRun, type AdvisorAiToolSideEffect, type AdvisorArgumentDerivedFetch, type AdvisorArgumentValidator, type AdvisorAuthApiCall, type AdvisorAuthConfig, type AdvisorBrowserUrlAccess, type AdvisorCallEdge, type AdvisorCallSiteScope, type AdvisorConfigCall, type AdvisorContainer, type AdvisorContainerKeyAccess, type AdvisorContainerOverride, type AdvisorCountRead, type AdvisorCron, type AdvisorExportSink, type AdvisorFailOpenGuard, type AdvisorFlagRead, type AdvisorFlagSecurityDefault, type AdvisorGeoIndexUsage, type AdvisorHttpActionGuard, type AdvisorHttpHeaderWrite, type AdvisorHyperdriveCall, type AdvisorIdentityClaimRead, type AdvisorImageDeliveryUrlAccess, type AdvisorIndex, type AdvisorIndexHit, type AdvisorInsertWrite, type AdvisorKeyedRelation, type AdvisorKvKeyAccess, type AdvisorMailRecipientAccess, type AdvisorMap, type AdvisorMaskProcedure, type AdvisorMaskStrategy, type AdvisorModule, type AdvisorMutatorDeclaration, type AdvisorMutatorWrite, type AdvisorNondeterministicCall, type AdvisorNormalizeIdAuthorization, type AdvisorNotifyCall, type AdvisorNotifyConfig, type AdvisorOpenShardAccess, type AdvisorOwnerFieldWrite, type AdvisorPaymentWebhook, type AdvisorPrivilegedDispatch, type AdvisorProcedureDocument, type AdvisorProcedureProtection, type AdvisorQueryRead, type AdvisorQueue, type AdvisorQueueTuning, type AdvisorR2sqlCall, type AdvisorRatelimitKeySelector, type AdvisorRawRowReturn, type AdvisorRelation, type AdvisorRelationLoad, type AdvisorRlsProcedure, type AdvisorRowEffect, type AdvisorSchema, type AdvisorSecretLiteral, type AdvisorShape, type AdvisorShardTraffic, type AdvisorSoftDeleteRead, type AdvisorSqlInterpolation, type AdvisorStaleMigrationImport, type AdvisorStorageKeyAccess, type AdvisorStorageUpload, type AdvisorTable, type AdvisorTableScan, type AdvisorTableWrite, type AdvisorThroughRelation, type AdvisorUnboundedLoop, type AdvisorVectorNamespaceAccess, type AdvisorWorkflow, type AdvisorWorkflowCall, type AdvisorWranglerVariable, type AnalyticsMetricsOptions, type AnalyticsMetricsSource, type AnalyticsRuntimeMetrics, type BaselineComparison, type CallSiteMetadata, type Category, type CheckResult, type Coverage, type Facing, type Finding, type Grade, type Level, type Lint, type LintContext, type LintSource, MAP_VERSION, type MapSummary, type ProcedureDelta, type ProcedureScore, type ProjectScore, RUNTIME_LINTS, RunAdvisorOptions, STATIC_LINTS, type ScoreAdvisorOptions, type Sensitivity, type SensitivityLevel, actionFetchSsrf, actionWithoutErrorHandling, adminRouteWithoutGuard, aiRawRunEscapeHatch, aiRunWithoutLogging, aiToolSideEffectPromptInjection, aiUnboundedGenerationPublic, allowUnauthenticatedShardAccessEnabled, authApiCallWithoutHeaders, authCsrfCheckDisabled, authEmailVerificationDisabled, authScimWithoutTransactions, authSecureCookiesDisabled, authSessionFreshageZero, authTrustedOriginsWildcard, browserAllowPrivateTargets, browserUserUrlWithoutAllowlist, byCodepoint, callSiteCallers, callSiteDescription, callSiteLabel, callSiteMetadata, circularFk, classifySensitivity, commitOrderedHardDelete, compareToBaseline, containerInstanceKeyFromUserInput, containerLongSleepAfter, containerOversizedInstance, containerPublicInternet, containerRuntimeEgressRelaxation, containerStartEnableInternetOverride, countWithoutIndex, cronEveryMinute, crossModuleTableWrite, dedupeCacheKeys, dispatchCycle, duplicateIndex, emptyIndex, errorWithoutCatalog, exportSinkMisconfigured, externalSourceIncrementalNoDeletePath, externalSourceOnGlobal, externalSourceUnscoped, fanOutBreadth, filterAfterIndexScan, filterOnPrimaryKey, filterWithoutIndex, flagGatesSecurityWithUnsafeDefault, flagReadInSubscription, fromServerSchema, geoIndexFieldNotGeopoint, geoIndexUnused, globalTableNearColumnLimit, gradeFromScore, hardcodedSecret, helperRole, hotShard, httpActionMissingAuthGuard, httpActionResponseHeaderInjection, hyperdriveOutsideAction, identityUndeclaredClaimTrusted, imagesUrlSourceFromUserInput, indexReferencesUnknownField, indexUtilization, insertManyUnsafeUserData, isReachableSite, kvUnscopedUserKeyIdor, mailInboundDispatchWithoutVerify, mailRecipientFromRequestInput, maskUncoveredPiiColumn, maskWeakHashStrategyOnPii, maskedRelationLeakViaWith, mutatorFullRowReplace, mutatorWithoutOwnerScope, nondeterministicQueryMutation, normalizeIdUsedAsAuthorization, notifyMissingPushConfig, notifySendOutsideAction, openShardAccess, outputProjectionMissingOnPublicRead, ownerFieldFromArgsNotAuth, parseAdvisorMap, paymentCreateWithoutAuthorize, paymentWebhookWideTolerance, plaintextSecretInWranglerVariables, policyReferencesUnknownTable, privilegedDispatchUnvalidatedPayload, privilegedFanoutFromPublicProcedure, procedureWithoutStructuredEvent, publicArgumentUsesAny, publicMutationWithoutRatelimit, publicTableRlsOptoutConfusion, queueDispatchCycle, queueWithoutDlq, r2sqlOutsideAction, ratelimitDefaultMemoryStore, ratelimitKeySpoofableOrGlobal, ratelimitMiddlewareFailOpen, readCallSiteCallers, relationReferencesUnknownField, relationReferencesUnknownTable, rlsUncoveredTable, runAdvisor, scoreAdvisor, selfRescheduleWithoutProgress, shapeTargetsGlobalTable, shapeUnknownTable, signupMutationWithoutDisposableGating, softDeleteIncludeDeletedFromArgs, sqlInjectionRisk, storageGenerateUploadUrlNoContentTypePin, storageKeyFromUserArgs, storagePresignedUrlForPrivateContent, storageUploadWithoutContentTypeAllowlist, storageUploadWithoutMaxSize, tableWithoutInsert, throughRelationMissingUniqueIndex, topicTooManySubscriptions, ttlFieldNotTimestamp, unboundedCollectOnOpenRange, unboundedLoop, unboundedStringArgument, unindexedForeignKey, unindexedRelationTarget, unrestrictedWhereBranch, userCreatingMutationWithoutCaptcha, vectorsNamespaceFromUserInput, workflowDuplicateStepName, workflowUnknownTarget, workflowUnused };
5395
+ export { ALL_LINTS, type AdvisorAdminRoute, type AdvisorAiRawRun, type AdvisorAiToolSideEffect, type AdvisorArgumentDerivedFetch, type AdvisorArgumentValidator, type AdvisorAuthApiCall, type AdvisorAuthConfig, type AdvisorBrowserUrlAccess, type AdvisorCallEdge, type AdvisorCallSiteScope, type AdvisorConfigCall, type AdvisorContainer, type AdvisorContainerKeyAccess, type AdvisorContainerOverride, type AdvisorCountRead, type AdvisorCron, type AdvisorExportSink, type AdvisorFailOpenGuard, type AdvisorFlagRead, type AdvisorFlagSecurityDefault, type AdvisorGeoIndexUsage, type AdvisorHttpActionGuard, type AdvisorHttpHeaderWrite, type AdvisorHyperdriveCall, type AdvisorIdentityClaimRead, type AdvisorImageDeliveryUrlAccess, type AdvisorIndex, type AdvisorIndexHit, type AdvisorInsertWrite, type AdvisorKeyedRelation, type AdvisorKvKeyAccess, type AdvisorMailRecipientAccess, type AdvisorMap, type AdvisorMaskProcedure, type AdvisorMaskStrategy, type AdvisorModule, type AdvisorMutatorDeclaration, type AdvisorMutatorWrite, type AdvisorNondeterministicCall, type AdvisorNormalizeIdAuthorization, type AdvisorNotifyCall, type AdvisorNotifyConfig, type AdvisorOpenShardAccess, type AdvisorOwnerFieldWrite, type AdvisorPaymentWebhook, type AdvisorPrivilegedDispatch, type AdvisorProcedureDocument, type AdvisorProcedureProtection, type AdvisorQueryRead, type AdvisorQueue, type AdvisorQueueTuning, type AdvisorR2sqlCall, type AdvisorRatelimitKeySelector, type AdvisorRawRowReturn, type AdvisorRelation, type AdvisorRelationLoad, type AdvisorRlsProcedure, type AdvisorRowEffect, type AdvisorSchema, type AdvisorSecretLiteral, type AdvisorShape, type AdvisorShardTraffic, type AdvisorSoftDeleteRead, type AdvisorSqlInterpolation, type AdvisorStaleMigrationImport, type AdvisorStorageKeyAccess, type AdvisorStorageUpload, type AdvisorTable, type AdvisorTableScan, type AdvisorTableWrite, type AdvisorThroughRelation, type AdvisorTopic, type AdvisorUnboundedLoop, type AdvisorVectorNamespaceAccess, type AdvisorWorkflow, type AdvisorWorkflowCall, type AdvisorWranglerVariable, type AnalyticsMetricsOptions, type AnalyticsMetricsSource, type AnalyticsRuntimeMetrics, type BaselineComparison, type CallSiteMetadata, type Category, type CheckResult, type Coverage, type Facing, type Finding, type Grade, type Level, type Lint, type LintContext, type LintSource, MAP_VERSION, type MapSummary, type ProcedureDelta, type ProcedureScore, type ProjectScore, RUNTIME_LINTS, RunAdvisorOptions, STATIC_LINTS, type ScoreAdvisorOptions, type Sensitivity, type SensitivityLevel, actionFetchSsrf, actionWithoutErrorHandling, adminRouteWithoutGuard, aiRawRunEscapeHatch, aiRunWithoutLogging, aiToolSideEffectPromptInjection, aiUnboundedGenerationPublic, allowUnauthenticatedShardAccessEnabled, authApiCallWithoutHeaders, authCsrfCheckDisabled, authEmailVerificationDisabled, authScimWithoutTransactions, authSecureCookiesDisabled, authSessionFreshageZero, authTrustedOriginsWildcard, browserAllowPrivateTargets, browserUserUrlWithoutAllowlist, byCodepoint, callSiteCallers, callSiteDescription, callSiteLabel, callSiteMetadata, circularFk, classifySensitivity, commitOrderedHardDelete, compareToBaseline, containerInstanceKeyFromUserInput, containerLongSleepAfter, containerOversizedInstance, containerPublicInternet, containerRuntimeEgressRelaxation, containerStartEnableInternetOverride, countWithoutIndex, cronEveryMinute, crossModuleTableWrite, dedupeCacheKeys, dispatchCycle, duplicateIndex, emptyIndex, errorWithoutCatalog, exportSinkMisconfigured, externalSourceIncrementalNoDeletePath, externalSourceOnGlobal, externalSourceUnscoped, fanOutBreadth, filterAfterIndexScan, filterOnPrimaryKey, filterWithoutIndex, flagGatesSecurityWithUnsafeDefault, flagReadInSubscription, fromServerSchema, geoIndexFieldNotGeopoint, geoIndexUnused, globalTableNearColumnLimit, gradeFromScore, hardcodedSecret, helperRole, hotShard, httpActionMissingAuthGuard, httpActionResponseHeaderInjection, hyperdriveOutsideAction, identityUndeclaredClaimTrusted, imagesUrlSourceFromUserInput, indexReferencesUnknownField, indexUtilization, insertManyUnsafeUserData, isReachableSite, kvUnscopedUserKeyIdor, mailInboundDispatchWithoutVerify, mailRecipientFromRequestInput, maskUncoveredPiiColumn, maskWeakHashStrategyOnPii, maskedRelationLeakViaWith, mutatorFullRowReplace, mutatorWithoutOwnerScope, nondeterministicQueryMutation, normalizeIdUsedAsAuthorization, notifyMissingPushConfig, notifySendOutsideAction, openShardAccess, outputProjectionMissingOnPublicRead, ownerFieldFromArgsNotAuth, parseAdvisorMap, paymentCreateWithoutAuthorize, paymentWebhookWideTolerance, plaintextSecretInWranglerVariables, policyReferencesUnknownTable, privilegedDispatchUnvalidatedPayload, privilegedFanoutFromPublicProcedure, procedureWithoutStructuredEvent, publicArgumentUsesAny, publicMutationWithoutRatelimit, publicTableRlsOptoutConfusion, queueDispatchCycle, queueWithoutDlq, r2sqlOutsideAction, ratelimitDefaultMemoryStore, ratelimitKeySpoofableOrGlobal, ratelimitMiddlewareFailOpen, readCallSiteCallers, relationReferencesUnknownField, relationReferencesUnknownTable, rlsUncoveredTable, runAdvisor, scoreAdvisor, selfRescheduleWithoutProgress, shapeTargetsGlobalTable, shapeUnknownTable, signupMutationWithoutDisposableGating, softDeleteIncludeDeletedFromArgs, sqlInjectionRisk, storageGenerateUploadUrlNoContentTypePin, storageKeyFromUserArgs, storagePresignedUrlForPrivateContent, storageUploadWithoutContentTypeAllowlist, storageUploadWithoutMaxSize, tableWithoutInsert, throughRelationMissingUniqueIndex, topicTooManySubscriptions, ttlFieldNotTimestamp, unboundedCollectOnOpenRange, unboundedLoop, unboundedStringArgument, unindexedForeignKey, unindexedRelationTarget, unrestrictedWhereBranch, userCreatingMutationWithoutCaptcha, vectorsNamespaceFromUserInput, workflowDuplicateStepName, workflowUnknownTarget, workflowUnused };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{dedupeCacheKeys as c}from"./packem_shared/dedupeCacheKeys-DtBOHffV.mjs";import d from"./packem_shared/fanOutBreadth-CBtmZnoh.mjs";import u from"./packem_shared/hotShard-BwGYZ3Tq.mjs";import h from"./packem_shared/indexUtilization-CmtN9-HA.mjs";import g from"./packem_shared/actionFetchSsrf-B7FqsLWm.mjs";import b from"./packem_shared/actionWithoutErrorHandling-DK3rB5c-.mjs";import y from"./packem_shared/adminRouteWithoutGuard-CcdlN75o.mjs";import S from"./packem_shared/aiRawRunEscapeHatch-CzIaQf_v.mjs";import w from"./packem_shared/aiRunWithoutLogging-Ct5MeKWe.mjs";import v from"./packem_shared/aiToolSideEffectPromptInjection-Ck_h8tFx.mjs";import A from"./packem_shared/aiUnboundedGenerationPublic-CzF3xBc3.mjs";import R from"./packem_shared/allowUnauthenticatedShardAccessEnabled-BQufF5Kb.mjs";import U from"./packem_shared/authApiCallWithoutHeaders-9PpziIB9.mjs";import T from"./packem_shared/authCsrfCheckDisabled-DYTzZFpp.mjs";import W from"./packem_shared/authEmailVerificationDisabled-OiNes7Dz.mjs";import I from"./packem_shared/authScimWithoutTransactions-CajXH24D.mjs";import x from"./packem_shared/authSecureCookiesDisabled-CA5zyqDZ.mjs";import C from"./packem_shared/authSessionFreshageZero-C3IYlYft.mjs";import N from"./packem_shared/authTrustedOriginsWildcard-661FRsGe.mjs";import k from"./packem_shared/browserAllowPrivateTargets-Cj5sizhv.mjs";import F from"./packem_shared/browserUserUrlWithoutAllowlist-Bi5ZWTF7.mjs";import M from"./packem_shared/circularFk-DtcWFJxK.mjs";import O from"./packem_shared/commitOrderedHardDelete-BPdwOKA7.mjs";import $ from"./packem_shared/containerInstanceKeyFromUserInput-DHQ2JL4x.mjs";import E from"./packem_shared/containerLongSleepAfter-DSGnfpfl.mjs";import D from"./packem_shared/containerOversizedInstance-INKmy3-D.mjs";import P from"./packem_shared/containerPublicInternet-Csh5_RwX.mjs";import L from"./packem_shared/containerRuntimeEgressRelaxation-J6rpfvr8.mjs";import q from"./packem_shared/containerStartEnableInternetOverride-Bxbmrpwe.mjs";import K from"./packem_shared/countWithoutIndex-CTbdpLyE.mjs";import _ from"./packem_shared/cronEveryMinute-BjdRdTEz.mjs";import G from"./packem_shared/crossModuleTableWrite-DjiVTAwK.mjs";import z from"./packem_shared/dispatchCycle-BwuXRDiL.mjs";import H from"./packem_shared/duplicateIndex-BJI90Cnj.mjs";import B from"./packem_shared/emptyIndex-BnHDcXza.mjs";import j from"./packem_shared/errorWithoutCatalog-Dib0sdSD.mjs";import V from"./packem_shared/exportSinkMisconfigured-JfbAx9AI.mjs";import Q from"./packem_shared/externalSourceIncrementalNoDeletePath-BCzm3HzF.mjs";import X from"./packem_shared/externalSourceOnGlobal-CH7xbJ49.mjs";import Z from"./packem_shared/externalSourceUnscoped-BxU2uSXk.mjs";import J from"./packem_shared/filterAfterIndexScan-BTHjxkNi.mjs";import Y from"./packem_shared/filterOnPrimaryKey-DeRYfLa7.mjs";import ee from"./packem_shared/filterWithoutIndex-8VrXwbq5.mjs";import oe from"./packem_shared/flagGatesSecurityWithUnsafeDefault-CJK9sKcH.mjs";import re from"./packem_shared/flagReadInSubscription-DabIhYGD.mjs";import te from"./packem_shared/geoIndexFieldNotGeopoint-Cx_9INob.mjs";import ie from"./packem_shared/geoIndexUnused-D7C9Qr4U.mjs";import ne from"./packem_shared/globalTableNearColumnLimit-BFbBBd6A.mjs";import ae from"./packem_shared/hardcodedSecret-Bw_4FYrs.mjs";import me from"./packem_shared/httpActionMissingAuthGuard-D58Vnjr0.mjs";import se from"./packem_shared/httpActionResponseHeaderInjection-Yn1pbKZ8.mjs";import le from"./packem_shared/hyperdriveOutsideAction-CPDdGP2g.mjs";import pe from"./packem_shared/identityUndeclaredClaimTrusted-Z-9ob8F2.mjs";import fe from"./packem_shared/imagesUrlSourceFromUserInput-a2CZ-Xnj.mjs";import ce from"./packem_shared/indexReferencesUnknownField-CV8STvk0.mjs";import de from"./packem_shared/insertManyUnsafeUserData-CSvy65sr.mjs";import ue from"./packem_shared/kvUnscopedUserKeyIdor-D0O2alyn.mjs";import he from"./packem_shared/mailInboundDispatchWithoutVerify-CWwqXyPX.mjs";import ge from"./packem_shared/mailRecipientFromRequestInput-BMrAJjNK.mjs";import be from"./packem_shared/maskUncoveredPiiColumn-axEka4nd.mjs";import ye from"./packem_shared/maskWeakHashStrategyOnPii-CwgAXFSx.mjs";import Se from"./packem_shared/maskedRelationLeakViaWith-CIFij6vE.mjs";import{e as a}from"./packem_shared/finding-NrKO8idM.mjs";import we from"./packem_shared/mutatorFullRowReplace-NuqUCVOI.mjs";import ve from"./packem_shared/mutatorWithoutOwnerScope-BoS81ns0.mjs";import Ae from"./packem_shared/nondeterministicQueryMutation-DA_Lq_IE.mjs";import Re from"./packem_shared/normalizeIdUsedAsAuthorization-BXN-Can6.mjs";import Ue from"./packem_shared/notifyMissingPushConfig-BYks8FAs.mjs";import Te from"./packem_shared/notifySendOutsideAction-BJrDkr4h.mjs";import We from"./packem_shared/openShardAccess-CVMAgmmY.mjs";import Ie from"./packem_shared/outputProjectionMissingOnPublicRead-BPS-eg2q.mjs";import xe from"./packem_shared/ownerFieldFromArgsNotAuth-BmKLZxrX.mjs";import Ce from"./packem_shared/paymentCreateWithoutAuthorize-CdenWpXD.mjs";import Ne from"./packem_shared/paymentWebhookWideTolerance-D9i3Vb1n.mjs";import ke from"./packem_shared/plaintextSecretInWranglerVariables-bNkqmNqV.mjs";import Fe from"./packem_shared/policyReferencesUnknownTable-DiQYFRFY.mjs";import Me from"./packem_shared/privilegedDispatchUnvalidatedPayload-BJL0JNzG.mjs";import Oe from"./packem_shared/privilegedFanoutFromPublicProcedure-Byw3Prsi.mjs";import $e from"./packem_shared/procedureWithoutStructuredEvent-na08a0M1.mjs";import Ee from"./packem_shared/publicArgumentUsesAny-BDEvMA8Q.mjs";import De from"./packem_shared/publicMutationWithoutRatelimit-DAxh8tL0.mjs";import Pe from"./packem_shared/publicTableRlsOptoutConfusion-W_jAkKFR.mjs";import Le from"./packem_shared/queueDispatchCycle-84yt1IR-.mjs";import qe from"./packem_shared/queueWithoutDlq-CF_xUgE_.mjs";import Ke from"./packem_shared/r2sqlOutsideAction-BdLiLOAX.mjs";import _e from"./packem_shared/ratelimitDefaultMemoryStore-Dj0Kk7t9.mjs";import Ge from"./packem_shared/ratelimitKeySpoofableOrGlobal-VSGOuu5X.mjs";import ze from"./packem_shared/ratelimitMiddlewareFailOpen-bweBVZ4J.mjs";import He from"./packem_shared/relationReferencesUnknownField-hVsgaUKy.mjs";import Be from"./packem_shared/relationReferencesUnknownTable-vYjirSxf.mjs";import je from"./packem_shared/rlsUncoveredTable-e2FhD6Nr.mjs";import Ve from"./packem_shared/selfRescheduleWithoutProgress-HoknmezK.mjs";import Qe from"./packem_shared/shapeTargetsGlobalTable-CYRV8OvU.mjs";import Xe from"./packem_shared/shapeUnknownTable-6virkUOz.mjs";import Ze from"./packem_shared/signupMutationWithoutDisposableGating-nopEfEEK.mjs";import Je from"./packem_shared/softDeleteIncludeDeletedFromArgs-C7Ugg4zb.mjs";import Ye from"./packem_shared/sqlInjectionRisk-CSKho3Vk.mjs";import eo from"./packem_shared/storageGenerateUploadUrlNoContentTypePin-BlOPGwhZ.mjs";import oo from"./packem_shared/storageKeyFromUserArgs-BuoTsz-h.mjs";import ro from"./packem_shared/storagePresignedUrlForPrivateContent-l-EwrAfj.mjs";import to from"./packem_shared/storageUploadWithoutContentTypeAllowlist-JmITAazT.mjs";import io from"./packem_shared/storageUploadWithoutMaxSize-DlhE1I98.mjs";import no from"./packem_shared/tableWithoutInsert-DrDVc5Do.mjs";import ao from"./packem_shared/throughRelationMissingUniqueIndex-Cg5e3GkS.mjs";import mo from"./packem_shared/topicTooManySubscriptions-CiZhFm9r.mjs";import so from"./packem_shared/ttlFieldNotTimestamp-C8zgHJjp.mjs";import{s as lo,q as po,c as fo}from"./packem_shared/helpers-YAAwOBMH.mjs";import co from"./packem_shared/unboundedCollectOnOpenRange-DDGNuKks.mjs";import uo from"./packem_shared/unboundedLoop-CUF9Wdxa.mjs";import ho from"./packem_shared/unboundedStringArgument-jZnCbwB0.mjs";import go from"./packem_shared/unindexedForeignKey-Dypgn8uH.mjs";import bo from"./packem_shared/unindexedRelationTarget-Dj2_NOCm.mjs";import yo from"./packem_shared/unrestrictedWhereBranch-CcIBmHik.mjs";import So from"./packem_shared/userCreatingMutationWithoutCaptcha-8mtYqiGy.mjs";import wo from"./packem_shared/vectorsNamespaceFromUserInput-537Bt2vT.mjs";import vo from"./packem_shared/workflowDuplicateStepName-B6eAJzwA.mjs";import Ao from"./packem_shared/workflowUnknownTarget-DdG3cUPH.mjs";import Ro from"./packem_shared/workflowUnused-CSKRWTd_.mjs";import{callSiteCallers as Gt,callSiteDescription as zt,callSiteLabel as Ht,callSiteMetadata as Bt,helperRole as jt,isReachableSite as Vt,readCallSiteCallers as Qt}from"./packem_shared/callSiteCallers-DArHfQSU.mjs";import{compareToBaseline as Zt,parseAdvisorMap as Jt}from"./packem_shared/compareToBaseline-CUG59IOy.mjs";import{gradeFromScore as ei}from"./packem_shared/gradeFromScore-KSt58rj1.mjs";import{MAP_VERSION as ri,byCodepoint as ti,scoreAdvisor as ii}from"./packem_shared/MAP_VERSION-MQ5W2B6n.mjs";import{default as ai}from"./packem_shared/classifySensitivity-JnjaTGYi.mjs";import{fromServerSchema as si}from"./packem_shared/fromServerSchema-KWJd4PLE.mjs";const Uo={convex:"migrating/from-convex",firebase:"migrating/from-firebase",supabase:"migrating/from-supabase"},m={categories:["SCHEMA"],description:"A migrated-away platform's SDK is still imported from `lunora/` source. The code compiles and typechecks, so a half-finished port keeps reading from the old platform at runtime and the two stores silently drift apart.",facing:"INTERNAL",level:"WARN",name:"migration_stale_import",remediation:"Replace the call with its Lunora equivalent and drop the dependency. If the import is deliberate — a second data source you still read from — move it out of `lunora/` so it is not mistaken for an unfinished migration.",run:r=>r.staleMigrationImports===void 0?[]:r.staleMigrationImports.map(e=>a(m,{cacheKey:`migration_stale_import:${e.file}:${e.line.toString()}:${e.moduleSpecifier}`,detail:`\`${e.file}\` (line ${e.line.toString()}) still imports \`${e.moduleSpecifier}\`. Finish the port — see \`${Uo[e.platform]}\` — or move the import out of \`lunora/\` if you genuinely still read from ${e.platform}.`,metadata:{file:e.file,line:e.line,moduleSpecifier:e.moduleSpecifier,platform:e.platform}})),source:"static",title:"Stale migration import"},To=new Map([["global",{level:"WARN",scope:r=>`it reads the whole D1 table "${r}" over a cross-region round trip`}],["root",{level:"WARN",scope:r=>`it loads every row of "${r}" from the root Durable Object's SQLite into memory`}],["shardBy",{level:"INFO",scope:r=>`"${r}" is \`.shardBy()\`, so this collects one shard's rows rather than the whole table — bounded by a single tenant's row count`}]]),Wo={level:"WARN",scope:r=>`it loads every row of "${r}"`},s={categories:["PERFORMANCE"],description:"A query calls `.collect()` with no `.withIndex()` and no `.filter()`, so it materializes every row of the table. Any live subscription over it also re-sends that whole result to every subscribed client on every write to the table.",facing:"EXTERNAL",level:"WARN",name:"unbounded_collect",remediation:'Narrow the read with `.withIndex("name", (q) => q.eq(...))`, cap it with `.take(n)`, or page it with `.paginate(args.paginationOpts)` so neither the scan nor the subscription payload grows with the table.',run:r=>{const e=[],n=lo(r.schema);for(const o of r.queries??[]){if(o.terminal!=="collect"||o.hasIndex||o.table===""||o.hasFilter)continue;const t=n.get(o.table),{level:i,scope:l}=To.get(t??"")??Wo,p=po(o),f=i==="WARN"?` A live subscription over this query records a whole-table dependency, so every write to "${o.table}" re-runs it and re-sends the full result to each subscribed socket.`:" Cap it with `.take(n)` if that count can grow.";e.push(a(s,{cacheKey:`unbounded_collect:${o.file}:${o.line.toString()}:${o.table}`,detail:`Query on "${o.table}" at ${p} calls .collect() with no index and no filter — ${l(o.table)}.${f}`,level:i,metadata:{...fo(o),shardKind:t??"unknown",table:o.table}}))}return e},source:"static",title:"Unbounded collect"},Io=[ce,Be,He,Ao,vo,Xe,Q,X,Z,B,ne,j,te,ie,V,so,O,M,K,G,go,bo,ao,H,no,Ro,Le,qe,_,mo,Y,ee,J,s,co,uo,z,Ve,Qe,we,ve,Ae,le,Ke,U,Fe,je,be,ye,E,D,P,De,yo,So,Ze,Ee,ho,ae,Ye,y,Ce,he,_e,k,Oe,$e,de,A,g,b,xe,oo,ue,$,S,w,wo,ge,F,Me,q,L,I,N,T,x,W,C,fe,Ge,Pe,R,We,to,io,eo,ro,me,se,ze,oe,re,v,pe,Ne,Je,Se,Ie,Re,Te,Ue,ke,m],xo=[u,h,d],Co=[...Io,...xo],qt=(r,e={})=>{const n=e.lints??Co,o=[];for(const t of n)if(!(e.source!==void 0&&t.source!==e.source))try{o.push(...t.run(r))}catch(i){o.push({cacheKey:`advisor_lint_failed:${t.name}`,categories:t.categories,description:"An advisor lint threw while running, so its check did not run. This is a bug in the lint, not in your app.",detail:`The \`${t.name}\` lint threw: ${i instanceof Error?i.message:String(i)}. Its findings are missing from this run.`,facing:"INTERNAL",level:t.level,metadata:{lint:t.name},name:"advisor_lint_failed",remediation:"Report the error with the source shape that triggered it. Pass `--no-strict-advisories` to deploy past it in the meantime.",title:`Advisor lint \`${t.name}\` failed`})}return c(o)};export{Co as ALL_LINTS,ri as MAP_VERSION,xo as RUNTIME_LINTS,Io as STATIC_LINTS,g as actionFetchSsrf,b as actionWithoutErrorHandling,y as adminRouteWithoutGuard,S as aiRawRunEscapeHatch,w as aiRunWithoutLogging,v as aiToolSideEffectPromptInjection,A as aiUnboundedGenerationPublic,R as allowUnauthenticatedShardAccessEnabled,U as authApiCallWithoutHeaders,T as authCsrfCheckDisabled,W as authEmailVerificationDisabled,I as authScimWithoutTransactions,x as authSecureCookiesDisabled,C as authSessionFreshageZero,N as authTrustedOriginsWildcard,k as browserAllowPrivateTargets,F as browserUserUrlWithoutAllowlist,ti as byCodepoint,Gt as callSiteCallers,zt as callSiteDescription,Ht as callSiteLabel,Bt as callSiteMetadata,M as circularFk,ai as classifySensitivity,O as commitOrderedHardDelete,Zt as compareToBaseline,$ as containerInstanceKeyFromUserInput,E as containerLongSleepAfter,D as containerOversizedInstance,P as containerPublicInternet,L as containerRuntimeEgressRelaxation,q as containerStartEnableInternetOverride,K as countWithoutIndex,_ as cronEveryMinute,G as crossModuleTableWrite,c as dedupeCacheKeys,z as dispatchCycle,H as duplicateIndex,B as emptyIndex,j as errorWithoutCatalog,V as exportSinkMisconfigured,Q as externalSourceIncrementalNoDeletePath,X as externalSourceOnGlobal,Z as externalSourceUnscoped,d as fanOutBreadth,J as filterAfterIndexScan,Y as filterOnPrimaryKey,ee as filterWithoutIndex,oe as flagGatesSecurityWithUnsafeDefault,re as flagReadInSubscription,si as fromServerSchema,te as geoIndexFieldNotGeopoint,ie as geoIndexUnused,ne as globalTableNearColumnLimit,ei as gradeFromScore,ae as hardcodedSecret,jt as helperRole,u as hotShard,me as httpActionMissingAuthGuard,se as httpActionResponseHeaderInjection,le as hyperdriveOutsideAction,pe as identityUndeclaredClaimTrusted,fe as imagesUrlSourceFromUserInput,ce as indexReferencesUnknownField,h as indexUtilization,de as insertManyUnsafeUserData,Vt as isReachableSite,ue as kvUnscopedUserKeyIdor,he as mailInboundDispatchWithoutVerify,ge as mailRecipientFromRequestInput,be as maskUncoveredPiiColumn,ye as maskWeakHashStrategyOnPii,Se as maskedRelationLeakViaWith,we as mutatorFullRowReplace,ve as mutatorWithoutOwnerScope,Ae as nondeterministicQueryMutation,Re as normalizeIdUsedAsAuthorization,Ue as notifyMissingPushConfig,Te as notifySendOutsideAction,We as openShardAccess,Ie as outputProjectionMissingOnPublicRead,xe as ownerFieldFromArgsNotAuth,Jt as parseAdvisorMap,Ce as paymentCreateWithoutAuthorize,Ne as paymentWebhookWideTolerance,ke as plaintextSecretInWranglerVariables,Fe as policyReferencesUnknownTable,Me as privilegedDispatchUnvalidatedPayload,Oe as privilegedFanoutFromPublicProcedure,$e as procedureWithoutStructuredEvent,Ee as publicArgumentUsesAny,De as publicMutationWithoutRatelimit,Pe as publicTableRlsOptoutConfusion,Le as queueDispatchCycle,qe as queueWithoutDlq,Ke as r2sqlOutsideAction,_e as ratelimitDefaultMemoryStore,Ge as ratelimitKeySpoofableOrGlobal,ze as ratelimitMiddlewareFailOpen,Qt as readCallSiteCallers,He as relationReferencesUnknownField,Be as relationReferencesUnknownTable,je as rlsUncoveredTable,qt as runAdvisor,ii as scoreAdvisor,Ve as selfRescheduleWithoutProgress,Qe as shapeTargetsGlobalTable,Xe as shapeUnknownTable,Ze as signupMutationWithoutDisposableGating,Je as softDeleteIncludeDeletedFromArgs,Ye as sqlInjectionRisk,eo as storageGenerateUploadUrlNoContentTypePin,oo as storageKeyFromUserArgs,ro as storagePresignedUrlForPrivateContent,to as storageUploadWithoutContentTypeAllowlist,io as storageUploadWithoutMaxSize,no as tableWithoutInsert,ao as throughRelationMissingUniqueIndex,mo as topicTooManySubscriptions,so as ttlFieldNotTimestamp,co as unboundedCollectOnOpenRange,uo as unboundedLoop,ho as unboundedStringArgument,go as unindexedForeignKey,bo as unindexedRelationTarget,yo as unrestrictedWhereBranch,So as userCreatingMutationWithoutCaptcha,wo as vectorsNamespaceFromUserInput,vo as workflowDuplicateStepName,Ao as workflowUnknownTarget,Ro as workflowUnused};
1
+ import{dedupeCacheKeys as c}from"./packem_shared/dedupeCacheKeys-DtBOHffV.mjs";import d from"./packem_shared/fanOutBreadth-CBtmZnoh.mjs";import u from"./packem_shared/hotShard-BwGYZ3Tq.mjs";import h from"./packem_shared/indexUtilization-CmtN9-HA.mjs";import g from"./packem_shared/actionFetchSsrf-B7FqsLWm.mjs";import b from"./packem_shared/actionWithoutErrorHandling-DK3rB5c-.mjs";import y from"./packem_shared/adminRouteWithoutGuard-CcdlN75o.mjs";import S from"./packem_shared/aiRawRunEscapeHatch-CzIaQf_v.mjs";import w from"./packem_shared/aiRunWithoutLogging-Ct5MeKWe.mjs";import v from"./packem_shared/aiToolSideEffectPromptInjection-Ck_h8tFx.mjs";import A from"./packem_shared/aiUnboundedGenerationPublic-CzF3xBc3.mjs";import R from"./packem_shared/allowUnauthenticatedShardAccessEnabled-BQufF5Kb.mjs";import U from"./packem_shared/authApiCallWithoutHeaders-9PpziIB9.mjs";import T from"./packem_shared/authCsrfCheckDisabled-DYTzZFpp.mjs";import W from"./packem_shared/authEmailVerificationDisabled-OiNes7Dz.mjs";import I from"./packem_shared/authScimWithoutTransactions-CajXH24D.mjs";import x from"./packem_shared/authSecureCookiesDisabled-CA5zyqDZ.mjs";import C from"./packem_shared/authSessionFreshageZero-C3IYlYft.mjs";import N from"./packem_shared/authTrustedOriginsWildcard-661FRsGe.mjs";import k from"./packem_shared/browserAllowPrivateTargets-Cj5sizhv.mjs";import F from"./packem_shared/browserUserUrlWithoutAllowlist-Bi5ZWTF7.mjs";import M from"./packem_shared/circularFk-DtcWFJxK.mjs";import O from"./packem_shared/commitOrderedHardDelete-dmDVELQ0.mjs";import $ from"./packem_shared/containerInstanceKeyFromUserInput-DHQ2JL4x.mjs";import E from"./packem_shared/containerLongSleepAfter-DSGnfpfl.mjs";import D from"./packem_shared/containerOversizedInstance-INKmy3-D.mjs";import P from"./packem_shared/containerPublicInternet-Csh5_RwX.mjs";import L from"./packem_shared/containerRuntimeEgressRelaxation-J6rpfvr8.mjs";import q from"./packem_shared/containerStartEnableInternetOverride-Bxbmrpwe.mjs";import K from"./packem_shared/countWithoutIndex-CTbdpLyE.mjs";import _ from"./packem_shared/cronEveryMinute-BjdRdTEz.mjs";import G from"./packem_shared/crossModuleTableWrite-DuIFwf3x.mjs";import z from"./packem_shared/dispatchCycle-BwuXRDiL.mjs";import H from"./packem_shared/duplicateIndex-DkuQfUJ7.mjs";import B from"./packem_shared/emptyIndex-CeS4ZF5O.mjs";import j from"./packem_shared/errorWithoutCatalog-Dib0sdSD.mjs";import V from"./packem_shared/exportSinkMisconfigured-JfbAx9AI.mjs";import Q from"./packem_shared/externalSourceIncrementalNoDeletePath-DrcLlb76.mjs";import X from"./packem_shared/externalSourceOnGlobal-WQbJ74fq.mjs";import Z from"./packem_shared/externalSourceUnscoped-BxU2uSXk.mjs";import J from"./packem_shared/filterAfterIndexScan-BTHjxkNi.mjs";import Y from"./packem_shared/filterOnPrimaryKey-DeRYfLa7.mjs";import ee from"./packem_shared/filterWithoutIndex-8VrXwbq5.mjs";import oe from"./packem_shared/flagGatesSecurityWithUnsafeDefault-CJK9sKcH.mjs";import re from"./packem_shared/flagReadInSubscription-DabIhYGD.mjs";import te from"./packem_shared/geoIndexFieldNotGeopoint-DcFi2zOK.mjs";import ie from"./packem_shared/geoIndexUnused-DgVtk2z_.mjs";import ne from"./packem_shared/globalTableNearColumnLimit-CTvIcQ5e.mjs";import ae from"./packem_shared/hardcodedSecret-Bw_4FYrs.mjs";import me from"./packem_shared/httpActionMissingAuthGuard-D58Vnjr0.mjs";import se from"./packem_shared/httpActionResponseHeaderInjection-Yn1pbKZ8.mjs";import le from"./packem_shared/hyperdriveOutsideAction-CPDdGP2g.mjs";import pe from"./packem_shared/identityUndeclaredClaimTrusted-Z-9ob8F2.mjs";import fe from"./packem_shared/imagesUrlSourceFromUserInput-a2CZ-Xnj.mjs";import ce from"./packem_shared/indexReferencesUnknownField-Bs2DiZqb.mjs";import de from"./packem_shared/insertManyUnsafeUserData-CSvy65sr.mjs";import ue from"./packem_shared/kvUnscopedUserKeyIdor-D0O2alyn.mjs";import he from"./packem_shared/mailInboundDispatchWithoutVerify-CWwqXyPX.mjs";import ge from"./packem_shared/mailRecipientFromRequestInput-BMrAJjNK.mjs";import be from"./packem_shared/maskUncoveredPiiColumn-BJ1prEd0.mjs";import ye from"./packem_shared/maskWeakHashStrategyOnPii-dQPsGXl0.mjs";import Se from"./packem_shared/maskedRelationLeakViaWith-CIFij6vE.mjs";import{e as a}from"./packem_shared/finding-NrKO8idM.mjs";import we from"./packem_shared/mutatorFullRowReplace-NuqUCVOI.mjs";import ve from"./packem_shared/mutatorWithoutOwnerScope-BoS81ns0.mjs";import Ae from"./packem_shared/nondeterministicQueryMutation-DA_Lq_IE.mjs";import Re from"./packem_shared/normalizeIdUsedAsAuthorization-BXN-Can6.mjs";import Ue from"./packem_shared/notifyMissingPushConfig-BYks8FAs.mjs";import Te from"./packem_shared/notifySendOutsideAction-BJrDkr4h.mjs";import We from"./packem_shared/openShardAccess-CVMAgmmY.mjs";import Ie from"./packem_shared/outputProjectionMissingOnPublicRead-BPS-eg2q.mjs";import xe from"./packem_shared/ownerFieldFromArgsNotAuth-BmKLZxrX.mjs";import Ce from"./packem_shared/paymentCreateWithoutAuthorize-CdenWpXD.mjs";import Ne from"./packem_shared/paymentWebhookWideTolerance-D9i3Vb1n.mjs";import ke from"./packem_shared/plaintextSecretInWranglerVariables-Bs1RvhjG.mjs";import Fe from"./packem_shared/policyReferencesUnknownTable-DiQYFRFY.mjs";import Me from"./packem_shared/privilegedDispatchUnvalidatedPayload-BJL0JNzG.mjs";import Oe from"./packem_shared/privilegedFanoutFromPublicProcedure-Byw3Prsi.mjs";import $e from"./packem_shared/procedureWithoutStructuredEvent-na08a0M1.mjs";import Ee from"./packem_shared/publicArgumentUsesAny-BDEvMA8Q.mjs";import De from"./packem_shared/publicMutationWithoutRatelimit-DAxh8tL0.mjs";import Pe from"./packem_shared/publicTableRlsOptoutConfusion-DMqePR7i.mjs";import Le from"./packem_shared/queueDispatchCycle-84yt1IR-.mjs";import qe from"./packem_shared/queueWithoutDlq-CF_xUgE_.mjs";import Ke from"./packem_shared/r2sqlOutsideAction-BdLiLOAX.mjs";import _e from"./packem_shared/ratelimitDefaultMemoryStore-Dj0Kk7t9.mjs";import Ge from"./packem_shared/ratelimitKeySpoofableOrGlobal-VSGOuu5X.mjs";import ze from"./packem_shared/ratelimitMiddlewareFailOpen-bweBVZ4J.mjs";import He from"./packem_shared/relationReferencesUnknownField-Cb9BSxHl.mjs";import Be from"./packem_shared/relationReferencesUnknownTable-COkvw71e.mjs";import je from"./packem_shared/rlsUncoveredTable-e2FhD6Nr.mjs";import Ve from"./packem_shared/selfRescheduleWithoutProgress-HoknmezK.mjs";import Qe from"./packem_shared/shapeTargetsGlobalTable-CYRV8OvU.mjs";import Xe from"./packem_shared/shapeUnknownTable-6virkUOz.mjs";import Ze from"./packem_shared/signupMutationWithoutDisposableGating-nopEfEEK.mjs";import Je from"./packem_shared/softDeleteIncludeDeletedFromArgs-C7Ugg4zb.mjs";import Ye from"./packem_shared/sqlInjectionRisk-CSKho3Vk.mjs";import eo from"./packem_shared/storageGenerateUploadUrlNoContentTypePin-BlOPGwhZ.mjs";import oo from"./packem_shared/storageKeyFromUserArgs-BuoTsz-h.mjs";import ro from"./packem_shared/storagePresignedUrlForPrivateContent-l-EwrAfj.mjs";import to from"./packem_shared/storageUploadWithoutContentTypeAllowlist-JmITAazT.mjs";import io from"./packem_shared/storageUploadWithoutMaxSize-DlhE1I98.mjs";import no from"./packem_shared/tableWithoutInsert-CgQyPF1P.mjs";import ao from"./packem_shared/throughRelationMissingUniqueIndex-DfVfPdjK.mjs";import mo from"./packem_shared/topicTooManySubscriptions-B1SiGfHM.mjs";import so from"./packem_shared/ttlFieldNotTimestamp-BM9uNTT8.mjs";import{s as lo,q as po,c as fo}from"./packem_shared/helpers-YAAwOBMH.mjs";import co from"./packem_shared/unboundedCollectOnOpenRange-DDGNuKks.mjs";import uo from"./packem_shared/unboundedLoop-CUF9Wdxa.mjs";import ho from"./packem_shared/unboundedStringArgument-jZnCbwB0.mjs";import go from"./packem_shared/unindexedForeignKey-ClyKvTnR.mjs";import bo from"./packem_shared/unindexedRelationTarget-C2t48b-z.mjs";import yo from"./packem_shared/unrestrictedWhereBranch-CcIBmHik.mjs";import So from"./packem_shared/userCreatingMutationWithoutCaptcha-8mtYqiGy.mjs";import wo from"./packem_shared/vectorsNamespaceFromUserInput-537Bt2vT.mjs";import vo from"./packem_shared/workflowDuplicateStepName-B6eAJzwA.mjs";import Ao from"./packem_shared/workflowUnknownTarget-DdG3cUPH.mjs";import Ro from"./packem_shared/workflowUnused-CSKRWTd_.mjs";import{callSiteCallers as Gt,callSiteDescription as zt,callSiteLabel as Ht,callSiteMetadata as Bt,helperRole as jt,isReachableSite as Vt,readCallSiteCallers as Qt}from"./packem_shared/callSiteCallers-DArHfQSU.mjs";import{compareToBaseline as Zt,parseAdvisorMap as Jt}from"./packem_shared/compareToBaseline-CbHQTuNW.mjs";import{gradeFromScore as ei}from"./packem_shared/gradeFromScore-KSt58rj1.mjs";import{MAP_VERSION as ri,byCodepoint as ti,scoreAdvisor as ii}from"./packem_shared/MAP_VERSION-BdyirFdd.mjs";import{default as ai}from"./packem_shared/classifySensitivity-JnjaTGYi.mjs";import{fromServerSchema as si}from"./packem_shared/fromServerSchema-KWJd4PLE.mjs";const Uo={convex:"migrating/from-convex",firebase:"migrating/from-firebase",supabase:"migrating/from-supabase"},m={categories:["SCHEMA"],description:"A migrated-away platform's SDK is still imported from `lunora/` source. The code compiles and typechecks, so a half-finished port keeps reading from the old platform at runtime and the two stores silently drift apart.",facing:"INTERNAL",level:"WARN",name:"migration_stale_import",remediation:"Replace the call with its Lunora equivalent and drop the dependency. If the import is deliberate — a second data source you still read from — move it out of `lunora/` so it is not mistaken for an unfinished migration.",run:r=>r.staleMigrationImports===void 0?[]:r.staleMigrationImports.map(e=>a(m,{cacheKey:`migration_stale_import:${e.file}:${e.line.toString()}:${e.moduleSpecifier}`,detail:`\`${e.file}\` (line ${e.line.toString()}) still imports \`${e.moduleSpecifier}\`. Finish the port — see \`${Uo[e.platform]}\` — or move the import out of \`lunora/\` if you genuinely still read from ${e.platform}.`,metadata:{file:e.file,line:e.line,moduleSpecifier:e.moduleSpecifier,platform:e.platform}})),source:"static",title:"Stale migration import"},To=new Map([["global",{level:"WARN",scope:r=>`it reads the whole D1 table "${r}" over a cross-region round trip`}],["root",{level:"WARN",scope:r=>`it loads every row of "${r}" from the root Durable Object's SQLite into memory`}],["shardBy",{level:"INFO",scope:r=>`"${r}" is \`.shardBy()\`, so this collects one shard's rows rather than the whole table — bounded by a single tenant's row count`}]]),Wo={level:"WARN",scope:r=>`it loads every row of "${r}"`},s={categories:["PERFORMANCE"],description:"A query calls `.collect()` with no `.withIndex()` and no `.filter()`, so it materializes every row of the table. Any live subscription over it also re-sends that whole result to every subscribed client on every write to the table.",facing:"EXTERNAL",level:"WARN",name:"unbounded_collect",remediation:'Narrow the read with `.withIndex("name", (q) => q.eq(...))`, cap it with `.take(n)`, or page it with `.paginate(args.paginationOpts)` so neither the scan nor the subscription payload grows with the table.',run:r=>{const e=[],n=lo(r.schema);for(const o of r.queries??[]){if(o.terminal!=="collect"||o.hasIndex||o.table===""||o.hasFilter)continue;const t=n.get(o.table),{level:i,scope:l}=To.get(t??"")??Wo,p=po(o),f=i==="WARN"?` A live subscription over this query records a whole-table dependency, so every write to "${o.table}" re-runs it and re-sends the full result to each subscribed socket.`:" Cap it with `.take(n)` if that count can grow.";e.push(a(s,{cacheKey:`unbounded_collect:${o.file}:${o.line.toString()}:${o.table}`,detail:`Query on "${o.table}" at ${p} calls .collect() with no index and no filter — ${l(o.table)}.${f}`,level:i,metadata:{...fo(o),shardKind:t??"unknown",table:o.table}}))}return e},source:"static",title:"Unbounded collect"},Io=[ce,Be,He,Ao,vo,Xe,Q,X,Z,B,ne,j,te,ie,V,so,O,M,K,G,go,bo,ao,H,no,Ro,Le,qe,_,mo,Y,ee,J,s,co,uo,z,Ve,Qe,we,ve,Ae,le,Ke,U,Fe,je,be,ye,E,D,P,De,yo,So,Ze,Ee,ho,ae,Ye,y,Ce,he,_e,k,Oe,$e,de,A,g,b,xe,oo,ue,$,S,w,wo,ge,F,Me,q,L,I,N,T,x,W,C,fe,Ge,Pe,R,We,to,io,eo,ro,me,se,ze,oe,re,v,pe,Ne,Je,Se,Ie,Re,Te,Ue,ke,m],xo=[u,h,d],Co=[...Io,...xo],qt=(r,e={})=>{const n=e.lints??Co,o=[];for(const t of n)if(!(e.source!==void 0&&t.source!==e.source))try{o.push(...t.run(r))}catch(i){o.push({cacheKey:`advisor_lint_failed:${t.name}`,categories:t.categories,description:"An advisor lint threw while running, so its check did not run. This is a bug in the lint, not in your app.",detail:`The \`${t.name}\` lint threw: ${i instanceof Error?i.message:String(i)}. Its findings are missing from this run.`,facing:"INTERNAL",level:t.level,metadata:{lint:t.name},name:"advisor_lint_failed",remediation:"Report the error with the source shape that triggered it. Pass `--no-strict-advisories` to deploy past it in the meantime.",title:`Advisor lint \`${t.name}\` failed`})}return c(o)};export{Co as ALL_LINTS,ri as MAP_VERSION,xo as RUNTIME_LINTS,Io as STATIC_LINTS,g as actionFetchSsrf,b as actionWithoutErrorHandling,y as adminRouteWithoutGuard,S as aiRawRunEscapeHatch,w as aiRunWithoutLogging,v as aiToolSideEffectPromptInjection,A as aiUnboundedGenerationPublic,R as allowUnauthenticatedShardAccessEnabled,U as authApiCallWithoutHeaders,T as authCsrfCheckDisabled,W as authEmailVerificationDisabled,I as authScimWithoutTransactions,x as authSecureCookiesDisabled,C as authSessionFreshageZero,N as authTrustedOriginsWildcard,k as browserAllowPrivateTargets,F as browserUserUrlWithoutAllowlist,ti as byCodepoint,Gt as callSiteCallers,zt as callSiteDescription,Ht as callSiteLabel,Bt as callSiteMetadata,M as circularFk,ai as classifySensitivity,O as commitOrderedHardDelete,Zt as compareToBaseline,$ as containerInstanceKeyFromUserInput,E as containerLongSleepAfter,D as containerOversizedInstance,P as containerPublicInternet,L as containerRuntimeEgressRelaxation,q as containerStartEnableInternetOverride,K as countWithoutIndex,_ as cronEveryMinute,G as crossModuleTableWrite,c as dedupeCacheKeys,z as dispatchCycle,H as duplicateIndex,B as emptyIndex,j as errorWithoutCatalog,V as exportSinkMisconfigured,Q as externalSourceIncrementalNoDeletePath,X as externalSourceOnGlobal,Z as externalSourceUnscoped,d as fanOutBreadth,J as filterAfterIndexScan,Y as filterOnPrimaryKey,ee as filterWithoutIndex,oe as flagGatesSecurityWithUnsafeDefault,re as flagReadInSubscription,si as fromServerSchema,te as geoIndexFieldNotGeopoint,ie as geoIndexUnused,ne as globalTableNearColumnLimit,ei as gradeFromScore,ae as hardcodedSecret,jt as helperRole,u as hotShard,me as httpActionMissingAuthGuard,se as httpActionResponseHeaderInjection,le as hyperdriveOutsideAction,pe as identityUndeclaredClaimTrusted,fe as imagesUrlSourceFromUserInput,ce as indexReferencesUnknownField,h as indexUtilization,de as insertManyUnsafeUserData,Vt as isReachableSite,ue as kvUnscopedUserKeyIdor,he as mailInboundDispatchWithoutVerify,ge as mailRecipientFromRequestInput,be as maskUncoveredPiiColumn,ye as maskWeakHashStrategyOnPii,Se as maskedRelationLeakViaWith,we as mutatorFullRowReplace,ve as mutatorWithoutOwnerScope,Ae as nondeterministicQueryMutation,Re as normalizeIdUsedAsAuthorization,Ue as notifyMissingPushConfig,Te as notifySendOutsideAction,We as openShardAccess,Ie as outputProjectionMissingOnPublicRead,xe as ownerFieldFromArgsNotAuth,Jt as parseAdvisorMap,Ce as paymentCreateWithoutAuthorize,Ne as paymentWebhookWideTolerance,ke as plaintextSecretInWranglerVariables,Fe as policyReferencesUnknownTable,Me as privilegedDispatchUnvalidatedPayload,Oe as privilegedFanoutFromPublicProcedure,$e as procedureWithoutStructuredEvent,Ee as publicArgumentUsesAny,De as publicMutationWithoutRatelimit,Pe as publicTableRlsOptoutConfusion,Le as queueDispatchCycle,qe as queueWithoutDlq,Ke as r2sqlOutsideAction,_e as ratelimitDefaultMemoryStore,Ge as ratelimitKeySpoofableOrGlobal,ze as ratelimitMiddlewareFailOpen,Qt as readCallSiteCallers,He as relationReferencesUnknownField,Be as relationReferencesUnknownTable,je as rlsUncoveredTable,qt as runAdvisor,ii as scoreAdvisor,Ve as selfRescheduleWithoutProgress,Qe as shapeTargetsGlobalTable,Xe as shapeUnknownTable,Ze as signupMutationWithoutDisposableGating,Je as softDeleteIncludeDeletedFromArgs,Ye as sqlInjectionRisk,eo as storageGenerateUploadUrlNoContentTypePin,oo as storageKeyFromUserArgs,ro as storagePresignedUrlForPrivateContent,to as storageUploadWithoutContentTypeAllowlist,io as storageUploadWithoutMaxSize,no as tableWithoutInsert,ao as throughRelationMissingUniqueIndex,mo as topicTooManySubscriptions,so as ttlFieldNotTimestamp,co as unboundedCollectOnOpenRange,uo as unboundedLoop,ho as unboundedStringArgument,go as unindexedForeignKey,bo as unindexedRelationTarget,yo as unrestrictedWhereBranch,So as userCreatingMutationWithoutCaptcha,wo as vectorsNamespaceFromUserInput,vo as workflowDuplicateStepName,Ao as workflowUnknownTarget,Ro as workflowUnused};
@@ -0,0 +1 @@
1
+ import{readCallSiteCallers as S}from"./callSiteCallers-DArHfQSU.mjs";import{scoreProcedure as w,procedureWeight as b,coverageFromScore as k,scoreGlobal as M,projectWeight as j,gradeFromScore as N,weightFor as C,worstLevel as F}from"./gradeFromScore-KSt58rj1.mjs";import P from"./classifySensitivity-JnjaTGYi.mjs";const y=(e,t)=>e===t?0:e<t?-1:1,x=(e,t)=>y(e.name,t.name),A=(e,t)=>{const n=e[t];return typeof n=="string"?n:void 0},g=(e,t)=>`${e}#${t}`,I=(e,t,n,c)=>e===void 0?{level:t,name:n,occurrences:1,weight:c}:{level:F(e.level,t),name:n,occurrences:e.occurrences+1,weight:Math.max(e.weight,c)},R=(e,t)=>{const n=new Map;for(const o of e)n.set(g(o.file,o.exportName),new Map);const c=new Map;for(const o of t){const s=A(o.metadata,"file"),m=S(o.metadata),i=s===void 0?[]:m.flatMap(l=>n.get(g(s,l))??[]),d=i.length===0?[c]:i;for(const l of d)l.set(o.name,I(l.get(o.name),o.level,o.name,C(o.level)))}return{byProcedure:new Map([...n].map(([o,s])=>[o,[...s.values()].toSorted(x)])),project:[...c.values()].toSorted(x)}},W=(e,t,n)=>{const c={clean:0,exempt:0,failing:0,warned:0};let o=t.checks.length;for(const s of e)c[s.coverage]+=1,o+=s.checks.length;return{clean:c.clean,exempt:c.exempt,failing:c.failing,procedures:e.length,rulesFired:o,suppressed:n,warned:c.warned}},E=1,D=(e,t,n={})=>{const c=new Set(n.exempt),o=t.filter(r=>r.suppressed===void 0),s=R(e,o),m=e.map(r=>{const a=g(r.file,r.exportName),u=s.byProcedure.get(a)??[],h=w(u),p=c.has(a)||r.exempt===!0,v=P(r);return{checks:u,coverage:p?"exempt":k(h),...p?{exemptReason:r.exemptReason??""}:{},exportName:r.exportName,file:r.file,id:a,kind:r.kind,score:h,sensitivity:v,visibility:r.visibility,weight:p?0:b(r,v.level)}}).toSorted((r,a)=>y(r.id,a.id)),i={checks:s.project,score:w(s.project)},d=m.filter(r=>r.coverage!=="exempt"),l=d.reduce((r,a)=>r+a.weight,0),f=M([...d,{score:i.score,weight:j(l)}]);return{generatedAt:n.generatedAt??new Date().toISOString(),grade:N(f),procedures:m,project:i,score:f,summary:W(m,i,t.length-o.length),version:E}};export{E as MAP_VERSION,y as byCodepoint,D as scoreAdvisor};
@@ -0,0 +1 @@
1
+ import{e as a}from"./finding-NrKO8idM.mjs";import{d as r}from"./helpers-YAAwOBMH.mjs";const i={categories:["SCHEMA"],description:"A `.commitOrdered()` table without `.softDelete()` cannot express a delete in its `_commitSeq` feed: the sequence lives on the row, so a hard-deleted row vanishes with no event a consumer can observe.",facing:"INTERNAL",level:"WARN",name:"commit_ordered_hard_delete",remediation:"Add `.softDelete()` so the tombstone flip advances `_commitSeq` and pages through the feed — or, if the table is genuinely append-only and nothing is ever deleted from it, leave it as-is.",run:o=>{const t=[];for(const e of o.schema.tables)e.commitOrdered!==!0||e.softDelete!==void 0||t.push(a(i,{cacheKey:`commit_ordered_hard_delete:${e.name}`,detail:`Table "${e.name}" is \`.commitOrdered()\` but not \`.softDelete()\`. A hard delete removes the row and its \`_commitSeq\` together, so a changefeed paging on the sequence never learns the row is gone.`,metadata:{...r(e),table:e.name}}));return t},source:"static",title:"Commit-ordered table cannot express deletes"};export{i as default};
@@ -1 +1 @@
1
- import{byCodepoint as f}from"./MAP_VERSION-MQ5W2B6n.mjs";const m=new Set(["clean","exempt","failing","warned"]),u=(e,r)=>{const c=new Map(e.map(s=>[s.name,s.occurrences]));return r.some(s=>s.occurrences>(c.get(s.name)??0))},n=e=>typeof e=="number"&&Number.isFinite(e),g=e=>Array.isArray(e)&&e.every(r=>{if(typeof r!="object"||r===null)return!1;const c=r;return typeof c.name=="string"&&n(c.occurrences)}),h=e=>{if(typeof e!="object"||e===null)return!1;const r=e;return typeof r.id=="string"&&n(r.score)&&typeof r.coverage=="string"&&m.has(r.coverage)&&g(r.checks)},y=e=>{if(typeof e!="object"||e===null)return!1;const r=e;return g(r.checks)&&n(r.score)},v=(e,r)=>{if(r.version!==e.version)return{comparable:!1,reason:"version-mismatch"};const c=new Map(r.procedures.map(o=>[o.id,o])),s=[],i=[],p=[];for(const o of e.procedures){if(o.coverage==="exempt")continue;const t=c.get(o.id);t!==void 0&&t.coverage!=="exempt"&&o.score<t.score&&s.push({after:o.score,before:t.score,id:o.id}),o.coverage==="failing"&&t?.coverage!=="failing"&&i.push(o.id),u(t?.checks??[],o.checks)&&p.push(o.id)}s.sort((o,t)=>f(o.id,t.id)),i.sort(f),p.sort(f);const a=e.score-r.score,d=u(r.project.checks,e.project.checks);return{comparable:!0,dropped:s,newFailing:i,projectRegressed:d,regressed:a<0||s.length>0||i.length>0||p.length>0||d,scoreDelta:a,worsened:p}},b=e=>{if(typeof e!="object"||e===null)return;const r=e;if(!(!n(r.version)||!n(r.score))&&!(!Array.isArray(r.procedures)||!r.procedures.every(c=>h(c)))&&y(r.project))return e};export{v as compareToBaseline,b as parseAdvisorMap};
1
+ import{byCodepoint as f}from"./MAP_VERSION-BdyirFdd.mjs";const m=new Set(["clean","exempt","failing","warned"]),u=(e,r)=>{const c=new Map(e.map(s=>[s.name,s.occurrences]));return r.some(s=>s.occurrences>(c.get(s.name)??0))},n=e=>typeof e=="number"&&Number.isFinite(e),g=e=>Array.isArray(e)&&e.every(r=>{if(typeof r!="object"||r===null)return!1;const c=r;return typeof c.name=="string"&&n(c.occurrences)}),h=e=>{if(typeof e!="object"||e===null)return!1;const r=e;return typeof r.id=="string"&&n(r.score)&&typeof r.coverage=="string"&&m.has(r.coverage)&&g(r.checks)},y=e=>{if(typeof e!="object"||e===null)return!1;const r=e;return g(r.checks)&&n(r.score)},v=(e,r)=>{if(r.version!==e.version)return{comparable:!1,reason:"version-mismatch"};const c=new Map(r.procedures.map(o=>[o.id,o])),s=[],i=[],p=[];for(const o of e.procedures){if(o.coverage==="exempt")continue;const t=c.get(o.id);t!==void 0&&t.coverage!=="exempt"&&o.score<t.score&&s.push({after:o.score,before:t.score,id:o.id}),o.coverage==="failing"&&t?.coverage!=="failing"&&i.push(o.id),u(t?.checks??[],o.checks)&&p.push(o.id)}s.sort((o,t)=>f(o.id,t.id)),i.sort(f),p.sort(f);const a=e.score-r.score,d=u(r.project.checks,e.project.checks);return{comparable:!0,dropped:s,newFailing:i,projectRegressed:d,regressed:a<0||s.length>0||i.length>0||p.length>0||d,scoreDelta:a,worsened:p}},b=e=>{if(typeof e!="object"||e===null)return;const r=e;if(!(!n(r.version)||!n(r.score))&&!(!Array.isArray(r.procedures)||!r.procedures.every(c=>h(c)))&&y(r.project))return e};export{v as compareToBaseline,b as parseAdvisorMap};
@@ -0,0 +1 @@
1
+ import{callSiteMetadata as h,callSiteDescription as f,callSiteLabel as p}from"./callSiteCallers-DArHfQSU.mjs";import{e as w}from"./finding-NrKO8idM.mjs";const b=(n,l)=>n.find(a=>a.ownsFolder!==!1&&l.startsWith(`${a.name}/`))?.name,g={categories:["SCHEMA"],description:"A function writes to a table that a different module declares it owns (`defineModule({ tables })`), or to an installed component's table from outside the component. The write couples the two modules: the owner can no longer change the table's shape or invariants without breaking a caller it does not know about.",facing:"INTERNAL",level:"WARN",name:"cross_module_table_write",remediation:"Move the write into the owning module and call it from there: an exported helper in the owner's files that takes the caller's `ctx` (`openInvoice(ctx, …)`) keeps the write in the caller's invocation, and a registered owner mutation runs through `ctx.runMutation(internal.<owner>.<fn>, …)`. Or move the table's ownership to the module that writes it. For a component's table, call the function the component exports for that write.",run:n=>{const l=n.modules??[],a=new Map(l.flatMap(e=>e.tables.map(t=>[t,e]))),i=[...n.inserts??[],...n.tableWrites??[]];if(a.size===0||i.length===0)return[];const c=e=>`cross_module_table_write:${e.file}:${p(e.scope)}:${e.table}`,r=new Map;for(const e of i){const t=c(e),o=r.get(t);e.line>0&&(o===void 0||e.line<o)&&r.set(t,e.line)}const d=new Set;return i.flatMap(e=>{const t=a.get(e.table),o=b(l,e.file),s=c(e),m=r.get(s);if(t===void 0||t.name===o||d.has(s))return[];d.add(s);const u=t.installed===!0?`the installed component \`${t.name}\``:`module \`${t.name}\``;return[w(g,{cacheKey:s,detail:`${f(e.scope)} (${e.file}) writes to \`${e.table}\`, which ${u} owns, from ${o===void 0?"outside every module":`module \`${o}\``}.`,metadata:{...h(e.scope),file:e.file,...m===void 0?{}:{line:m},owner:t.name,table:e.table,...t.installed===!0?{installed:!0}:{},...o===void 0?{}:{writer:o}}})]})},source:"static",title:"Function writes a table another module owns"};export{g as default};
@@ -0,0 +1 @@
1
+ import{e as r}from"./finding-NrKO8idM.mjs";import{d as o}from"./helpers-YAAwOBMH.mjs";const l=(d,i)=>d.length>i.length?!1:d.every((n,s)=>n===i[s]),c={categories:["PERFORMANCE"],description:"A secondary index is redundant because another index already covers every lookup it serves (its columns are a leading prefix of the other's). The redundant index costs storage and is maintained on every write for no read benefit.",facing:"INTERNAL",level:"INFO",name:"duplicate_index",remediation:"Drop the redundant index; the covering index already serves its lookups.",run:d=>{const i=[];for(const n of d.schema.tables){const s=n.indexes.filter(e=>e.kind==="index");for(const e of s){if(e.unique===!0)continue;const t=s.find(a=>a===e||!l(e.fields,a.fields)?!1:e.fields.length===a.fields.length?a.unique===!0||e.name>a.name:!0);t&&i.push(r(c,{cacheKey:`duplicate_index:${n.name}:${e.name}`,detail:`Index "${e.name}" on table "${n.name}" (${e.fields.join(", ")}) is redundant — index "${t.name}" (${t.fields.join(", ")}) already covers its lookups.`,metadata:{...o(e),coveredBy:{fields:t.fields,name:t.name},fields:e.fields,index:e.name,table:n.name}}))}}return i},source:"static",title:"Duplicate / redundant index"};export{c as default};
@@ -0,0 +1 @@
1
+ import{e as t}from"./finding-NrKO8idM.mjs";import{d as i}from"./helpers-YAAwOBMH.mjs";const m={categories:["SCHEMA"],description:"An index declares no columns, so it indexes nothing and can never narrow a read.",facing:"INTERNAL",level:"WARN",name:"empty_index",remediation:"Give the index its columns, or remove it.",run:a=>a.schema.tables.flatMap(n=>n.indexes.filter(e=>e.kind==="index"&&e.fields.length===0).map(e=>t(m,{cacheKey:`empty_index:${n.name}:${e.name}`,detail:`Index "${e.name}" on table "${n.name}" declares no columns.`,metadata:{...i(e),index:e.name,table:n.name}}))),source:"static",title:"Empty index"};export{m as default};
@@ -0,0 +1 @@
1
+ import{e as n}from"./finding-NrKO8idM.mjs";import{d as l}from"./helpers-YAAwOBMH.mjs";const o={categories:["SCHEMA"],description:"A `.source({ mode: 'incremental' })` table declares no delete-visibility path (`reconcileEveryMs` or `softDeleteColumn`), so upstream deletes are never applied and the materialized table accumulates phantom rows.",facing:"EXTERNAL",level:"ERROR",name:"external_source_incremental_no_delete_path",remediation:"Add `reconcileEveryMs` (a periodic full-pull sweep that GCs vanished rows) or `softDeleteColumn` (an upstream tombstone column the incremental pull returns). Incremental ingest can't see a delete otherwise.",run:i=>{const a=[];for(const e of i.schema.tables){const t=e.externalSource;if(t!==void 0){if(t.unanalyzable){a.push(n(o,{cacheKey:`external_source_incremental_no_delete_path:${e.name}`,detail:`Table \`${e.name}\`'s \`.source(...)\` config is not a static object literal, so its \`mode\`/delete-visibility can't be verified. If it is \`mode: "incremental"\`, confirm it declares \`reconcileEveryMs\` or \`softDeleteColumn\` — an incremental source without one accumulates phantom rows on every upstream delete.`,level:"WARN",metadata:{...l(e),table:e.name}}));continue}t.mode!=="incremental"||t.hasReconcile||t.hasSoftDelete||a.push(n(o,{cacheKey:`external_source_incremental_no_delete_path:${e.name}`,detail:`Table \`${e.name}\` is \`.source({ mode: "incremental" })\` but declares neither \`reconcileEveryMs\` nor \`softDeleteColumn\` — an incremental pull never sees upstream deletes, so the materialized table would accumulate phantom rows. Add one of the two delete-visibility paths.`,metadata:{...l(e),table:e.name}}))}}return a},source:"static",title:"Incremental sourced table has no delete-visibility path"};export{o as default};
@@ -0,0 +1 @@
1
+ import{e as t}from"./finding-NrKO8idM.mjs";import{d as l}from"./helpers-YAAwOBMH.mjs";const o={categories:["SCHEMA"],description:"A table is both `.source(...)` and `.global()`. A global table lives in the external/global tier; a sourced table is materialized into a shard DO's SQLite — the two are mutually exclusive.",facing:"INTERNAL",level:"ERROR",name:"external_source_on_global",remediation:'Drop either `.source(...)` or `.global()`. To ingest an external database into per-tenant DOs, use `.source(...)` with `.shardBy(...)`; to read it in place as a global table, use `.global({ backend: "hyperdrive" })`.',run:a=>a.schema.tables.filter(e=>e.externalSource!==void 0&&e.shardKind==="global").map(e=>t(o,{cacheKey:`external_source_on_global:${e.name}`,detail:`Table \`${e.name}\` is both \`.source(...)\` and \`.global()\` — contradictory. A sourced table materializes into a shard DO's SQLite; a global table lives in the external tier.`,metadata:{...l(e),table:e.name}})),source:"static",title:"Sourced table cannot also be global"};export{o as default};
@@ -0,0 +1 @@
1
+ import{e as d}from"./finding-NrKO8idM.mjs";import{b as s,d as c}from"./helpers-YAAwOBMH.mjs";const l={categories:["SCHEMA"],description:"A `.geoIndex(name, { field })` points at a column that is not a `v.geoPoint()`, so its geohash companion can't be built and `withGeoIndex(...)` can never match.",facing:"INTERNAL",level:"ERROR",name:"geo_index_field_not_geopoint",remediation:"Point the geo index at a `v.geoPoint()` column, or change the column's type to `v.geoPoint()`.",run:a=>{const t=[];for(const n of a.schema.tables)for(const e of n.indexes){if(e.kind!=="geo")continue;const o=e.fields[0];if(o===void 0)continue;const i=s(n,o);i===void 0||i==="geoPoint"||t.push(d(l,{cacheKey:`geo_index_field_not_geopoint:${n.name}:${e.name}:${o}`,detail:`Geo index "${e.name}" on table "${n.name}" indexes column "${o}", which is a ${i}, not a v.geoPoint().`,metadata:{...c(e),field:o,index:e.name,kind:i,table:n.name}}))}return t},source:"static",title:"Geo index field is not a geoPoint"};export{l as default};
@@ -0,0 +1 @@
1
+ import{e as d}from"./finding-NrKO8idM.mjs";import{d as t}from"./helpers-YAAwOBMH.mjs";const r={categories:["SCHEMA"],description:"A `.geoIndex(name, { field })` is declared but no handler reads it via `withGeoIndex(name, …)`. The geohash companion column is maintained on every write and read by nothing — dead overhead, the geo analogue of a dead index.",facing:"INTERNAL",level:"INFO",name:"geo_index_unused",remediation:'Query the index from a handler with `ctx.db.query("<table>").withGeoIndex("<name>", q => q.near(point, radius))`, or drop the `.geoIndex(...)` declaration so writes stop maintaining its geohash companion.',run:n=>{if(n.geoIndexUsages===void 0)return[];const i=n.geoIndexUsages;if(i.some(e=>e.indexName===""))return[];const o=new Set(i.map(e=>e.indexName));return n.schema.tables.flatMap(e=>e.indexes.filter(a=>a.kind==="geo"&&!o.has(a.name)).map(a=>d(r,{cacheKey:`geo_index_unused:${e.name}:${a.name}`,detail:`No handler reads geo index "${a.name}" on table "${e.name}" via \`withGeoIndex("${a.name}", …)\` — it's declared but never queried, so its geohash companion is maintained on every write for nothing.`,metadata:{...t(a),index:a.name,table:e.name}})))},source:"static",title:"Geo index is declared but never queried"};export{r as default};
@@ -0,0 +1 @@
1
+ import{e as n}from"./finding-NrKO8idM.mjs";import{d as o}from"./helpers-YAAwOBMH.mjs";const t=100,l=2,s=90,m={categories:["SCHEMA"],description:"A `.global()` table is approaching D1's 100-column ceiling, past which it cannot be created.",facing:"INTERNAL",level:"WARN",name:"global_table_near_column_limit",remediation:"Split the table, or move the tail of its fields into one object field.",run:a=>a.schema.tables.filter(e=>e.shardKind==="global"&&e.fields.length+l>=s).map(e=>{const i=e.fields.length+l;return n(m,{cacheKey:`global_table_near_column_limit:${e.name}`,detail:`Global table "${e.name}" needs ${String(i)} columns (${String(e.fields.length)} fields plus id and _creationTime), against D1's limit of ${String(t)}.`,metadata:{...o(e),columns:i,limit:t,table:e.name}})}),source:"static",title:"Global table near the column limit"};export{m as default};
@@ -0,0 +1 @@
1
+ import{e as o}from"./finding-NrKO8idM.mjs";import{t as r,d as c}from"./helpers-YAAwOBMH.mjs";const d={categories:["SCHEMA"],description:"An index references a column that is not declared on its table. The index can never match, and the typo would otherwise surface only at runtime.",facing:"INTERNAL",level:"ERROR",name:"index_references_unknown_field",remediation:"Fix the column name in the index declaration, or add the column to the table.",run:t=>t.schema.tables.flatMap(n=>{const i=r(n);return n.indexes.flatMap(e=>e.fields.filter(a=>!i.has(a)).map(a=>o(d,{cacheKey:`index_references_unknown_field:${n.name}:${e.name}:${a}`,detail:`Index "${e.name}" on table "${n.name}" references column "${a}", which is not declared on the table.`,metadata:{...c(e),field:a,index:e.name,indexKind:e.kind,table:n.name}})))}),source:"static",title:"Index references unknown field"};export{d as default};
@@ -0,0 +1 @@
1
+ import{e as l}from"./finding-NrKO8idM.mjs";import{d}from"./helpers-YAAwOBMH.mjs";const m={categories:["SECURITY"],description:"A public procedure reads a table whose columns are masked by `.use(mask(...))` elsewhere in the app, but this procedure's builder chain does not include `.use(mask(...))`. It returns those columns in the clear while a sibling procedure redacts them.",facing:"EXTERNAL",level:"WARN",name:"mask_uncovered_pii_column",remediation:"Add `.use(mask(policies))` to the procedure's builder chain — e.g. `c.use(mask(myMasks)).query(...)` — so its returned rows redact the same columns as the rest of the app. If this procedure is intentionally privileged (e.g. an admin export), declare it with `internalQuery` / `internalMutation` / `internalAction` instead of the public builder so the intent is explicit.",run:r=>{if(r.maskProcedures===void 0)return[];const o=new Map;for(const t of r.maskProcedures)for(const{column:i,table:e}of t.maskColumns){if(e===""||i==="")continue;const s=o.get(e)??new Set;s.add(i),o.set(e,s)}if(o.size===0)return[];const n=[];for(const t of r.maskProcedures){if(t.usesMask||t.visibility==="internal")continue;const i=new Set;for(const e of t.tablesRead)e!==""&&o.has(e)&&i.add(e);for(const e of i){const s=[...o.get(e)??new Set].toSorted((a,u)=>a.localeCompare(u)),c=s.map(a=>`\`${a}\``).join(", ");n.push(l(m,{cacheKey:`mask_uncovered_pii_column:${t.file}:${t.exportName}:${e}`,detail:`\`${t.exportName}\` in ${t.file} reads table \`${e}\` without \`.use(mask(...))\` — its column${s.length===1?"":"s"} ${c} ${s.length===1?"is":"are"} masked elsewhere in the app but returned in the clear here.`,metadata:{columns:s,exportName:t.exportName,...d(t),table:e}}))}}return n},source:"static",title:"Maskable column returned without mask() middleware"};export{m as default};
@@ -1 +1 @@
1
- import{e as i}from"./finding-NrKO8idM.mjs";import{e as s}from"./helpers-YAAwOBMH.mjs";const o={categories:["SECURITY"],description:'A `mask(policies)` column named like PII (email, SSN, phone, …) uses the `"hash"` strategy. `"hash"` is an unsalted 32-bit FNV-1a digest — brute-force-recoverable and cross-row-correlatable — not a confidentiality control, so it does not actually hide the value.',facing:"EXTERNAL",level:"WARN",name:"mask_weak_hash_strategy_on_pii",remediation:'Use `"redact"` instead of `"hash"` for this column — e.g. `mask({ <table>: { <column>: "redact" } })`. Reserve `"hash"` for columns where a stable, joinable pseudonym is the goal and the value itself is not sensitive.',run:a=>a.maskStrategies===void 0?[]:a.maskStrategies.filter(e=>e.strategy==="hash"&&s(e.column)).map(e=>i(o,{cacheKey:`mask_weak_hash_strategy_on_pii:${e.file}:${e.line.toString()}`,detail:`\`${e.exportName}\` in ${e.file} masks \`${e.table===""?e.column:`${e.table}.${e.column}`}\` with \`"hash"\` — its name suggests PII, and \`"hash"\` is brute-force-recoverable and leaks cross-row equality. Use \`"redact"\` instead.`,metadata:{column:e.column,exportName:e.exportName,file:e.file,table:e.table}})),source:"static",title:'Weak "hash" mask strategy on a PII column'};export{o as default};
1
+ import{e as i}from"./finding-NrKO8idM.mjs";import{e as s}from"./helpers-YAAwOBMH.mjs";const o={categories:["SECURITY"],description:'A `mask(policies)` column named like PII (email, SSN, phone, …) uses the `"hash"` strategy. `"hash"` is an unsalted 32-bit FNV-1a digest — brute-force-recoverable and cross-row-correlatable — not a confidentiality control, so it does not actually hide the value.',facing:"EXTERNAL",level:"WARN",name:"mask_weak_hash_strategy_on_pii",remediation:'Use `"redact"` instead of `"hash"` for this column — e.g. `mask({ <table>: { <column>: "redact" } })`. Reserve `"hash"` for columns where a stable, joinable pseudonym is the goal and the value itself is not sensitive.',run:a=>a.maskStrategies===void 0?[]:a.maskStrategies.filter(e=>e.strategy==="hash"&&s(e.column)).map(e=>i(o,{cacheKey:`mask_weak_hash_strategy_on_pii:${e.file}:${e.line.toString()}`,detail:`\`${e.exportName}\` in ${e.file} masks \`${e.table===""?e.column:`${e.table}.${e.column}`}\` with \`"hash"\` — its name suggests PII, and \`"hash"\` is brute-force-recoverable and leaks cross-row equality. Use \`"redact"\` instead.`,metadata:{column:e.column,exportName:e.exportName,file:e.file,line:e.line,table:e.table}})),source:"static",title:'Weak "hash" mask strategy on a PII column'};export{o as default};
@@ -1 +1 @@
1
- import{dedupeCacheKeys as r}from"./dedupeCacheKeys-DtBOHffV.mjs";import{e as i}from"./finding-NrKO8idM.mjs";const o={categories:["SECURITY"],description:"A plaintext secret is committed to `wrangler.jsonc`'s `vars` block. `vars` are cleartext — baked into the deployed Worker and checked into source control — so the secret leaks via the repo and the bundle, and rotating it needs a config edit plus a redeploy.",facing:"INTERNAL",level:"ERROR",name:"plaintext_secret_in_wrangler_vars",remediation:"Move the value out of `vars`: bind it through a Secrets Store (`ctx.secrets.get(<NAME>)`) or set it with `wrangler secret put <NAME>` and read it from `env.<NAME>`. Delete the `vars` entry and rotate the exposed value — assume it is already compromised. Public/publishable keys (name them `*_PUBLIC` / `*_PUBLISHABLE`) are exempt.",run:t=>t.wranglerVariables===void 0?[]:r(t.wranglerVariables.map(e=>i(o,{cacheKey:`plaintext_secret_in_wrangler_vars:${e.file}:${e.key}`,detail:`The \`vars\` entry \`${e.key}\` in ${e.file} holds a plaintext ${e.kind.replaceAll("_"," ")} (${e.preview}). \`vars\` ship in cleartext to the deployed Worker and are committed to source control — move it to a Secrets Store binding or \`wrangler secret put\` and rotate the exposed value.`,metadata:{file:e.file,key:e.key,kind:e.kind,preview:e.preview}}))),source:"static",title:"Plaintext secret in wrangler vars"};export{o as default};
1
+ import{dedupeCacheKeys as i}from"./dedupeCacheKeys-DtBOHffV.mjs";import{e as r}from"./finding-NrKO8idM.mjs";const o={categories:["SECURITY"],description:"A plaintext secret is committed to `wrangler.jsonc`'s `vars` block. `vars` are cleartext — baked into the deployed Worker and checked into source control — so the secret leaks via the repo and the bundle, and rotating it needs a config edit plus a redeploy.",facing:"INTERNAL",level:"ERROR",name:"plaintext_secret_in_wrangler_vars",remediation:"Move the value out of `vars`: bind it through a Secrets Store (`ctx.secrets.get(<NAME>)`) or set it with `wrangler secret put <NAME>` and read it from `env.<NAME>`. Delete the `vars` entry and rotate the exposed value — assume it is already compromised. Public/publishable keys (name them `*_PUBLIC` / `*_PUBLISHABLE`) are exempt.",run:t=>t.wranglerVariables===void 0?[]:i(t.wranglerVariables.map(e=>r(o,{cacheKey:`plaintext_secret_in_wrangler_vars:${e.file}:${e.key}`,detail:`The \`vars\` entry \`${e.key}\` in ${e.file} holds a plaintext ${e.kind.replaceAll("_"," ")} (${e.preview}). \`vars\` ship in cleartext to the deployed Worker and are committed to source control — move it to a Secrets Store binding or \`wrangler secret put\` and rotate the exposed value.`,metadata:{file:e.file,key:e.key,kind:e.kind,preview:e.preview,...e.line===void 0?{}:{line:e.line}}}))),source:"static",title:"Plaintext secret in wrangler vars"};export{o as default};
@@ -0,0 +1 @@
1
+ import{e as i}from"./finding-NrKO8idM.mjs";import{o as a,d as n}from"./helpers-YAAwOBMH.mjs";const r={categories:["SECURITY"],description:'`.public()` opts a table OUT of the schema\'s `.rls("required")` enforcement — it does not mean the table holds public data. A `.public()` table whose columns look ownership- or PII-shaped (`userId`, `email`, `ssn`, …) is exempt from the row-security guard, not "safe to expose".',facing:"EXTERNAL",level:"WARN",name:"public_table_rls_optout_confusion",remediation:'Double-check this table actually needs the RLS opt-out. If it does not, remove `.public()` so `.rls("required")` covers it like every other table. If it genuinely must stay open (a shared lookup table, for instance), rename or comment it so the exemption is intentional rather than a name-implies-safety mistake, and make sure no procedure trusts `.public()` as an authorization boundary.',run:o=>{if(o.schema.rlsMode!=="required")return[];const s=[];for(const e of o.schema.tables){if(!e.isPublic)continue;const t=a(e);t.length!==0&&s.push(i(r,{cacheKey:`public_table_rls_optout_confusion:${e.name}`,detail:`Table "${e.name}" is \`.public()\` (opted OUT of the schema's \`.rls("required")\` enforcement) but carries ownership/PII-shaped column(s): ${t.join(", ")}. \`.public()\` means "exempt from RLS", not "safe to expose" — confirm this table really needs the opt-out.`,metadata:{...n(e),columns:t,table:e.name}}))}return s},source:"static",title:"Public table opts out of RLS but carries sensitive columns"};export{r as default};
@@ -0,0 +1 @@
1
+ import{e as f}from"./finding-NrKO8idM.mjs";import{d as m,t as u}from"./helpers-YAAwOBMH.mjs";const l=(o,r,a,n)=>{if(n.through!==void 0){const c=o.get(n.through.table);return c===void 0?[]:[n.through.from,n.through.to].filter(d=>!r(c).has(d)).map(d=>({column:d,owner:c.name,side:"field"}))}const e=o.get(n.table);if(!e)return[];const s=n.kind==="one"?a:e,t=n.kind==="one"?e:a,i=[];return r(s).has(n.field)||i.push({column:n.field,owner:s.name,side:"field"}),r(t).has(n.references)||i.push({column:n.references,owner:t.name,side:"references"}),i},h={categories:["SCHEMA"],description:"A relation references a foreign-key or referenced column that is not declared on its table, so the join can never resolve.",facing:"INTERNAL",level:"ERROR",name:"relation_references_unknown_field",remediation:"Fix the `field` / `references` column name in the relation, or add the missing column.",run:o=>{const r=new Map(o.schema.tables.map(e=>[e.name,e])),a=new Map,n=e=>{let s=a.get(e);return s||(s=u(e),a.set(e,s)),s};return o.schema.tables.flatMap(e=>e.relations.flatMap(s=>l(r,n,e,s).map(t=>f(h,{cacheKey:`relation_references_unknown_field:${e.name}:${s.name}:${t.side}`,detail:`Relation "${s.name}" on table "${e.name}" uses ${t.side} "${t.column}", which is not declared on table "${t.owner}".`,metadata:{...m(s),column:t.column,owner:t.owner,relation:s.name,side:t.side,table:e.name}}))))},source:"static",title:"Relation references unknown field"};export{h as default};
@@ -0,0 +1 @@
1
+ import{e as s}from"./finding-NrKO8idM.mjs";import{d as i}from"./helpers-YAAwOBMH.mjs";const l={categories:["SCHEMA"],description:"A relation targets a table that does not exist in the schema. The relation can never load — the target is a typo or a removed/renamed table.",facing:"INTERNAL",level:"ERROR",name:"relation_references_unknown_table",remediation:"Fix the target table name in the relation, or add the missing table to the schema.",run:n=>{const r=new Set(n.schema.tables.map(a=>a.name));return n.schema.tables.flatMap(a=>a.relations.flatMap(e=>[{name:e.table,role:""},...e.through===void 0?[]:[{name:e.through.table,role:":through"}]].filter(({name:t})=>!r.has(t)).map(({name:t,role:o})=>s(l,{cacheKey:`relation_references_unknown_table:${a.name}:${e.name}${o}`,detail:`Relation "${e.name}" on table "${a.name}" targets table "${t}", which does not exist in the schema.`,metadata:{...i(e),relation:e.name,table:a.name,target:t}}))))},source:"static",title:"Relation references unknown table"};export{l as default};
@@ -0,0 +1 @@
1
+ import{isReachableSite as a}from"./callSiteCallers-DArHfQSU.mjs";import{e as n}from"./finding-NrKO8idM.mjs";import{d as s}from"./helpers-YAAwOBMH.mjs";const r=new Set(["insert","insertMany","insertManyUnsafe","upsert","upsertMany"]),o={categories:["SCHEMA"],description:'No function inserts into this table via `ctx.db.insert("<table>", …)`, the `ctx.db.<table>` facade, or `insertMany`. It may be read-only by design (seeded by a migration, replicated, or written through a path the advisor can\'t see) — or it may be dead schema.',facing:"INTERNAL",level:"INFO",name:"table_without_insert",remediation:'If the table should be writable, add a mutation that inserts into it with `ctx.db.insert("<table>", …)` or `ctx.db.<table>.insert(…)`. If it is read-only or seeded elsewhere, this advisory can be ignored.',run:t=>{if(t.inserts===void 0)return[];const i=new Set([...t.inserts.filter(e=>e.table!==""&&a(e.scope)),...(t.tableWrites??[]).filter(e=>r.has(e.method)&&e.table!==""&&a(e.scope))].map(e=>e.table));return t.schema.tables.filter(e=>!i.has(e.name)&&e.externallyManaged!==!0).map(e=>n(o,{cacheKey:`table_without_insert:${e.name}`,detail:`No function inserts into "${e.name}" via \`ctx.db.insert("${e.name}", …)\`, \`ctx.db.${e.name}.insert\`, \`ctx.db.${e.name}.upsert\` or \`insertMany\` — table "${e.name}" has no discovered insert path.`,metadata:{...s(e),table:e.name}}))},source:"static",title:"Table has no insert path"};export{o as default};
@@ -0,0 +1 @@
1
+ import{e as d}from"./finding-NrKO8idM.mjs";import{d as h}from"./helpers-YAAwOBMH.mjs";const m=(n,s,t)=>n.some(e=>e.unique===!0&&e.fields.length===2&&e.fields.includes(s)&&e.fields.includes(t)),l={categories:["SCHEMA"],description:"A many-to-many relation's join table has no unique index over its two keys, so the same link can be stored twice and every read through the relation returns the target twice.",facing:"INTERNAL",level:"ERROR",name:"through_relation_missing_unique_index",remediation:'Add a unique index over the two keys on the join table, e.g. `.index("byPostTag", ["postId", "tagId"], { unique: true })`.',run:n=>{const s=new Map(n.schema.tables.map(t=>[t.name,t]));return n.schema.tables.flatMap(t=>t.relations.flatMap(e=>{if(e.through===void 0)return[];const{from:i,table:o,to:a}=e.through,r=s.get(o);return r===void 0?[]:m(r.indexes.filter(u=>u.kind==="index"),i,a)?[]:[d(l,{cacheKey:`through_relation_missing_unique_index:${t.name}:${e.name}`,detail:`Relation "${e.name}" on table "${t.name}" goes through "${o}", which has no unique index over ("${i}", "${a}"). A repeated connect stores the same link twice.`,metadata:{...h(e),relation:e.name,suggestedIndex:{fields:[i,a],name:`by_${i}_${a}`,unique:!0},table:o}})]}))},source:"static",title:"Through relation missing unique index"};export{l as default};
@@ -0,0 +1 @@
1
+ import{e as a}from"./finding-NrKO8idM.mjs";import{d as p}from"./helpers-YAAwOBMH.mjs";const r=10,c={categories:["PERFORMANCE"],description:`A topic with more than ${String(r)} subscriptions makes every publish one queue send per subscription. A Worker runs at most six sends at once, so the publish adds several round trips to the calling handler, and a retried publish re-delivers to every subscription that already received it.`,facing:"INTERNAL",level:"INFO",name:"topic_too_many_subscriptions",remediation:"Fold subscriptions that do related work into one handler, or publish from an action instead of a mutation so the fan-out is off the write path. Keep every subscription handler idempotent: a retried publish re-delivers to all of them.",run:t=>{if(t.queues===void 0)return[];const n=Map.groupBy(t.queues.filter(e=>e.topic!==void 0),e=>e.topic),o=[];for(const[e,i]of n)i.length<=r||o.push(a(c,{cacheKey:`topic_too_many_subscriptions:${e}`,detail:`Topic "${e}" has ${String(i.length)} subscriptions, so each publish sends to ${String(i.length)} queues.`,metadata:{...p(t.topics?.find(s=>s.exportName===e)??{}),subscriptions:i.map(s=>s.exportName),topic:e}}));return o},source:"static",title:"Topic has many subscriptions"};export{c as default};
@@ -0,0 +1 @@
1
+ import{e as o}from"./finding-NrKO8idM.mjs";import{b as l,d as s}from"./helpers-YAAwOBMH.mjs";const m=new Set(["date","number","timestamp"]),c={categories:["SCHEMA"],description:"A `.ttl(field)` policy points at a column that is not an epoch-millisecond timestamp, so the alarm sweep's `field < now` comparison can't decide expiry correctly.",facing:"INTERNAL",level:"ERROR",name:"ttl_field_not_timestamp",remediation:"Point `.ttl(field)` at a `v.timestamp()` / `v.date()` / `v.number()` (epoch-ms) column, or add such a column.",run:n=>{const a=[];for(const t of n.schema.tables){const{ttl:e}=t;if(!e)continue;const i=l(t,e.field);i===void 0||m.has(i)||a.push(o(c,{cacheKey:`ttl_field_not_timestamp:${t.name}:${e.field}`,detail:`Table "${t.name}" declares \`.ttl("${e.field}")\`, but "${e.field}" is a ${i} column, not an epoch-millisecond timestamp.`,metadata:{...s(t),field:e.field,kind:i,table:t.name}}))}return a},source:"static",title:"TTL field is not a timestamp"};export{c as default};
@@ -0,0 +1 @@
1
+ import{e as d}from"./finding-NrKO8idM.mjs";import{d as l}from"./helpers-YAAwOBMH.mjs";import{l as r,P as c,s as m}from"./fk-index-DXYS17cc.mjs";const f={categories:["PERFORMANCE"],description:"A foreign-key column declared by a `one` relation has no index leading with it. Reads that filter or join on the column full-scan the table, which gets linearly slower as rows accumulate.",facing:"EXTERNAL",level:"INFO",name:"unindexed_foreign_key",remediation:'Add a secondary index leading with the FK column, e.g. `.index("byAuthorId", ["authorId"])`.',run:o=>{const i=[];for(const a of o.schema.tables){const t=r(a);for(const e of a.relations){if(e.kind!=="one")continue;const n=e.field;if(n===c||t.has(n))continue;const s=m(n);i.push(d(f,{cacheKey:`unindexed_foreign_key:${a.name}:${n}`,detail:`Relation "${e.name}" on table "${a.name}" references "${e.table}" via column "${n}", which is not the leading column of any index. Reads filtering or joining on "${n}" full-scan "${a.name}".`,metadata:{...l(e),fkColumn:n,references:{column:e.references,table:e.table},relation:e.name,suggestedIndex:{fields:[n],name:s},table:a.name}}))}}return i},source:"static",title:"Unindexed foreign key"};export{f as default};
@@ -0,0 +1 @@
1
+ import{e as o}from"./finding-NrKO8idM.mjs";import{d as m}from"./helpers-YAAwOBMH.mjs";import{s as r,P as d,l}from"./fk-index-DXYS17cc.mjs";const c=e=>e.through===void 0?[{column:e.field,references:e.references,table:e.table}]:[{column:e.through.from,references:"_id",table:e.through.table},{column:e.through.to,references:"_id",table:e.through.table}],u=(e,s)=>s===d||e.relations.some(n=>n.kind==="one"&&n.field===s)||l(e).has(s),f={categories:["PERFORMANCE"],description:"A `many` relation's foreign-key column on the target table has no index leading with it. Relation predicates (`some`/`none`/`every`) and `with:` child reads filter the target on that column, full-scanning it as rows accumulate.",facing:"EXTERNAL",level:"INFO",name:"unindexed_relation_target",remediation:'Add a secondary index on the target table leading with the FK column, e.g. `.index("byAuthorId", ["authorId"])`.',run:e=>{const s=new Map(e.schema.tables.map(n=>[n.name,n]));return e.schema.tables.flatMap(n=>n.relations.filter(t=>t.kind==="many").flatMap(t=>c(t).flatMap(a=>{const i=s.get(a.table);return i===void 0||u(i,a.column)?[]:[o(f,{cacheKey:`unindexed_relation_target:${i.name}:${a.column}`,detail:`Relation "${t.name}" on table "${n.name}" is a to-many over "${i.name}" via its column "${a.column}", which is not the leading column of any index on "${i.name}". Relation predicates (\`some\`/\`none\`/\`every\`) and \`with:\` reads of "${t.name}" full-scan "${i.name}".`,metadata:{...m(t),fkColumn:a.column,references:{column:a.references,table:n.name},relation:t.name,suggestedIndex:{fields:[a.column],name:r(a.column)},table:i.name}})]})))},source:"static",title:"Unindexed relation target"};export{f as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/advisor",
3
- "version": "1.0.0-alpha.292",
3
+ "version": "1.0.0-alpha.294",
4
4
  "description": "Schema & query lints (splinter-style advisors) for Lunora, feeding the Studio Advisors view",
5
5
  "keywords": [
6
6
  "advisor",
@@ -1 +0,0 @@
1
- import{readCallSiteCallers as y}from"./callSiteCallers-DArHfQSU.mjs";import{scoreProcedure as v,procedureWeight as S,coverageFromScore as b,scoreGlobal as k,projectWeight as M,gradeFromScore as j,weightFor as N,worstLevel as C}from"./gradeFromScore-KSt58rj1.mjs";import F from"./classifySensitivity-JnjaTGYi.mjs";const x=(e,r)=>e===r?0:e<r?-1:1,w=(e,r)=>x(e.name,r.name),P=(e,r)=>{const o=e[r];return typeof o=="string"?o:void 0},f=(e,r)=>`${e}#${r}`,A=(e,r,o,c)=>e===void 0?{level:r,name:o,occurrences:1,weight:c}:{level:C(e.level,r),name:o,occurrences:e.occurrences+1,weight:Math.max(e.weight,c)},I=(e,r)=>{const o=new Map;for(const t of e)o.set(f(t.file,t.exportName),new Map);const c=new Map;for(const t of r){const s=P(t.metadata,"file"),l=y(t.metadata),m=s===void 0?[]:l.flatMap(a=>o.get(f(s,a))??[]),d=m.length===0?[c]:m;for(const a of d)a.set(t.name,A(a.get(t.name),t.level,t.name,N(t.level)))}return{byProcedure:new Map([...o].map(([t,s])=>[t,[...s.values()].toSorted(w)])),project:[...c.values()].toSorted(w)}},R=(e,r)=>{const o={clean:0,exempt:0,failing:0,warned:0};let c=r.checks.length;for(const t of e)o[t.coverage]+=1,c+=t.checks.length;return{clean:o.clean,exempt:o.exempt,failing:o.failing,procedures:e.length,rulesFired:c,warned:o.warned}},W=1,B=(e,r,o={})=>{const c=new Set(o.exempt),t=I(e,r),s=e.map(n=>{const i=f(n.file,n.exportName),p=t.byProcedure.get(i)??[],u=v(p),g=c.has(i)||n.exempt===!0,h=F(n);return{checks:p,coverage:g?"exempt":b(u),...g?{exemptReason:n.exemptReason??""}:{},exportName:n.exportName,file:n.file,id:i,kind:n.kind,score:u,sensitivity:h,visibility:n.visibility,weight:g?0:S(n,h.level)}}).toSorted((n,i)=>x(n.id,i.id)),l={checks:t.project,score:v(t.project)},m=s.filter(n=>n.coverage!=="exempt"),d=m.reduce((n,i)=>n+i.weight,0),a=k([...m,{score:l.score,weight:M(d)}]);return{generatedAt:o.generatedAt??new Date().toISOString(),grade:j(a),procedures:s,project:l,score:a,summary:R(s,l),version:W}};export{W as MAP_VERSION,x as byCodepoint,B as scoreAdvisor};
@@ -1 +0,0 @@
1
- import{e as a}from"./finding-NrKO8idM.mjs";const n={categories:["SCHEMA"],description:"A `.commitOrdered()` table without `.softDelete()` cannot express a delete in its `_commitSeq` feed: the sequence lives on the row, so a hard-deleted row vanishes with no event a consumer can observe.",facing:"INTERNAL",level:"WARN",name:"commit_ordered_hard_delete",remediation:"Add `.softDelete()` so the tombstone flip advances `_commitSeq` and pages through the feed — or, if the table is genuinely append-only and nothing is ever deleted from it, leave it as-is.",run:o=>{const t=[];for(const e of o.schema.tables)e.commitOrdered!==!0||e.softDelete!==void 0||t.push(a(n,{cacheKey:`commit_ordered_hard_delete:${e.name}`,detail:`Table "${e.name}" is \`.commitOrdered()\` but not \`.softDelete()\`. A hard delete removes the row and its \`_commitSeq\` together, so a changefeed paging on the sequence never learns the row is gone.`,metadata:{table:e.name}}));return t},source:"static",title:"Commit-ordered table cannot express deletes"};export{n as default};
@@ -1 +0,0 @@
1
- import{callSiteLabel as d,callSiteMetadata as m,callSiteDescription as u}from"./callSiteCallers-DArHfQSU.mjs";import{e as h}from"./finding-NrKO8idM.mjs";const f=(o,l)=>o.find(n=>n.ownsFolder!==!1&&l.startsWith(`${n.name}/`))?.name,p={categories:["SCHEMA"],description:"A function writes to a table that a different module declares it owns (`defineModule({ tables })`), or to an installed component's table from outside the component. The write couples the two modules: the owner can no longer change the table's shape or invariants without breaking a caller it does not know about.",facing:"INTERNAL",level:"WARN",name:"cross_module_table_write",remediation:"Move the write into the owning module and call it from there: an exported helper in the owner's files that takes the caller's `ctx` (`openInvoice(ctx, …)`) keeps the write in the caller's invocation, and a registered owner mutation runs through `ctx.runMutation(internal.<owner>.<fn>, …)`. Or move the table's ownership to the module that writes it. For a component's table, call the function the component exports for that write.",run:o=>{const l=o.modules??[],n=new Map(l.flatMap(e=>e.tables.map(t=>[t,e]))),i=[...o.inserts??[],...o.tableWrites??[]];if(n.size===0||i.length===0)return[];const r=new Set;return i.flatMap(e=>{const t=n.get(e.table),a=f(l,e.file),s=`cross_module_table_write:${e.file}:${d(e.scope)}:${e.table}`;if(t===void 0||t.name===a||r.has(s))return[];r.add(s);const c=t.installed===!0?`the installed component \`${t.name}\``:`module \`${t.name}\``;return[h(p,{cacheKey:s,detail:`${u(e.scope)} (${e.file}) writes to \`${e.table}\`, which ${c} owns, from ${a===void 0?"outside every module":`module \`${a}\``}.`,metadata:{...m(e.scope),file:e.file,owner:t.name,table:e.table,...t.installed===!0?{installed:!0}:{},...a===void 0?{}:{writer:a}}})]})},source:"static",title:"Function writes a table another module owns"};export{p as default};
@@ -1 +0,0 @@
1
- import{e as r}from"./finding-NrKO8idM.mjs";const o=(d,i)=>d.length>i.length?!1:d.every((n,s)=>n===i[s]),l={categories:["PERFORMANCE"],description:"A secondary index is redundant because another index already covers every lookup it serves (its columns are a leading prefix of the other's). The redundant index costs storage and is maintained on every write for no read benefit.",facing:"INTERNAL",level:"INFO",name:"duplicate_index",remediation:"Drop the redundant index; the covering index already serves its lookups.",run:d=>{const i=[];for(const n of d.schema.tables){const s=n.indexes.filter(e=>e.kind==="index");for(const e of s){if(e.unique===!0)continue;const t=s.find(a=>a===e||!o(e.fields,a.fields)?!1:e.fields.length===a.fields.length?a.unique===!0||e.name>a.name:!0);t&&i.push(r(l,{cacheKey:`duplicate_index:${n.name}:${e.name}`,detail:`Index "${e.name}" on table "${n.name}" (${e.fields.join(", ")}) is redundant — index "${t.name}" (${t.fields.join(", ")}) already covers its lookups.`,metadata:{coveredBy:{fields:t.fields,name:t.name},fields:e.fields,index:e.name,table:n.name}}))}}return i},source:"static",title:"Duplicate / redundant index"};export{l as default};
@@ -1 +0,0 @@
1
- import{e as t}from"./finding-NrKO8idM.mjs";const i={categories:["SCHEMA"],description:"An index declares no columns, so it indexes nothing and can never narrow a read.",facing:"INTERNAL",level:"WARN",name:"empty_index",remediation:"Give the index its columns, or remove it.",run:a=>a.schema.tables.flatMap(n=>n.indexes.filter(e=>e.kind==="index"&&e.fields.length===0).map(e=>t(i,{cacheKey:`empty_index:${n.name}:${e.name}`,detail:`Index "${e.name}" on table "${n.name}" declares no columns.`,metadata:{index:e.name,table:n.name}}))),source:"static",title:"Empty index"};export{i as default};
@@ -1 +0,0 @@
1
- import{e as n}from"./finding-NrKO8idM.mjs";const l={categories:["SCHEMA"],description:"A `.source({ mode: 'incremental' })` table declares no delete-visibility path (`reconcileEveryMs` or `softDeleteColumn`), so upstream deletes are never applied and the materialized table accumulates phantom rows.",facing:"EXTERNAL",level:"ERROR",name:"external_source_incremental_no_delete_path",remediation:"Add `reconcileEveryMs` (a periodic full-pull sweep that GCs vanished rows) or `softDeleteColumn` (an upstream tombstone column the incremental pull returns). Incremental ingest can't see a delete otherwise.",run:o=>{const a=[];for(const e of o.schema.tables){const t=e.externalSource;if(t!==void 0){if(t.unanalyzable){a.push(n(l,{cacheKey:`external_source_incremental_no_delete_path:${e.name}`,detail:`Table \`${e.name}\`'s \`.source(...)\` config is not a static object literal, so its \`mode\`/delete-visibility can't be verified. If it is \`mode: "incremental"\`, confirm it declares \`reconcileEveryMs\` or \`softDeleteColumn\` — an incremental source without one accumulates phantom rows on every upstream delete.`,level:"WARN",metadata:{table:e.name}}));continue}t.mode!=="incremental"||t.hasReconcile||t.hasSoftDelete||a.push(n(l,{cacheKey:`external_source_incremental_no_delete_path:${e.name}`,detail:`Table \`${e.name}\` is \`.source({ mode: "incremental" })\` but declares neither \`reconcileEveryMs\` nor \`softDeleteColumn\` — an incremental pull never sees upstream deletes, so the materialized table would accumulate phantom rows. Add one of the two delete-visibility paths.`,metadata:{table:e.name}}))}}return a},source:"static",title:"Incremental sourced table has no delete-visibility path"};export{l as default};
@@ -1 +0,0 @@
1
- import{e as t}from"./finding-NrKO8idM.mjs";const l={categories:["SCHEMA"],description:"A table is both `.source(...)` and `.global()`. A global table lives in the external/global tier; a sourced table is materialized into a shard DO's SQLite — the two are mutually exclusive.",facing:"INTERNAL",level:"ERROR",name:"external_source_on_global",remediation:'Drop either `.source(...)` or `.global()`. To ingest an external database into per-tenant DOs, use `.source(...)` with `.shardBy(...)`; to read it in place as a global table, use `.global({ backend: "hyperdrive" })`.',run:a=>a.schema.tables.filter(e=>e.externalSource!==void 0&&e.shardKind==="global").map(e=>t(l,{cacheKey:`external_source_on_global:${e.name}`,detail:`Table \`${e.name}\` is both \`.source(...)\` and \`.global()\` — contradictory. A sourced table materializes into a shard DO's SQLite; a global table lives in the external tier.`,metadata:{table:e.name}})),source:"static",title:"Sourced table cannot also be global"};export{l as default};
@@ -1 +0,0 @@
1
- import{e as d}from"./finding-NrKO8idM.mjs";import{b as c}from"./helpers-YAAwOBMH.mjs";const s={categories:["SCHEMA"],description:"A `.geoIndex(name, { field })` points at a column that is not a `v.geoPoint()`, so its geohash companion can't be built and `withGeoIndex(...)` can never match.",facing:"INTERNAL",level:"ERROR",name:"geo_index_field_not_geopoint",remediation:"Point the geo index at a `v.geoPoint()` column, or change the column's type to `v.geoPoint()`.",run:a=>{const t=[];for(const e of a.schema.tables)for(const n of e.indexes){if(n.kind!=="geo")continue;const o=n.fields[0];if(o===void 0)continue;const i=c(e,o);i===void 0||i==="geoPoint"||t.push(d(s,{cacheKey:`geo_index_field_not_geopoint:${e.name}:${n.name}:${o}`,detail:`Geo index "${n.name}" on table "${e.name}" indexes column "${o}", which is a ${i}, not a v.geoPoint().`,metadata:{field:o,index:n.name,kind:i,table:e.name}}))}return t},source:"static",title:"Geo index field is not a geoPoint"};export{s as default};
@@ -1 +0,0 @@
1
- import{e as d}from"./finding-NrKO8idM.mjs";const t={categories:["SCHEMA"],description:"A `.geoIndex(name, { field })` is declared but no handler reads it via `withGeoIndex(name, …)`. The geohash companion column is maintained on every write and read by nothing — dead overhead, the geo analogue of a dead index.",facing:"INTERNAL",level:"INFO",name:"geo_index_unused",remediation:'Query the index from a handler with `ctx.db.query("<table>").withGeoIndex("<name>", q => q.near(point, radius))`, or drop the `.geoIndex(...)` declaration so writes stop maintaining its geohash companion.',run:n=>{if(n.geoIndexUsages===void 0)return[];const i=n.geoIndexUsages;if(i.some(e=>e.indexName===""))return[];const o=new Set(i.map(e=>e.indexName));return n.schema.tables.flatMap(e=>e.indexes.filter(a=>a.kind==="geo"&&!o.has(a.name)).map(a=>d(t,{cacheKey:`geo_index_unused:${e.name}:${a.name}`,detail:`No handler reads geo index "${a.name}" on table "${e.name}" via \`withGeoIndex("${a.name}", …)\` — it's declared but never queried, so its geohash companion is maintained on every write for nothing.`,metadata:{index:a.name,table:e.name}})))},source:"static",title:"Geo index is declared but never queried"};export{t as default};
@@ -1 +0,0 @@
1
- import{e as n}from"./finding-NrKO8idM.mjs";const l=100,i=2,o=90,s={categories:["SCHEMA"],description:"A `.global()` table is approaching D1's 100-column ceiling, past which it cannot be created.",facing:"INTERNAL",level:"WARN",name:"global_table_near_column_limit",remediation:"Split the table, or move the tail of its fields into one object field.",run:a=>a.schema.tables.filter(e=>e.shardKind==="global"&&e.fields.length+i>=o).map(e=>{const t=e.fields.length+i;return n(s,{cacheKey:`global_table_near_column_limit:${e.name}`,detail:`Global table "${e.name}" needs ${String(t)} columns (${String(e.fields.length)} fields plus id and _creationTime), against D1's limit of ${String(l)}.`,metadata:{columns:t,limit:l,table:e.name}})}),source:"static",title:"Global table near the column limit"};export{s as default};
@@ -1 +0,0 @@
1
- import{e as i}from"./finding-NrKO8idM.mjs";import{t as r}from"./helpers-YAAwOBMH.mjs";const c={categories:["SCHEMA"],description:"An index references a column that is not declared on its table. The index can never match, and the typo would otherwise surface only at runtime.",facing:"INTERNAL",level:"ERROR",name:"index_references_unknown_field",remediation:"Fix the column name in the index declaration, or add the column to the table.",run:a=>a.schema.tables.flatMap(e=>{const o=r(e);return e.indexes.flatMap(n=>n.fields.filter(t=>!o.has(t)).map(t=>i(c,{cacheKey:`index_references_unknown_field:${e.name}:${n.name}:${t}`,detail:`Index "${n.name}" on table "${e.name}" references column "${t}", which is not declared on the table.`,metadata:{field:t,index:n.name,indexKind:n.kind,table:e.name}})))}),source:"static",title:"Index references unknown field"};export{c as default};
@@ -1 +0,0 @@
1
- import{e as l}from"./finding-NrKO8idM.mjs";const d={categories:["SECURITY"],description:"A public procedure reads a table whose columns are masked by `.use(mask(...))` elsewhere in the app, but this procedure's builder chain does not include `.use(mask(...))`. It returns those columns in the clear while a sibling procedure redacts them.",facing:"EXTERNAL",level:"WARN",name:"mask_uncovered_pii_column",remediation:"Add `.use(mask(policies))` to the procedure's builder chain — e.g. `c.use(mask(myMasks)).query(...)` — so its returned rows redact the same columns as the rest of the app. If this procedure is intentionally privileged (e.g. an admin export), declare it with `internalQuery` / `internalMutation` / `internalAction` instead of the public builder so the intent is explicit.",run:n=>{if(n.maskProcedures===void 0)return[];const i=new Map;for(const t of n.maskProcedures)for(const{column:o,table:e}of t.maskColumns){if(e===""||o==="")continue;const s=i.get(e)??new Set;s.add(o),i.set(e,s)}if(i.size===0)return[];const a=[];for(const t of n.maskProcedures){if(t.usesMask||t.visibility==="internal")continue;const o=new Set;for(const e of t.tablesRead)e!==""&&i.has(e)&&o.add(e);for(const e of o){const s=[...i.get(e)??new Set].toSorted((r,u)=>r.localeCompare(u)),c=s.map(r=>`\`${r}\``).join(", ");a.push(l(d,{cacheKey:`mask_uncovered_pii_column:${t.file}:${t.exportName}:${e}`,detail:`\`${t.exportName}\` in ${t.file} reads table \`${e}\` without \`.use(mask(...))\` — its column${s.length===1?"":"s"} ${c} ${s.length===1?"is":"are"} masked elsewhere in the app but returned in the clear here.`,metadata:{columns:s,exportName:t.exportName,file:t.file,table:e}}))}}return a},source:"static",title:"Maskable column returned without mask() middleware"};export{d as default};
@@ -1 +0,0 @@
1
- import{e as i}from"./finding-NrKO8idM.mjs";import{o as a}from"./helpers-YAAwOBMH.mjs";const n={categories:["SECURITY"],description:'`.public()` opts a table OUT of the schema\'s `.rls("required")` enforcement — it does not mean the table holds public data. A `.public()` table whose columns look ownership- or PII-shaped (`userId`, `email`, `ssn`, …) is exempt from the row-security guard, not "safe to expose".',facing:"EXTERNAL",level:"WARN",name:"public_table_rls_optout_confusion",remediation:'Double-check this table actually needs the RLS opt-out. If it does not, remove `.public()` so `.rls("required")` covers it like every other table. If it genuinely must stay open (a shared lookup table, for instance), rename or comment it so the exemption is intentional rather than a name-implies-safety mistake, and make sure no procedure trusts `.public()` as an authorization boundary.',run:o=>{if(o.schema.rlsMode!=="required")return[];const s=[];for(const e of o.schema.tables){if(!e.isPublic)continue;const t=a(e);t.length!==0&&s.push(i(n,{cacheKey:`public_table_rls_optout_confusion:${e.name}`,detail:`Table "${e.name}" is \`.public()\` (opted OUT of the schema's \`.rls("required")\` enforcement) but carries ownership/PII-shaped column(s): ${t.join(", ")}. \`.public()\` means "exempt from RLS", not "safe to expose" — confirm this table really needs the opt-out.`,metadata:{columns:t,table:e.name}}))}return s},source:"static",title:"Public table opts out of RLS but carries sensitive columns"};export{n as default};
@@ -1 +0,0 @@
1
- import{e as m}from"./finding-NrKO8idM.mjs";import{t as d}from"./helpers-YAAwOBMH.mjs";const u=(o,r,a,n)=>{if(n.through!==void 0){const c=o.get(n.through.table);return c===void 0?[]:[n.through.from,n.through.to].filter(f=>!r(c).has(f)).map(f=>({column:f,owner:c.name,side:"field"}))}const e=o.get(n.table);if(!e)return[];const s=n.kind==="one"?a:e,t=n.kind==="one"?e:a,i=[];return r(s).has(n.field)||i.push({column:n.field,owner:s.name,side:"field"}),r(t).has(n.references)||i.push({column:n.references,owner:t.name,side:"references"}),i},l={categories:["SCHEMA"],description:"A relation references a foreign-key or referenced column that is not declared on its table, so the join can never resolve.",facing:"INTERNAL",level:"ERROR",name:"relation_references_unknown_field",remediation:"Fix the `field` / `references` column name in the relation, or add the missing column.",run:o=>{const r=new Map(o.schema.tables.map(e=>[e.name,e])),a=new Map,n=e=>{let s=a.get(e);return s||(s=d(e),a.set(e,s)),s};return o.schema.tables.flatMap(e=>e.relations.flatMap(s=>u(r,n,e,s).map(t=>m(l,{cacheKey:`relation_references_unknown_field:${e.name}:${s.name}:${t.side}`,detail:`Relation "${s.name}" on table "${e.name}" uses ${t.side} "${t.column}", which is not declared on table "${t.owner}".`,metadata:{column:t.column,owner:t.owner,relation:s.name,side:t.side,table:e.name}}))))},source:"static",title:"Relation references unknown field"};export{l as default};
@@ -1 +0,0 @@
1
- import{e as s}from"./finding-NrKO8idM.mjs";const l={categories:["SCHEMA"],description:"A relation targets a table that does not exist in the schema. The relation can never load — the target is a typo or a removed/renamed table.",facing:"INTERNAL",level:"ERROR",name:"relation_references_unknown_table",remediation:"Fix the target table name in the relation, or add the missing table to the schema.",run:n=>{const r=new Set(n.schema.tables.map(e=>e.name));return n.schema.tables.flatMap(e=>e.relations.flatMap(a=>[{name:a.table,role:""},...a.through===void 0?[]:[{name:a.through.table,role:":through"}]].filter(({name:t})=>!r.has(t)).map(({name:t,role:o})=>s(l,{cacheKey:`relation_references_unknown_table:${e.name}:${a.name}${o}`,detail:`Relation "${a.name}" on table "${e.name}" targets table "${t}", which does not exist in the schema.`,metadata:{relation:a.name,table:e.name,target:t}}))))},source:"static",title:"Relation references unknown table"};export{l as default};
@@ -1 +0,0 @@
1
- import{isReachableSite as a}from"./callSiteCallers-DArHfQSU.mjs";import{e as n}from"./finding-NrKO8idM.mjs";const s=new Set(["insert","insertMany","insertManyUnsafe","upsert","upsertMany"]),r={categories:["SCHEMA"],description:'No function inserts into this table via `ctx.db.insert("<table>", …)`, the `ctx.db.<table>` facade, or `insertMany`. It may be read-only by design (seeded by a migration, replicated, or written through a path the advisor can\'t see) — or it may be dead schema.',facing:"INTERNAL",level:"INFO",name:"table_without_insert",remediation:'If the table should be writable, add a mutation that inserts into it with `ctx.db.insert("<table>", …)` or `ctx.db.<table>.insert(…)`. If it is read-only or seeded elsewhere, this advisory can be ignored.',run:t=>{if(t.inserts===void 0)return[];const i=new Set([...t.inserts.filter(e=>e.table!==""&&a(e.scope)),...(t.tableWrites??[]).filter(e=>s.has(e.method)&&e.table!==""&&a(e.scope))].map(e=>e.table));return t.schema.tables.filter(e=>!i.has(e.name)&&e.externallyManaged!==!0).map(e=>n(r,{cacheKey:`table_without_insert:${e.name}`,detail:`No function inserts into "${e.name}" via \`ctx.db.insert("${e.name}", …)\`, \`ctx.db.${e.name}.insert\`, \`ctx.db.${e.name}.upsert\` or \`insertMany\` — table "${e.name}" has no discovered insert path.`,metadata:{table:e.name}}))},source:"static",title:"Table has no insert path"};export{r as default};
@@ -1 +0,0 @@
1
- import{e as d}from"./finding-NrKO8idM.mjs";const h=(t,s,n)=>t.some(e=>e.unique===!0&&e.fields.length===2&&e.fields.includes(s)&&e.fields.includes(n)),l={categories:["SCHEMA"],description:"A many-to-many relation's join table has no unique index over its two keys, so the same link can be stored twice and every read through the relation returns the target twice.",facing:"INTERNAL",level:"ERROR",name:"through_relation_missing_unique_index",remediation:'Add a unique index over the two keys on the join table, e.g. `.index("byPostTag", ["postId", "tagId"], { unique: true })`.',run:t=>{const s=new Map(t.schema.tables.map(n=>[n.name,n]));return t.schema.tables.flatMap(n=>n.relations.flatMap(e=>{if(e.through===void 0)return[];const{from:i,table:o,to:a}=e.through,r=s.get(o);return r===void 0?[]:h(r.indexes.filter(u=>u.kind==="index"),i,a)?[]:[d(l,{cacheKey:`through_relation_missing_unique_index:${n.name}:${e.name}`,detail:`Relation "${e.name}" on table "${n.name}" goes through "${o}", which has no unique index over ("${i}", "${a}"). A repeated connect stores the same link twice.`,metadata:{relation:e.name,suggestedIndex:{fields:[i,a],name:`by_${i}_${a}`,unique:!0},table:o}})]}))},source:"static",title:"Through relation missing unique index"};export{l as default};
@@ -1 +0,0 @@
1
- import{e as a}from"./finding-NrKO8idM.mjs";const o=10,p={categories:["PERFORMANCE"],description:`A topic with more than ${String(o)} subscriptions makes every publish one queue send per subscription. A Worker runs at most six sends at once, so the publish adds several round trips to the calling handler, and a retried publish re-delivers to every subscription that already received it.`,facing:"INTERNAL",level:"INFO",name:"topic_too_many_subscriptions",remediation:"Fold subscriptions that do related work into one handler, or publish from an action instead of a mutation so the fan-out is off the write path. Keep every subscription handler idempotent: a retried publish re-delivers to all of them.",run:i=>{if(i.queues===void 0)return[];const r=Map.groupBy(i.queues.filter(e=>e.topic!==void 0),e=>e.topic),s=[];for(const[e,t]of r)t.length<=o||s.push(a(p,{cacheKey:`topic_too_many_subscriptions:${e}`,detail:`Topic "${e}" has ${String(t.length)} subscriptions, so each publish sends to ${String(t.length)} queues.`,metadata:{subscriptions:t.map(n=>n.exportName),topic:e}}));return s},source:"static",title:"Topic has many subscriptions"};export{p as default};
@@ -1 +0,0 @@
1
- import{e as o}from"./finding-NrKO8idM.mjs";import{b as l}from"./helpers-YAAwOBMH.mjs";const m=new Set(["date","number","timestamp"]),s={categories:["SCHEMA"],description:"A `.ttl(field)` policy points at a column that is not an epoch-millisecond timestamp, so the alarm sweep's `field < now` comparison can't decide expiry correctly.",facing:"INTERNAL",level:"ERROR",name:"ttl_field_not_timestamp",remediation:"Point `.ttl(field)` at a `v.timestamp()` / `v.date()` / `v.number()` (epoch-ms) column, or add such a column.",run:n=>{const a=[];for(const e of n.schema.tables){const{ttl:t}=e;if(!t)continue;const i=l(e,t.field);i===void 0||m.has(i)||a.push(o(s,{cacheKey:`ttl_field_not_timestamp:${e.name}:${t.field}`,detail:`Table "${e.name}" declares \`.ttl("${t.field}")\`, but "${t.field}" is a ${i} column, not an epoch-millisecond timestamp.`,metadata:{field:t.field,kind:i,table:e.name}}))}return a},source:"static",title:"TTL field is not a timestamp"};export{s as default};
@@ -1 +0,0 @@
1
- import{e as l}from"./finding-NrKO8idM.mjs";import{l as d,P as r,s as c}from"./fk-index-DXYS17cc.mjs";const u={categories:["PERFORMANCE"],description:"A foreign-key column declared by a `one` relation has no index leading with it. Reads that filter or join on the column full-scan the table, which gets linearly slower as rows accumulate.",facing:"EXTERNAL",level:"INFO",name:"unindexed_foreign_key",remediation:'Add a secondary index leading with the FK column, e.g. `.index("byAuthorId", ["authorId"])`.',run:o=>{const i=[];for(const a of o.schema.tables){const t=d(a);for(const n of a.relations){if(n.kind!=="one")continue;const e=n.field;if(e===r||t.has(e))continue;const s=c(e);i.push(l(u,{cacheKey:`unindexed_foreign_key:${a.name}:${e}`,detail:`Relation "${n.name}" on table "${a.name}" references "${n.table}" via column "${e}", which is not the leading column of any index. Reads filtering or joining on "${e}" full-scan "${a.name}".`,metadata:{fkColumn:e,references:{column:n.references,table:n.table},relation:n.name,suggestedIndex:{fields:[e],name:s},table:a.name}}))}}return i},source:"static",title:"Unindexed foreign key"};export{u as default};
@@ -1 +0,0 @@
1
- import{e as o}from"./finding-NrKO8idM.mjs";import{s as m,P as l,l as r}from"./fk-index-DXYS17cc.mjs";const d=e=>e.through===void 0?[{column:e.field,references:e.references,table:e.table}]:[{column:e.through.from,references:"_id",table:e.through.table},{column:e.through.to,references:"_id",table:e.through.table}],c=(e,i)=>i===l||e.relations.some(n=>n.kind==="one"&&n.field===i)||r(e).has(i),u={categories:["PERFORMANCE"],description:"A `many` relation's foreign-key column on the target table has no index leading with it. Relation predicates (`some`/`none`/`every`) and `with:` child reads filter the target on that column, full-scanning it as rows accumulate.",facing:"EXTERNAL",level:"INFO",name:"unindexed_relation_target",remediation:'Add a secondary index on the target table leading with the FK column, e.g. `.index("byAuthorId", ["authorId"])`.',run:e=>{const i=new Map(e.schema.tables.map(n=>[n.name,n]));return e.schema.tables.flatMap(n=>n.relations.filter(s=>s.kind==="many").flatMap(s=>d(s).flatMap(a=>{const t=i.get(a.table);return t===void 0||c(t,a.column)?[]:[o(u,{cacheKey:`unindexed_relation_target:${t.name}:${a.column}`,detail:`Relation "${s.name}" on table "${n.name}" is a to-many over "${t.name}" via its column "${a.column}", which is not the leading column of any index on "${t.name}". Relation predicates (\`some\`/\`none\`/\`every\`) and \`with:\` reads of "${s.name}" full-scan "${t.name}".`,metadata:{fkColumn:a.column,references:{column:a.references,table:n.name},relation:s.name,suggestedIndex:{fields:[a.column],name:m(a.column)},table:t.name}})]})))},source:"static",title:"Unindexed relation target"};export{u as default};