@lunora/codegen 1.0.0-alpha.256 → 1.0.0-alpha.258

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 (60) hide show
  1. package/dist/index.d.mts +121 -67
  2. package/dist/index.d.ts +121 -67
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/{AGENTS_FILENAME-D8SgT3OR.mjs → AGENTS_FILENAME-pKCBP6Us.mjs} +1 -1
  5. package/dist/packem_shared/CONTAINERS_FILENAME-C0nEQjXL.mjs +1 -0
  6. package/dist/packem_shared/{DEFAULT_TARGET-Co7ZXJ21.mjs → DEFAULT_TARGET-Dy9KAvjZ.mjs} +1 -1
  7. package/dist/packem_shared/{FLAGS_FILENAME-W5XQz_Po.mjs → FLAGS_FILENAME-DuEbVfug.mjs} +1 -1
  8. package/dist/packem_shared/MUTATORS_FILENAME-Cm-LVbo0.mjs +1 -0
  9. package/dist/packem_shared/{NOTIFY_FILENAME-C1J_47et.mjs → NOTIFY_FILENAME-BRewD55T.mjs} +1 -1
  10. package/dist/packem_shared/{OPENRPC_VERSION-Cr7Zzp6s.mjs → OPENRPC_VERSION-C8htLv5J.mjs} +1 -1
  11. package/dist/packem_shared/QUEUES_FILENAME-BUC4MU94.mjs +1 -0
  12. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DOe1K6eL.mjs +11 -0
  13. package/dist/packem_shared/{SHAPES_FILENAME-DRUFomCj.mjs → SHAPES_FILENAME-BMT5EVQI.mjs} +1 -1
  14. package/dist/packem_shared/WORKFLOWS_FILENAME-BIjSK96U.mjs +1 -0
  15. package/dist/packem_shared/attribution-CTEeAmtS.mjs +1 -0
  16. package/dist/packem_shared/{buildOpenApiDocument-SxfElVzK.mjs → buildOpenApiDocument-BG_b1qiR.mjs} +1 -1
  17. package/dist/packem_shared/{capabilitiesUsedBy-DqrbgTKV.mjs → capabilitiesUsedBy-D5TtIE8p.mjs} +1 -1
  18. package/dist/packem_shared/chain-ChloHMQt.mjs +1 -0
  19. package/dist/packem_shared/{classify-procedure-call-CmcShAze.mjs → classify-procedure-call-VzDQHiLB.mjs} +1 -1
  20. package/dist/packem_shared/{context-property-calls-CWf9-6G5.mjs → context-property-calls-CtIWno5c.mjs} +1 -1
  21. package/dist/packem_shared/discoverAuthApiCalls-D6s0QBwd.mjs +1 -0
  22. package/dist/packem_shared/{discoverCrons-BEALHx1S.mjs → discoverCrons-D2jGNq6i.mjs} +1 -1
  23. package/dist/packem_shared/{discoverFunctions-BcBzcG5x.mjs → discoverFunctions-AcXUQuyo.mjs} +1 -1
  24. package/dist/packem_shared/{discoverHttpRoutes-CJHS4llq.mjs → discoverHttpRoutes-C7qeDpp3.mjs} +1 -1
  25. package/dist/packem_shared/discoverHyperdriveCalls-CeyhQdv3.mjs +1 -0
  26. package/dist/packem_shared/discoverInserts-Db4we2Lt.mjs +1 -0
  27. package/dist/packem_shared/discoverMaskProcedures-DKS6xOnB.mjs +1 -0
  28. package/dist/packem_shared/{discoverMigrations-Dt7ywfZv.mjs → discoverMigrations-CyySAw7Z.mjs} +1 -1
  29. package/dist/packem_shared/{discoverNondeterministicCalls-CNJV2BiP.mjs → discoverNondeterministicCalls-Bl_vaQUi.mjs} +1 -1
  30. package/dist/packem_shared/discoverQueries-DHtbg9iS.mjs +1 -0
  31. package/dist/packem_shared/discoverR2sqlCalls-BNKRNkrB.mjs +1 -0
  32. package/dist/packem_shared/{discoverRlsMetadata-mXBmPOGj.mjs → discoverRlsMetadata-CVqVMNnz.mjs} +1 -1
  33. package/dist/packem_shared/{discoverRlsProcedures-F4Cy-kSi.mjs → discoverRlsProcedures-zDOYuzjt.mjs} +1 -1
  34. package/dist/packem_shared/{discoverSandboxUsage-DC6q7rZy.mjs → discoverSandboxUsage-DhE6sfq2.mjs} +1 -1
  35. package/dist/packem_shared/{discoverSchema-D5R60b4F.mjs → discoverSchema-DPghAnQv.mjs} +1 -1
  36. package/dist/packem_shared/{discoverStorageRulesMetadata-D3Ot9g5f.mjs → discoverStorageRulesMetadata-BdZT9H9j.mjs} +1 -1
  37. package/dist/packem_shared/{exported-procedure-chains-D48EXUVQ.mjs → exported-procedure-chains-gbM1pign.mjs} +1 -1
  38. package/dist/packem_shared/{fingerprintSchemaSources-Cl1CJFeh.mjs → fingerprintSchemaSources-DA9sYQDZ.mjs} +1 -1
  39. package/dist/packem_shared/handler-reference-BjE6kvyl.mjs +1 -0
  40. package/dist/packem_shared/{index-D7dKfGPh.mjs → index-Bq-b_-7H.mjs} +1 -1
  41. package/dist/packem_shared/listLunoraSourceFiles-DmOftuU4.mjs +1 -0
  42. package/dist/packem_shared/{loadProjectConfig-nNIDOrlR.mjs → loadProjectConfig-CWtWqN3X.mjs} +1 -1
  43. package/dist/packem_shared/{modules-DyCocr1e.mjs → modules-Dcalu27_.mjs} +1 -1
  44. package/dist/packem_shared/{parse-validator-C6fHL7OS.mjs → parse-validator-Cs6F8SYG.mjs} +1 -1
  45. package/dist/packem_shared/{readServiceBindings-CeQvSswr.mjs → readServiceBindings-V1rcBYrK.mjs} +1 -1
  46. package/dist/packem_shared/{unwrap-handler-return-DVY_kFF7.mjs → unwrap-handler-return-Bnx99voQ.mjs} +1 -1
  47. package/package.json +3 -3
  48. package/dist/packem_shared/CONTAINERS_FILENAME-C13yKxas.mjs +0 -1
  49. package/dist/packem_shared/MUTATORS_FILENAME-DqWOgC5Z.mjs +0 -1
  50. package/dist/packem_shared/QUEUES_FILENAME-RGwht3Xu.mjs +0 -1
  51. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DsV2KbZm.mjs +0 -11
  52. package/dist/packem_shared/WORKFLOWS_FILENAME-4-ib4HH-.mjs +0 -1
  53. package/dist/packem_shared/chain-mte5djRJ.mjs +0 -1
  54. package/dist/packem_shared/discoverAuthApiCalls-DoSN_yc3.mjs +0 -1
  55. package/dist/packem_shared/discoverHyperdriveCalls-Bkbh4tG7.mjs +0 -1
  56. package/dist/packem_shared/discoverInserts-DpuLYPPd.mjs +0 -1
  57. package/dist/packem_shared/discoverMaskProcedures-B0w8gM0S.mjs +0 -1
  58. package/dist/packem_shared/discoverQueries-BcdqjYky.mjs +0 -1
  59. package/dist/packem_shared/discoverR2sqlCalls-30Wtbc0P.mjs +0 -1
  60. package/dist/packem_shared/listLunoraSourceFiles-CSlcBYlo.mjs +0 -1
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext, AdvisorProcedureProtection } from '@lunora/advisor';
1
+ import { AdvisorCallSiteScope, AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext, AdvisorProcedureProtection } from '@lunora/advisor';
2
2
  export type { Finding } from '@lunora/advisor';
3
3
  import { Project, SourceFile, Node } from 'ts-morph';
4
4
  import { LunoraError } from '@lunora/errors';
@@ -819,6 +819,14 @@ interface WorkflowIR {
819
819
  };
820
820
  /** The `lunora/workflows.ts` export name, e.g. `orderPipeline`. */
821
821
  exportName: string;
822
+ /**
823
+ * The file declaring the `handler:` when it is a function passed by reference
824
+ * and declared in another file — the file {@link WorkflowIR.steps}' lines are
825
+ * in. Lunora-relative inside `lunora/`, project-relative outside it.
826
+ */
827
+ handlerFile?: string;
828
+ /** See {@link HandlerSiteIR}. */
829
+ handlerSite?: HandlerSiteIR;
822
830
  /** Static `limits` literal → `exports.<Class>.limits`. */
823
831
  limits?: {
824
832
  steps?: number;
@@ -841,7 +849,8 @@ interface WorkflowIR {
841
849
  * call. Feeds the duplicate-step-name lint, which flags a name used twice
842
850
  * (Cloudflare memoizes by name, so the second call silently returns the
843
851
  * first's cached result). Calls with a non-literal name are omitted (not
844
- * statically comparable).
852
+ * statically comparable). A handler passed by reference is followed to its
853
+ * declaration; the lines are then in {@link WorkflowIR.handlerFile}.
845
854
  */
846
855
  steps: ReadonlyArray<WorkflowStepIR>;
847
856
  }
@@ -924,6 +933,8 @@ interface QueueIR {
924
933
  bindingName: string;
925
934
  /** The `lunora/queues.ts` export name, e.g. `emailQueue`. */
926
935
  exportName: string;
936
+ /** See {@link HandlerSiteIR}. */
937
+ handlerSite?: HandlerSiteIR;
927
938
  /** How the queue is consumed: `"push"` (a worker `queue()` handler) or `"pull"` (external HTTP). */
928
939
  mode: "pull" | "push";
929
940
  /**
@@ -981,6 +992,43 @@ interface ModuleIR {
981
992
  /** Tables the module declares it owns (`defineModule({ tables })`); empty when it declares none. */
982
993
  tables: ReadonlyArray<string>;
983
994
  }
995
+ /**
996
+ * Who a discovered call site runs on behalf of — the one attribution every
997
+ * per-call-site IR carries (see `discover/attribution`).
998
+ *
999
+ * `export`: lexically inside an exported top-level declaration. `name` is the
1000
+ * EXPORTED name — `export const send = …` → `send`, `export default …` →
1001
+ * `default`, `const run = …; export { run as start }` → `start`.
1002
+ *
1003
+ * `helper`: inside a top-level, non-exported `function` / `const` of the same
1004
+ * file. `callers` are the exports that reach it through same-file value
1005
+ * references (a call, or the helper passed on as a value), transitively and
1006
+ * sorted; a type-only reference (`typeof helper`) does not count. Empty for an
1007
+ * orphan helper no export reaches. `untracked` is set when code attribution
1008
+ * cannot follow — module scope, a class body, a destructured declaration — also
1009
+ * reaches the helper, so `callers` is incomplete.
1010
+ *
1011
+ * `module`: outside every top-level `function` / `const` — module scope, or a
1012
+ * class body.
1013
+ *
1014
+ * A site is recorded once; consumers fan out over its callers. The advisor's
1015
+ * `AdvisorCallSiteScope` is the same type, so feeder rows pass straight through.
1016
+ */
1017
+ type CallSiteScope = AdvisorCallSiteScope;
1018
+ /**
1019
+ * Where a queue or workflow `handler:` passed by reference is declared, when it is
1020
+ * exported from a lunora source file — `defineWorkflow({ handler: onboard })` with
1021
+ * `onboard` exported from `lunora/onboarding/flow.ts` gives
1022
+ * `{ exportName: "onboard", file: "onboarding/flow" }`. The architecture graph
1023
+ * attributes that export's own call sites to the queue or workflow node, so its
1024
+ * calls are not reported as "not a registered function". `exportName` is the
1025
+ * exported name (`export { run as start }` → `start`).
1026
+ */
1027
+ interface HandlerSiteIR {
1028
+ exportName: string;
1029
+ /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1030
+ file: string;
1031
+ }
984
1032
  /**
985
1033
  * A sibling Worker the app calls through a Cloudflare service binding, declared in
986
1034
  * `lunora.config.*` `services` (plan 457). Becomes a wrangler `services[]` entry,
@@ -1054,12 +1102,12 @@ interface FlagsIR {
1054
1102
  * unused-workflow heuristic rather than producing a false positive).
1055
1103
  */
1056
1104
  interface WorkflowCallIR {
1057
- /** Export binding name of the function performing the call, e.g. `create`. */
1058
- exportName: string;
1059
1105
  /** Source file relative to `<projectRoot>/lunora/`, without extension (the api namespace). */
1060
1106
  file: string;
1061
1107
  /** 1-based line of the `get(...)` call. */
1062
1108
  line: number;
1109
+ /** Who the call runs on behalf of. */
1110
+ scope: CallSiteScope;
1063
1111
  /** The referenced workflow export name, or `""` when the argument is not a string literal. */
1064
1112
  workflow: string;
1065
1113
  }
@@ -1071,8 +1119,6 @@ interface WorkflowCallIR {
1071
1119
  * dynamic table — not lintable).
1072
1120
  */
1073
1121
  interface QueryReadIR {
1074
- /** Exported procedure the read sits in, or `""` at module scope. */
1075
- exportName: string;
1076
1122
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1077
1123
  file: string;
1078
1124
  /**
@@ -1088,6 +1134,8 @@ interface QueryReadIR {
1088
1134
  hasIndex: boolean;
1089
1135
  /** 1-based line of the `query(...)` call. */
1090
1136
  line: number;
1137
+ /** Who the read runs on behalf of. */
1138
+ scope: CallSiteScope;
1091
1139
  /** Queried table name, or `""` when the argument is not a string literal. */
1092
1140
  table: string;
1093
1141
  /**
@@ -1111,8 +1159,6 @@ interface QueryReadIR {
1111
1159
  * `AdvisorInsertWrite`.
1112
1160
  */
1113
1161
  interface AuthApiCallIR {
1114
- /** Export binding name of the function performing the call, e.g. "createOrg". */
1115
- exportName: string;
1116
1162
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1117
1163
  file: string;
1118
1164
  /** True when the call's argument object includes a `headers` property. */
@@ -1121,6 +1167,8 @@ interface AuthApiCallIR {
1121
1167
  line: number;
1122
1168
  /** The better-auth method invoked (e.g. `banUser`); empty when not statically known. */
1123
1169
  method: string;
1170
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1171
+ scope: CallSiteScope;
1124
1172
  }
1125
1173
  /**
1126
1174
  * A table write other than a plain `ctx.db.insert(...)` (see {@link InsertWriteIR}):
@@ -1129,15 +1177,18 @@ interface AuthApiCallIR {
1129
1177
  * edges and the `cross_module_table_write` lint.
1130
1178
  */
1131
1179
  interface TableWriteIR {
1132
- /** Export binding name of the function performing the write. */
1133
- exportName: string;
1134
1180
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1135
1181
  file: string;
1136
1182
  /** 1-based line of the call. */
1137
1183
  line: number;
1138
1184
  /** The writer method called, e.g. `patch`, `deleteMany`, `upsert`. */
1139
1185
  method: string;
1140
- /** Target table; `""` when it can't be read (an untyped id, a non-literal name). */
1186
+ /** Who the write runs on behalf of. */
1187
+ scope: CallSiteScope;
1188
+ /**
1189
+ * Target table; `""` when it can't be read (an untyped id, a non-literal
1190
+ * name). A union id (`Id<"a"> | Id<"b">`) gives one record per table.
1191
+ */
1141
1192
  table: string;
1142
1193
  }
1143
1194
  /**
@@ -1148,12 +1199,12 @@ interface TableWriteIR {
1148
1199
  * {@link InsertWriteIR.table} is `""` when the argument is not a string literal.
1149
1200
  */
1150
1201
  interface InsertWriteIR {
1151
- /** Export binding name of the function performing the insert, e.g. "send". */
1152
- exportName: string;
1153
1202
  /** Source file relative to `<projectRoot>/lunora/`, without extension (the api namespace). */
1154
1203
  file: string;
1155
1204
  /** 1-based line of the `insert(...)` call. */
1156
1205
  line: number;
1206
+ /** Who the insert runs on behalf of. */
1207
+ scope: CallSiteScope;
1157
1208
  /** Target table name, or `""` when the argument is not a string literal. */
1158
1209
  table: string;
1159
1210
  }
@@ -1552,12 +1603,12 @@ interface SecretLiteralIR {
1552
1603
  * identical to `AdvisorSqlInterpolation`.
1553
1604
  */
1554
1605
  interface SqlInterpolationIR {
1555
- /** Export binding name of the procedure performing the `ctx.sql` call. */
1556
- exportName: string;
1557
1606
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1558
1607
  file: string;
1559
1608
  /** 1-based line of the interpolation, or `0` when unknown. */
1560
1609
  line: number;
1610
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1611
+ scope: CallSiteScope;
1561
1612
  }
1562
1613
  /**
1563
1614
  * One `ctx.fetch(url, …)` call inside an action whose URL argument is derived
@@ -1569,12 +1620,12 @@ interface SqlInterpolationIR {
1569
1620
  * identical to `AdvisorArgumentDerivedFetch`.
1570
1621
  */
1571
1622
  interface ArgumentDerivedFetchIR {
1572
- /** Export binding name of the action performing the `ctx.fetch` call. */
1573
- exportName: string;
1574
1623
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1575
1624
  file: string;
1576
1625
  /** 1-based line of the `ctx.fetch` call, or `0` when unknown. */
1577
1626
  line: number;
1627
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1628
+ scope: CallSiteScope;
1578
1629
  }
1579
1630
  /**
1580
1631
  * One `ctx.kv.<method>(key, …)` call whose namespace key is derived from the
@@ -1587,14 +1638,14 @@ interface ArgumentDerivedFetchIR {
1587
1638
  * prefix, not a per-entry key). Structurally identical to `AdvisorKvKeyAccess`.
1588
1639
  */
1589
1640
  interface KvKeyAccessIR {
1590
- /** Export binding name of the procedure performing the `ctx.kv` access. */
1591
- exportName: string;
1592
1641
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1593
1642
  file: string;
1594
1643
  /** 1-based line of the `ctx.kv` call, or `0` when unknown. */
1595
1644
  line: number;
1596
1645
  /** The `ctx.kv` method invoked: `get` / `getRaw` / `getWithMetadata` / `put` / `delete`. */
1597
1646
  method: string;
1647
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1648
+ scope: CallSiteScope;
1598
1649
  /**
1599
1650
  * Visibility of the enclosing procedure. `internal` procedures have no
1600
1651
  * untrusted caller by construction — see `owner_field_from_args_not_auth`'s
@@ -1636,8 +1687,6 @@ interface UnrestrictedWhereBranchIR {
1636
1687
  owner: string;
1637
1688
  }
1638
1689
  interface OwnerFieldWriteIR {
1639
- /** Export binding name of the procedure performing the write. */
1640
- exportName: string;
1641
1690
  /** The identity column being written from `args` (e.g. `userId`). */
1642
1691
  field: string;
1643
1692
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
@@ -1648,7 +1697,9 @@ interface OwnerFieldWriteIR {
1648
1697
  method: string;
1649
1698
  /**
1650
1699
  * The enclosing `defineMutator` declared this very column as its `owner`, AND
1651
- * the value written resolves to that same `args[owner]`.
1700
+ * the value written resolves, by symbol, to that same `args[owner]` of the
1701
+ * `server` impl's own 2nd parameter. A nested closure's or a helper's own
1702
+ * `args` (or any binding shadowing it) never qualifies.
1652
1703
  *
1653
1704
  * `applyOwnerScope` requires a verified identity, rejects a client-supplied
1654
1705
  * value that disagrees with it, and overwrites the column with the verified
@@ -1663,6 +1714,8 @@ interface OwnerFieldWriteIR {
1663
1714
  * is a real IDOR and stays reportable.
1664
1715
  */
1665
1716
  ownerScoped?: true;
1717
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1718
+ scope: CallSiteScope;
1666
1719
  /**
1667
1720
  * Visibility of the enclosing procedure. `internal` procedures are not
1668
1721
  * reachable by a caller, so the lint's premise ("any caller can write rows
@@ -1683,14 +1736,14 @@ interface OwnerFieldWriteIR {
1683
1736
  * Structurally identical to `AdvisorStorageKeyAccess`.
1684
1737
  */
1685
1738
  interface StorageKeyAccessIR {
1686
- /** Export binding name of the procedure performing the storage call. */
1687
- exportName: string;
1688
1739
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1689
1740
  file: string;
1690
1741
  /** 1-based line of the storage call, or `0` when unknown. */
1691
1742
  line: number;
1692
1743
  /** The bucket method invoked with the arg-derived key, e.g. `get` / `put` / `delete` / `download`. */
1693
1744
  method: string;
1745
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1746
+ scope: CallSiteScope;
1694
1747
  /**
1695
1748
  * Visibility of the enclosing procedure. `internal` procedures have no
1696
1749
  * untrusted caller by construction — see `owner_field_from_args_not_auth`'s
@@ -1712,14 +1765,14 @@ interface StorageKeyAccessIR {
1712
1765
  * identical to `AdvisorContainerKeyAccess`.
1713
1766
  */
1714
1767
  interface ContainerKeyAccessIR {
1715
- /** Export binding name of the procedure performing the `ctx.containers` access. */
1716
- exportName: string;
1717
1768
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1718
1769
  file: string;
1719
1770
  /** 1-based line of the `ctx.containers.*.get` call, or `0` when unknown. */
1720
1771
  line: number;
1721
1772
  /** The container accessor method invoked — always `get`. */
1722
1773
  method: string;
1774
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1775
+ scope: CallSiteScope;
1723
1776
  }
1724
1777
  /**
1725
1778
  * One `ctx.ai.run(model, …)` call whose model-id argument is derived from the handler's
@@ -1732,12 +1785,12 @@ interface ContainerKeyAccessIR {
1732
1785
  * normal usage and is never inspected). Structurally identical to `AdvisorAiRawRun`.
1733
1786
  */
1734
1787
  interface AiRawRunIR {
1735
- /** Export binding name of the procedure performing the `ctx.ai.run` call. */
1736
- exportName: string;
1737
1788
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1738
1789
  file: string;
1739
1790
  /** 1-based line of the `ctx.ai.run` call, or `0` when unknown. */
1740
1791
  line: number;
1792
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1793
+ scope: CallSiteScope;
1741
1794
  }
1742
1795
  /**
1743
1796
  * One `ctx.vectors.<method>(indexName, input)` call whose `input.namespace` is derived
@@ -1750,14 +1803,14 @@ interface AiRawRunIR {
1750
1803
  * here. Structurally identical to `AdvisorVectorNamespaceAccess`.
1751
1804
  */
1752
1805
  interface VectorNamespaceAccessIR {
1753
- /** Export binding name of the procedure performing the `ctx.vectors` access. */
1754
- exportName: string;
1755
1806
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1756
1807
  file: string;
1757
1808
  /** 1-based line of the `ctx.vectors` call, or `0` when unknown. */
1758
1809
  line: number;
1759
1810
  /** The `ctx.vectors` method invoked: `query` / `upsert` / `upsertNow`. */
1760
1811
  method: string;
1812
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1813
+ scope: CallSiteScope;
1761
1814
  }
1762
1815
  /**
1763
1816
  * One `ctx.mail`/`ctx.email` `send`/`queue` call whose recipient field (`to`/`cc`/`bcc`)
@@ -1770,14 +1823,14 @@ interface VectorNamespaceAccessIR {
1770
1823
  * `AdvisorMailRecipientAccess`.
1771
1824
  */
1772
1825
  interface MailRecipientAccessIR {
1773
- /** Export binding name of the procedure performing the `ctx.mail`/`ctx.email` call. */
1774
- exportName: string;
1775
1826
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1776
1827
  file: string;
1777
1828
  /** 1-based line of the `ctx.mail`/`ctx.email` call, or `0` when unknown. */
1778
1829
  line: number;
1779
1830
  /** The mailer method invoked: `send` / `queue`. */
1780
1831
  method: string;
1832
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1833
+ scope: CallSiteScope;
1781
1834
  }
1782
1835
  /**
1783
1836
  * One `ctx.browser.<method>(url, …)` call whose navigation URL (`arguments[0]`)
@@ -1788,14 +1841,14 @@ interface MailRecipientAccessIR {
1788
1841
  * `resolveDns`. Structurally identical to `AdvisorBrowserUrlAccess`.
1789
1842
  */
1790
1843
  interface BrowserUrlAccessIR {
1791
- /** Export binding name of the procedure performing the `ctx.browser` call. */
1792
- exportName: string;
1793
1844
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1794
1845
  file: string;
1795
1846
  /** 1-based line of the `ctx.browser` call, or `0` when unknown. */
1796
1847
  line: number;
1797
1848
  /** The browser method invoked: `content` / `pdf` / `scrape` / `screenshot`. */
1798
1849
  method: string;
1850
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1851
+ scope: CallSiteScope;
1799
1852
  }
1800
1853
  /**
1801
1854
  * One runtime container-override call: a `<handle>.start({ enableInternet: true, … })`
@@ -1809,14 +1862,14 @@ interface BrowserUrlAccessIR {
1809
1862
  interface ContainerOverrideIR {
1810
1863
  /** e.g. the egress method name, or `"enableInternet: true"`. */
1811
1864
  detail: string;
1812
- /** Export binding name of the procedure performing the call. */
1813
- exportName: string;
1814
1865
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1815
1866
  file: string;
1816
1867
  /** Which override shape matched. */
1817
1868
  kind: "egress_relaxation" | "enable_internet";
1818
1869
  /** 1-based line of the call, or `0` when unknown. */
1819
1870
  line: number;
1871
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1872
+ scope: CallSiteScope;
1820
1873
  }
1821
1874
  /**
1822
1875
  * One `buildImageDeliveryUrl({ key, … })` call (`@lunora/bindings/images`) whose
@@ -1832,12 +1885,12 @@ interface ContainerOverrideIR {
1832
1885
  * identical to `AdvisorImageDeliveryUrlAccess`.
1833
1886
  */
1834
1887
  interface ImageDeliveryUrlAccessIR {
1835
- /** Export binding name of the procedure performing the `buildImageDeliveryUrl` call. */
1836
- exportName: string;
1837
1888
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1838
1889
  file: string;
1839
1890
  /** 1-based line of the `buildImageDeliveryUrl` call, or `0` when unknown. */
1840
1891
  line: number;
1892
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1893
+ scope: CallSiteScope;
1841
1894
  }
1842
1895
  /**
1843
1896
  * One `createAuth({...})` call's configuration snapshot — the shared input for
@@ -1858,8 +1911,6 @@ interface AuthConfigIR {
1858
1911
  disableCsrfCheck: boolean;
1859
1912
  /** `emailAndPassword.enabled === true`. */
1860
1913
  emailPasswordEnabled: boolean;
1861
- /** Export binding name enclosing the `createAuth(...)` call. */
1862
- exportName: string;
1863
1914
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1864
1915
  file: string;
1865
1916
  /** 1-based line of the `createAuth(...)` call, or `0` when unknown. */
@@ -1869,6 +1920,8 @@ interface AuthConfigIR {
1869
1920
  /** `trustedOrigins` array literal contains a `"*"` element. */
1870
1921
  /** `plugins` includes `scim(...)` while `database` is a non-transactional Lunora adapter — a combination that throws at runtime. */
1871
1922
  scimOnNonTransactionalAdapter: boolean;
1923
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1924
+ scope: CallSiteScope;
1872
1925
  /** `advanced.useSecureCookies === false`. */
1873
1926
  secureCookiesDisabled: boolean;
1874
1927
  /** `session.freshAge === 0` (explicit literal). */
@@ -1890,14 +1943,14 @@ interface AuthConfigIR {
1890
1943
  interface RatelimitKeySelectorIR {
1891
1944
  /** The `rateLimit`/`dbRateLimit` callee invoked. */
1892
1945
  callee: string;
1893
- /** Export binding name of the procedure whose `.use(...)` chain carries the call. */
1894
- exportName: string;
1895
1946
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1896
1947
  file: string;
1897
1948
  /** The rate limit's `name` argument (the second positional argument), or `""` when not a string literal. */
1898
1949
  limitName: string;
1899
1950
  /** 1-based line of the `rateLimit`/`dbRateLimit` call, or `0` when unknown. */
1900
1951
  line: number;
1952
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1953
+ scope: CallSiteScope;
1901
1954
  }
1902
1955
  /**
1903
1956
  * One payload-derived privileged dispatch — a `ctx.run`/`context.run` back into a
@@ -1915,10 +1968,10 @@ interface PrivilegedDispatchIR {
1915
1968
  dispatchKind: "queue" | "workflow";
1916
1969
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1917
1970
  file: string;
1918
- /** Export binding name of the handler performing the dispatch. */
1919
- handlerExport: string;
1920
1971
  /** 1-based line of the dispatch call, or `0` when unknown. */
1921
1972
  line: number;
1973
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
1974
+ scope: CallSiteScope;
1922
1975
  /** Export name of the dispatched target (`send` in `api.messages.send`). */
1923
1976
  targetExport: string;
1924
1977
  /** File path of the dispatched target relative to `lunora/` (`messages` in `api.messages.send`). */
@@ -1959,8 +2012,6 @@ interface StorageUploadIR {
1959
2012
  analyzable: boolean;
1960
2013
  /** Numeric literal value of an `expiresInSeconds` option, when statically known (`getSignedUrl` / `getPresignedUrl` only). */
1961
2014
  expiresInSeconds?: number;
1962
- /** Export binding name of the procedure performing the call. */
1963
- exportName: string;
1964
2015
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1965
2016
  file: string;
1966
2017
  /** 1-based line of the call, or `0` when unknown. */
@@ -1969,6 +2020,8 @@ interface StorageUploadIR {
1969
2020
  method: "generateUploadUrl" | "getPresignedUrl" | "getSignedUrl" | "store" | "upload";
1970
2021
  /** Options-object keys present at the call site (empty when not `analyzable`, or when no options argument was passed). */
1971
2022
  presentKeys: string[];
2023
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2024
+ scope: CallSiteScope;
1972
2025
  }
1973
2026
  /**
1974
2027
  * One discovered `httpAction`/`httpRoute` handler in `lunora/` that performs a
@@ -1982,8 +2035,6 @@ interface StorageUploadIR {
1982
2035
  * `AdvisorHttpActionGuard`.
1983
2036
  */
1984
2037
  interface HttpActionGuardIR {
1985
- /** Export binding name of the handler (or `"<module>"` when mounted inline / not a named binding). */
1986
- exportName: string;
1987
2038
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
1988
2039
  file: string;
1989
2040
  /** Which HTTP surface the handler is: a raw `httpAction` or a typed `httpRoute` route. */
@@ -1994,6 +2045,8 @@ interface HttpActionGuardIR {
1994
2045
  method?: string;
1995
2046
  /** `true` when the handler reads `ctx.auth` (a direct member access or a `const { auth } = ctx` destructure). */
1996
2047
  readsAuth: boolean;
2048
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2049
+ scope: CallSiteScope;
1997
2050
  /** The first side effect found, as a stable label: `runMutation`, `runAction`, or `db.<method>`. */
1998
2051
  sideEffect: string;
1999
2052
  }
@@ -2012,14 +2065,14 @@ interface HttpActionGuardIR {
2012
2065
  * identical to `AdvisorHttpHeaderWrite`.
2013
2066
  */
2014
2067
  interface HttpHeaderWriteIR {
2015
- /** Export binding name of the enclosing handler, or `"<module>"` when mounted inline. */
2016
- exportName: string;
2017
2068
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
2018
2069
  file: string;
2019
2070
  /** The header name being written (`"location"`), or `""` when the key is not a string literal. */
2020
2071
  headerName: string;
2021
2072
  /** 1-based line of the request-tainted header value. */
2022
2073
  line: number;
2074
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2075
+ scope: CallSiteScope;
2023
2076
  /** How the header was written. */
2024
2077
  via: "headers-append" | "headers-ctor" | "headers-set" | "response-init";
2025
2078
  }
@@ -2037,8 +2090,6 @@ interface HttpHeaderWriteIR {
2037
2090
  interface FailOpenGuardIR {
2038
2091
  /** The middleware factory at the call site: `rateLimit` / `dbRateLimit` / `verifyTurnstileMiddleware`. */
2039
2092
  callee: string;
2040
- /** Export binding name of the procedure the guard is attached to, or `"<module>"` at file scope. */
2041
- exportName: string;
2042
2093
  /** `true` only when the options literal set `failOpen: true` as a boolean literal; a non-literal or absent option is treated as fail-closed. */
2043
2094
  failOpen: boolean;
2044
2095
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
@@ -2047,6 +2098,8 @@ interface FailOpenGuardIR {
2047
2098
  limitName: string;
2048
2099
  /** 1-based line of the middleware call, or `0` when unknown. */
2049
2100
  line: number;
2101
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2102
+ scope: CallSiteScope;
2050
2103
  }
2051
2104
  /**
2052
2105
  * One `ctx.flags.boolean("key", <boolean-literal>)` read in `lunora/` — the
@@ -2060,14 +2113,14 @@ interface FailOpenGuardIR {
2060
2113
  interface FlagSecurityDefaultIR {
2061
2114
  /** The boolean-literal default returned on a provider outage (fail-open value). */
2062
2115
  defaultValue: boolean;
2063
- /** Export binding name of the procedure performing the flag read, or `"<module>"` at file scope. */
2064
- exportName: string;
2065
2116
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
2066
2117
  file: string;
2067
2118
  /** The flag key — the first string-literal argument of `ctx.flags.boolean`. */
2068
2119
  key: string;
2069
2120
  /** 1-based line of the `ctx.flags.boolean` call, or `0` when unknown. */
2070
2121
  line: number;
2122
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2123
+ scope: CallSiteScope;
2071
2124
  }
2072
2125
  /**
2073
2126
  * One `ctx.flags` read lexically inside a `query(...)` handler — the
@@ -2101,14 +2154,14 @@ interface FlagReadIR {
2101
2154
  * Structurally identical to `AdvisorAiToolSideEffect`.
2102
2155
  */
2103
2156
  interface AiToolSideEffectIR {
2104
- /** Export binding name of the procedure performing the call. */
2105
- exportName: string;
2106
2157
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
2107
2158
  file: string;
2108
2159
  /** 1-based line of the generation call, or `0` when unknown. */
2109
2160
  line: number;
2110
2161
  /** The generation entrypoint invoked. */
2111
2162
  method: "generateText" | "streamText";
2163
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2164
+ scope: CallSiteScope;
2112
2165
  /** The privileged side-effect sink a model-callable tool reaches (`ctx.db.insert`, `ctx.run`, `ctx.fetch`, …). */
2113
2166
  sideEffect: string;
2114
2167
  /** `true` when a model-input option is derived from the handler's `args` (a bare `args.x`, or a name destructured from `args`). */
@@ -2125,14 +2178,14 @@ interface AiToolSideEffectIR {
2125
2178
  interface IdentityClaimReadIR {
2126
2179
  /** `true` when `key` is a declared claim (in the `defineIdentity` contract, or the always-present `userId`). */
2127
2180
  declared: boolean;
2128
- /** Export binding name of the enclosing declaration (`<module>` at file scope). */
2129
- exportName: string;
2130
2181
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
2131
2182
  file: string;
2132
2183
  /** The claim key read off the identity bag. */
2133
2184
  key: string;
2134
2185
  /** 1-based line of the read, or `0` when unknown. */
2135
2186
  line: number;
2187
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2188
+ scope: CallSiteScope;
2136
2189
  }
2137
2190
  /**
2138
2191
  * One payment webhook-adapter construction in `lunora/` (`createStripeAdapter` /
@@ -2145,12 +2198,12 @@ interface IdentityClaimReadIR {
2145
2198
  interface PaymentWebhookIR {
2146
2199
  /** The adapter factory invoked. */
2147
2200
  callee: "createAutumnAdapter" | "createDodoPaymentsAdapter" | "createPolarAdapter" | "createStripeAdapter";
2148
- /** Export binding name of the enclosing declaration (`<module>` at file scope). */
2149
- exportName: string;
2150
2201
  /** Source file relative to `<projectRoot>/lunora/`, without extension. */
2151
2202
  file: string;
2152
2203
  /** 1-based line of the construction, or `0` when unknown. */
2153
2204
  line: number;
2205
+ /** Who the site runs on behalf of — see {@link CallSiteScope}. */
2206
+ scope: CallSiteScope;
2154
2207
  /** Statically-known `webhookToleranceSeconds` literal, when present and a plain numeric literal. */
2155
2208
  toleranceSeconds?: number;
2156
2209
  }
@@ -3184,8 +3237,7 @@ declare const discoverAgents: (project: Project, lunoraDirectory: string) => Age
3184
3237
  declare const listLunoraSourceFiles: (directory: string) => string[];
3185
3238
  /**
3186
3239
  * Discover `ctx.authApi.<method>(...)` (and bare `authApi.<method>(...)`) calls
3187
- * under the lunora source directory and attribute each to the exported function
3188
- * (and file) performing it. Calls outside an exported declaration are dropped.
3240
+ * under the lunora source directory, each with its `CallSiteScope`.
3189
3241
  */
3190
3242
  declare const discoverAuthApiCalls: (project: Project, lunoraDirectory: string) => AuthApiCallIR[];
3191
3243
  /** The only file containers may be declared in — mirrors `lunora/crons.ts`. */
@@ -3244,10 +3296,11 @@ declare const discoverHttpRoutes: (project: Project, lunoraDirectory: string) =>
3244
3296
  */
3245
3297
  declare const discoverHyperdriveCalls: (project: Project, lunoraDirectory: string) => ContextPropertyCallIR[];
3246
3298
  /**
3247
- * Discover `ctx.db.insert("table", …)` writes under the lunora source directory
3248
- * and attribute each to the exported function (and file) performing it. Calls
3249
- * with a non-literal table argument, or outside an exported declaration, are
3250
- * dropped (`table === ""` / no enclosing export).
3299
+ * Discover `ctx.db.insert("table", …)` writes under the lunora source directory,
3300
+ * one record per call site with its `CallSiteScope` — so an insert inside a
3301
+ * same-file helper carries the exports calling the helper, and one in a helper
3302
+ * no export calls is kept rather than lost. A non-literal table argument is kept
3303
+ * with `table: ""`.
3251
3304
  */
3252
3305
  declare const discoverInserts: (project: Project, lunoraDirectory: string) => InsertWriteIR[];
3253
3306
  /**
@@ -3330,7 +3383,8 @@ declare const discoverNotifyConfig: (project: Project, lunoraDirectory: string)
3330
3383
  declare const readPackageDependencies: (projectRoot: string) => Set<string> | undefined;
3331
3384
  /**
3332
3385
  * Discover every `ctx.db.query("table")…` read under the lunora source directory
3333
- * and reduce each to a {@link QueryReadIR}.
3386
+ * and reduce each to a {@link QueryReadIR}, one per read site with its
3387
+ * `CallSiteScope`.
3334
3388
  *
3335
3389
  * Reads without a `.filter()` are kept too. They are never
3336
3390
  * `filter_without_index` candidates (that lint gates on `hasFilter`), but an