@gate-forge/pack-sqlalchemy 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,8 +46,14 @@ with `ast.parse` and reports:
46
46
  (`table=True`), `no_tablename_source`. The graph retires an entry it
47
47
  resolves and synthesizes `inherited_tablename_unresolved` when it
48
48
  cannot.
49
- - **Findings** — `DUPLICATE_TABLE_NAME` (2-file and 1-file variants,
50
- GF-20), `CLASS_NAME_REPEATED_IN_FILE` (GF-01 non-collapse proof),
49
+ - **Findings** — `DUPLICATE_TABLE_NAME` (GF-20, **base-qualified**:
50
+ a same-name group is flagged unless every pair provably sits on a
51
+ different declarative Base root — separate `MetaData` at runtime — so
52
+ a test-file fixture Base or an intentional tenant/master model split
53
+ never blocks the gate; roots resolve through local alias chains and
54
+ imports into scanned files, and unprovable evidence — unresolved
55
+ bases, plain `Table()` calls — stays flagged, fail closed),
56
+ `CLASS_NAME_REPEATED_IN_FILE` (GF-01 non-collapse proof),
51
57
  `PARSE_ERROR` (GF-19).
52
58
 
53
59
  ## Setup
@@ -64,7 +70,7 @@ Both transports run the **same** detector; pick one per project:
64
70
  # .gateforge.yml
65
71
  plugins:
66
72
  - id: gateforge.pack-sqlalchemy
67
- version: 0.1.0
73
+ version: 0.2.0
68
74
  transport: subprocess
69
75
  command: ['python3', '-m', 'gateforge_sqlalchemy_detector']
70
76
  ```
@@ -81,7 +87,7 @@ export PYTHONPATH="$PWD/packages/pack-sqlalchemy/python:$PWD/packages/plugin-pro
81
87
  bootstraps the sibling client from the monorepo layout automatically.)
82
88
  The CLI spawns the plugin with the repo root as its working directory
83
89
  and passes repo-root-relative paths; the `version` must match the pack
84
- (`0.1.0`) — it is pinned at the GPP/3 handshake.
90
+ (`0.2.0`) — it is pinned at the GPP/3 handshake.
85
91
 
86
92
  ### In-process transport
87
93
 
@@ -89,7 +95,7 @@ and passes repo-root-relative paths; the `version` must match the pack
89
95
  # .gateforge.yml
90
96
  plugins:
91
97
  - id: gateforge.pack-sqlalchemy
92
- version: 0.1.0
98
+ version: 0.2.0
93
99
  transport: in-process
94
100
  module: '@gate-forge/pack-sqlalchemy'
95
101
  ```
@@ -324,7 +330,7 @@ convention.)
324
330
  | GF-01 | Function-local `Row` × 4 → 4 distinct stable IDs, `CLASS_NAME_REPEATED_IN_FILE` finding, no collapse |
325
331
  | GF-02 | 3 stacked decorators + default-valued calls → full reason (`3 decorator(s)`, return-expression kind), no truncation |
326
332
  | GF-19 | Malformed file → `PARSE_ERROR` finding with line 6, no resources, no crash |
327
- | GF-20 | `dupes` × 2 in one file + `shared_items` across two files → both `DUPLICATE_TABLE_NAME` variants, 3 distinct resources |
333
+ | GF-20 | `dupes` × 2 in one file (same Base → flagged) + `shared_items` across files with DISTINCT local Bases → suppressed + `shared_base_models.py` re-declaring it on the IMPORTED Base → flagged (base-qualified rule, `test/subprocess.test.ts`) |
328
334
  | GF-21 | declared_attr / f-string / call / name / `table=True` → typed unresolved entries, never absent |
329
335
  | — | Declarative `.gateforge/planes.json` (phase 5): path/tables rules apply with explicit-beats-general precedence (`tables` enumeration beats an overlapping glob; conflicts fail closed WITHIN a tier), `exclude` carves mixed-plane directory surfaces (excluded files never collide with per-file rules), no-match stays plane-unresolved, config absence is byte-identical (`test/planes.test.ts`) |
330
336
  | — | Cross-module inheritance resolved through the graph symbol table; genuinely computed chains stay typed-unresolved |
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { PACK_PLUGIN_ID, PACK_VERSION } from './version.js';
2
2
  export { createSqlalchemyDetector, DEFAULT_COMMAND, pythonEnvironment, applyPlaneMapping, applyPlanesConfig, PLANE_RULE_CONTRADICTION, type SqlalchemyDetector, type SqlalchemyDetectorOptions, } from './detector.js';
3
- export { DEFAULT_PLANES_CONFIG, NO_PLANE_MAPPING, PLANES_CONFIG_PATH, byTableName, planeRuleMatches, readPlanesConfigOrNull, resolvePlaneByRules, type PlaneConfigRule, type PlaneContext, type PlaneMatchInput, type PlaneResolution, type PlaneRule, type PlaneRuleHit, type PlanesConfig, type SqlalchemyPlane, } from './planes.js';
3
+ export { DEFAULT_PLANES_CONFIG, NO_PLANE_MAPPING, PLANES_CONFIG_PATH, byTableName, planeRuleMatches, readPlanesConfigOrNull, parsePlanesConfigText, resolvePlaneByRules, type PlaneConfigRule, type PlaneContext, type PlaneMatchInput, type PlaneResolution, type PlaneRule, type PlaneRuleHit, type PlanesConfig, type SqlalchemyPlane, } from './planes.js';
4
4
  export { EntityAdapterSchema, validateEntityAdapter, type EntityAdapter, type EntityAdapterContext, type NormalizedEntity, type EntityAdapterValidation, } from './adapter-schema.js';
5
5
  /** The default CLI in-process plugin module: `{ discover(paths) }`. */
6
6
  declare const _default: import("./detector.js").SqlalchemyDetector;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,uEAAuE;;AACvE,wBAA0C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,uEAAuE;;AACvE,wBAA0C"}
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@
24
24
  import { createSqlalchemyDetector } from './detector.js';
25
25
  export { PACK_PLUGIN_ID, PACK_VERSION } from './version.js';
26
26
  export { createSqlalchemyDetector, DEFAULT_COMMAND, pythonEnvironment, applyPlaneMapping, applyPlanesConfig, PLANE_RULE_CONTRADICTION, } from './detector.js';
27
- export { DEFAULT_PLANES_CONFIG, NO_PLANE_MAPPING, PLANES_CONFIG_PATH, byTableName, planeRuleMatches, readPlanesConfigOrNull, resolvePlaneByRules, } from './planes.js';
27
+ export { DEFAULT_PLANES_CONFIG, NO_PLANE_MAPPING, PLANES_CONFIG_PATH, byTableName, planeRuleMatches, readPlanesConfigOrNull, parsePlanesConfigText, resolvePlaneByRules, } from './planes.js';
28
28
  export { EntityAdapterSchema, validateEntityAdapter, } from './adapter-schema.js';
29
29
  /** The default CLI in-process plugin module: `{ discover(paths) }`. */
30
30
  export default createSqlalchemyDetector();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,GAGzB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,GASpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GAKtB,MAAM,qBAAqB,CAAC;AAC7B,uEAAuE;AACvE,eAAe,wBAAwB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,GAGzB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,GASpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GAKtB,MAAM,qBAAqB,CAAC;AAC7B,uEAAuE;AACvE,eAAe,wBAAwB,EAAE,CAAC"}
package/dist/planes.d.ts CHANGED
@@ -93,10 +93,11 @@ export interface PlanesConfig {
93
93
  /** The absent-config default: no rules, no mapping (byte-identical noop). */
94
94
  export declare const DEFAULT_PLANES_CONFIG: PlanesConfig;
95
95
  /**
96
- * Reads a declarative plane config document. Returns the default config
97
- * when the file is absent (normal; byte-identical to
98
- * {@link NO_PLANE_MAPPING}); malformed documents throw (fail closed —
99
- * the CLI surfaces the error instead of scanning with partial trust).
96
+ * Parses and validates one declarative plane config DOCUMENT TEXT
97
+ * (strict; every rule reviewed). Exported for generators that must
98
+ * self-check a proposed document BEFORE writing it (e.g. `gateforge
99
+ * init --planes`) — the exact validation the runtime reader applies,
100
+ * applied to the draft.
100
101
  *
101
102
  * Accepted shape: `{ rules: [{ match?, exclude?, tables?, plane, reason }] }` — a
102
103
  * rule carries EXACTLY ONE of `match` (repo-root-relative source-path
@@ -106,6 +107,13 @@ export declare const DEFAULT_PLANES_CONFIG: PlanesConfig;
106
107
  * repo-root-relative globs pruning files from its surface — rejected
107
108
  * on a `tables` rule).
108
109
  */
110
+ export declare function parsePlanesConfigText(text: string, path: string): PlanesConfig;
111
+ /**
112
+ * Reads a declarative plane config document. Returns the default config
113
+ * when the file is absent (normal; byte-identical to
114
+ * {@link NO_PLANE_MAPPING}); malformed documents throw (fail closed —
115
+ * the CLI surfaces the error instead of scanning with partial trust).
116
+ */
109
117
  export declare function readPlanesConfigOrNull(path: string | null): PlanesConfig;
110
118
  /** The facts one `sqlalchemy.table` resource is matched against. */
111
119
  export interface PlaneMatchInput {
@@ -1 +1 @@
1
- {"version":3,"file":"planes.d.ts","sourceRoot":"","sources":["../src/planes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAKH,wCAAwC;AACxC,MAAM,MAAM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,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,6EAA6E;IAC7E,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC;AAED,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,YAAY,EAAE,CAAC;IACvC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAWvF;AAoCD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,GAAG,eAAe,CAQjG"}
package/dist/planes.js CHANGED
@@ -159,10 +159,11 @@ function parsePlaneConfigRule(value, path, index) {
159
159
  };
160
160
  }
161
161
  /**
162
- * Reads a declarative plane config document. Returns the default config
163
- * when the file is absent (normal; byte-identical to
164
- * {@link NO_PLANE_MAPPING}); malformed documents throw (fail closed —
165
- * the CLI surfaces the error instead of scanning with partial trust).
162
+ * Parses and validates one declarative plane config DOCUMENT TEXT
163
+ * (strict; every rule reviewed). Exported for generators that must
164
+ * self-check a proposed document BEFORE writing it (e.g. `gateforge
165
+ * init --planes`) — the exact validation the runtime reader applies,
166
+ * applied to the draft.
166
167
  *
167
168
  * Accepted shape: `{ rules: [{ match?, exclude?, tables?, plane, reason }] }` — a
168
169
  * rule carries EXACTLY ONE of `match` (repo-root-relative source-path
@@ -172,16 +173,7 @@ function parsePlaneConfigRule(value, path, index) {
172
173
  * repo-root-relative globs pruning files from its surface — rejected
173
174
  * on a `tables` rule).
174
175
  */
175
- export function readPlanesConfigOrNull(path) {
176
- if (path === null)
177
- return DEFAULT_PLANES_CONFIG;
178
- let text;
179
- try {
180
- text = readFileSync(path, 'utf8');
181
- }
182
- catch {
183
- return DEFAULT_PLANES_CONFIG; // absence is normal; malformed is not (below)
184
- }
176
+ export function parsePlanesConfigText(text, path) {
185
177
  const parsed = JSON.parse(text);
186
178
  if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
187
179
  throw new Error(`invalid planes config: expected an object at ${path}`);
@@ -197,6 +189,24 @@ export function readPlanesConfigOrNull(path) {
197
189
  }
198
190
  return { rules: rules.map((rule, index) => parsePlaneConfigRule(rule, path, index)) };
199
191
  }
192
+ /**
193
+ * Reads a declarative plane config document. Returns the default config
194
+ * when the file is absent (normal; byte-identical to
195
+ * {@link NO_PLANE_MAPPING}); malformed documents throw (fail closed —
196
+ * the CLI surfaces the error instead of scanning with partial trust).
197
+ */
198
+ export function readPlanesConfigOrNull(path) {
199
+ if (path === null)
200
+ return DEFAULT_PLANES_CONFIG;
201
+ let text;
202
+ try {
203
+ text = readFileSync(path, 'utf8');
204
+ }
205
+ catch {
206
+ return DEFAULT_PLANES_CONFIG; // absence is normal; malformed is not (below)
207
+ }
208
+ return parsePlanesConfigText(text, path);
209
+ }
200
210
  /**
201
211
  * Whether one config rule matches one table resource. A `match` rule
202
212
  * globs the resource's repo-root-relative SOURCE FILE path with core's
@@ -1 +1 @@
1
- {"version":3,"file":"planes.js","sourceRoot":"","sources":["../src/planes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,M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AmB,CAAC,MAAoB,EAAE,KAAsB;IAC9E,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IAC1F,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1E,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACvD,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;AAC1D,CAAC"}
package/dist/version.d.ts CHANGED
@@ -8,5 +8,5 @@
8
8
  /** Plugin id every SQLAlchemy pack contribution is pinned to. */
9
9
  export declare const PACK_PLUGIN_ID = "gateforge.pack-sqlalchemy";
10
10
  /** Detector/pack version; must match `python/.../__init__.py::VERSION`. */
11
- export declare const PACK_VERSION = "0.1.0";
11
+ export declare const PACK_VERSION = "0.2.0";
12
12
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -8,5 +8,5 @@
8
8
  /** Plugin id every SQLAlchemy pack contribution is pinned to. */
9
9
  export const PACK_PLUGIN_ID = 'gateforge.pack-sqlalchemy';
10
10
  /** Detector/pack version; must match `python/.../__init__.py::VERSION`. */
11
- export const PACK_VERSION = '0.1.0';
11
+ export const PACK_VERSION = '0.2.0';
12
12
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gate-forge/pack-sqlalchemy",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "SQLAlchemy CRUD discovery pack: AST-only python detector (GPP/3), in-process TS discover entry, configurable plane mapping, entity-adapter schema.",
6
6
  "type": "module",
@@ -50,8 +50,12 @@ Detector vocabulary (frozen with the pack):
50
50
  - additional unresolved entries: ``PRIMARY_KEY_UNRESOLVED`` (computed
51
51
  or invisible primary key — the key is never defaulted to ``id``) and
52
52
  ``ARCHIVE_STATE_UNRESOLVED`` (non-literal archive declaration).
53
- - ``findings``: ``DUPLICATE_TABLE_NAME`` (GF-20: 2-file and 1-file
54
- variants), ``CLASS_NAME_REPEATED_IN_FILE`` (GF-01 non-collapse), and
53
+ - ``findings``: ``DUPLICATE_TABLE_NAME`` (GF-20, BASE-QUALIFIED: a
54
+ same-name group is flagged unless every pair provably sits on a
55
+ different declarative Base root — distinct ``MetaData`` at runtime —
56
+ so a test-file fixture Base or an intentional tenant/master split no
57
+ longer blocks the gate; unprovable evidence stays flagged),
58
+ ``CLASS_NAME_REPEATED_IN_FILE`` (GF-01 non-collapse), and
55
59
  ``PARSE_ERROR`` (GF-19: malformed files never crash the scan and
56
60
  contribute no resources).
57
61
 
@@ -65,4 +69,4 @@ canonical serializer.
65
69
  from __future__ import annotations
66
70
 
67
71
  PLUGIN_ID = "gateforge.pack-sqlalchemy"
68
- VERSION = "0.1.0"
72
+ VERSION = "0.2.0"
@@ -12,6 +12,15 @@ canonical detector vocabulary of the frozen resource graph:
12
12
  the class statement -- never absent, never guessed (ADR 0001 D1);
13
13
  - duplicate table names (GF-20) and repeated class names (GF-01) are
14
14
  findings; malformed files (GF-19) are ``PARSE_ERROR`` findings.
15
+ GF-20 is BASE-QUALIFIED (detector 0.2.0): a same ``__tablename__``
16
+ group is flagged unless every pair of declarations provably sits on
17
+ a DIFFERENT declarative Base root (distinct ``MetaData`` at
18
+ runtime). Base roots resolve through local alias chains and through
19
+ imports into scanned files; anything unprovable (unresolvable import,
20
+ ``Table("name", ...)`` calls, mixed evidence) stays flagged —
21
+ fail closed. Same name on different planes was never the detector's
22
+ call: plane qualification owns identity collapse (the graph's
23
+ ``detectDuplicateIds``).
15
24
 
16
25
  Classification signals (plan phase 3, ADR 0003 D1): the detector emits
17
26
  code-derived FACTS, never classifications and never exposure claims:
@@ -774,6 +783,26 @@ class FileIndex:
774
783
 
775
784
  visit(tree, [])
776
785
 
786
+ def class_by_qname(self, qname: str) -> ClassRecord | None:
787
+ """The class record with an exact dotted qname, if any."""
788
+ for rec in self.classes:
789
+ if rec.qname == qname:
790
+ return rec
791
+ return None
792
+
793
+ def class_by_simple_name(self, name: str) -> ClassRecord | None:
794
+ """The first class record with this simple name, if any.
795
+
796
+ Duplicate simple names inside one file (GF-01 territory) are a
797
+ real ambiguity: the first record wins deterministically, and any
798
+ collision finding built on the wrong record stays conservative
799
+ (unresolvable roots are never treated as distinct).
800
+ """
801
+ for rec in self.classes:
802
+ if rec.qname.rsplit(".", 1)[-1] == name:
803
+ return rec
804
+ return None
805
+
777
806
 
778
807
  def loc(relpath: str, node: ast.AST) -> dict:
779
808
  """Build the canonical location triple for an AST node.
@@ -1167,11 +1196,200 @@ def _unresolved_entry(relpath: str, rec: ClassRecord) -> dict:
1167
1196
  }
1168
1197
 
1169
1198
 
1170
- def _duplicate_findings(resources: list[dict]) -> list[dict]:
1171
- """Duplicate table names (GF-20): same name in 2 files or twice in 1.
1199
+ def _module_to_relpath(indexes: dict[str, "FileIndex"], module: str) -> str | None:
1200
+ """Maps a dotted module to the scanned file that defines it.
1201
+
1202
+ Args:
1203
+ indexes: Parsed-file indexes of one discovery request, keyed by
1204
+ repo-root-relative path.
1205
+ module: The dotted module of an import (absolute portion).
1206
+
1207
+ Returns:
1208
+ str | None: The scanned relpath whose dotted module path equals
1209
+ ``module`` or ends with ``.<module>`` (package-rooted
1210
+ layouts: ``backend`` on disk, ``app.backend`` in imports),
1211
+ when exactly one file matches; ``None`` when nothing or more
1212
+ than one matches (ambiguous provenance is never guessed).
1213
+ """
1214
+ matches: list[str] = []
1215
+ for relpath in indexes:
1216
+ parts = relpath.replace("\\", "/").split("/")
1217
+ if parts and parts[-1].endswith(".py"):
1218
+ parts[-1] = parts[-1][: -len(".py")]
1219
+ if parts and parts[-1] == "__init__":
1220
+ parts = parts[:-1]
1221
+ dotted = ".".join(parts)
1222
+ if dotted == module or dotted.endswith("." + module):
1223
+ matches.append(relpath)
1224
+ return matches[0] if len(matches) == 1 else None
1225
+
1226
+
1227
+ def _resolve_base_root(
1228
+ indexes: dict[str, "FileIndex"],
1229
+ relpath: str,
1230
+ name: str,
1231
+ visited: set[tuple[str, str]],
1232
+ ) -> str | None:
1233
+ """Resolves one base simple name to its declarative ROOT identity.
1234
+
1235
+ The identity of a SQLAlchemy ``MetaData`` is the declarative root a
1236
+ model descends from, so two same-named tables collide only when
1237
+ their roots coincide. Resolution follows the evidence a flat scan
1238
+ can actually see, in order:
1239
+
1240
+ 1. a locally registered declarative alias in the referencing file
1241
+ (``X = declarative_base()``, ``class X(DeclarativeBase)``
1242
+ chains) — identity is the alias itself, file-qualified;
1243
+ 2. a locally defined class — its own bases are chased (first base
1244
+ that resolves wins, so mixins in front of the root are skipped);
1245
+ 3. the literal ``DeclarativeBase`` — every direct subclass creates
1246
+ its OWN registry, so the identity is the referencing CLASS
1247
+ (passed via ``visited`` seed), not a shared global name;
1248
+ 4. an import — the imported name is resolved inside the scanned
1249
+ file that defines its module (exact or package-rooted suffix
1250
+ match, unique only), recursively; when no scanned file matches,
1251
+ the identity degrades to the module-qualified definition site,
1252
+ which still distinguishes two different source modules.
1253
+
1254
+ Args:
1255
+ indexes: Parsed-file indexes of one discovery request.
1256
+ relpath: Repo-root-relative path of the file referencing ``name``.
1257
+ name: The base simple name to resolve.
1258
+ visited: (relpath, name) pairs already being resolved (cycle guard).
1259
+
1260
+ Returns:
1261
+ str | None: The root identity id, or ``None`` when unprovable
1262
+ (the caller must then treat the declaration as NOT provably
1263
+ distinct — fail closed).
1264
+ """
1265
+ key = (relpath, name)
1266
+ if key in visited:
1267
+ return None
1268
+ visited.add(key)
1269
+ idx = indexes.get(relpath)
1270
+ if idx is None:
1271
+ return None
1272
+ if name in idx.declarative_base_aliases:
1273
+ return f"alias:{relpath}#{name}"
1274
+ rec = idx.class_by_simple_name(name)
1275
+ if rec is not None:
1276
+ # Chase the class's own bases in order; a leading mixin with no
1277
+ # declarative root of its own resolves to None here and the loop
1278
+ # simply continues to the next base (``class Account(Mixin, Base)``
1279
+ # must root at Base, not at the mixin). When NOTHING resolves the
1280
+ # name is unprovable — None keeps every pair involving it flagged.
1281
+ for base in rec.bases:
1282
+ resolved = _resolve_base_root(indexes, relpath, base, visited)
1283
+ if resolved is not None:
1284
+ return resolved
1285
+ return None
1286
+ if name == "DeclarativeBase":
1287
+ return None # handled by the caller via its own class identity
1288
+ ref = idx.imports.get(name)
1289
+ if ref is None or not ref.name or module_denied(ref.module):
1290
+ return None
1291
+ module = ref.module
1292
+ if ref.level > 0:
1293
+ # Relative imports resolve against the referencing file's package:
1294
+ # ``pkg/sub/mod.py`` is package ``pkg.sub``; level 1 is that
1295
+ # package itself, each further level pops one segment.
1296
+ package = relpath.replace("\\", "/").split("/")[:-1]
1297
+ if ref.level > 1:
1298
+ drop = ref.level - 1
1299
+ if len(package) < drop:
1300
+ return None
1301
+ package = package[: len(package) - drop]
1302
+ module = ".".join([*package, ref.module]) if ref.module else ".".join(package)
1303
+ if not module:
1304
+ return None
1305
+ mapped = _module_to_relpath(indexes, module)
1306
+ if mapped is not None:
1307
+ return _resolve_base_root(indexes, mapped, ref.name or name, visited)
1308
+ return f"module:{module}.{ref.name}"
1309
+
1310
+
1311
+ def _table_base_identities(
1312
+ indexes: dict[str, "FileIndex"], resource: dict
1313
+ ) -> set[str] | None:
1314
+ """The set of declarative root ids one table resource sits on.
1315
+
1316
+ Args:
1317
+ indexes: Parsed-file indexes of one discovery request.
1318
+ resource: A ``sqlalchemy.table`` business resource.
1319
+
1320
+ Returns:
1321
+ set[str] | None: The resolved root ids, or ``None`` when any
1322
+ direct base is unprovable or the resource carries no class
1323
+ evidence (``Table("name", ...)`` calls) — the caller must
1324
+ treat ``None`` as NOT provably distinct from anything.
1325
+ """
1326
+ qname = resource["attributes"].get("classQname")
1327
+ if not qname:
1328
+ return None
1329
+ idx = indexes.get(resource["source"])
1330
+ if idx is None:
1331
+ return None
1332
+ rec = idx.class_by_qname(qname)
1333
+ if rec is None or not rec.bases:
1334
+ return None
1335
+ # Identity-bearing bases only: a base that resolves to None is a
1336
+ # mixin or an unproven name — it contributes no MetaData identity of
1337
+ # its own, so it is skipped as long as at least one base resolves.
1338
+ # If NOTHING resolves, the declaration is unprovable (None → never
1339
+ # treated as distinct — fail closed).
1340
+ sites: set[str] = set()
1341
+ for base in rec.bases:
1342
+ if base == "DeclarativeBase" and base not in idx.declarative_base_aliases:
1343
+ # The class subclasses DeclarativeBase directly: it creates
1344
+ # its own registry, so ITS identity is the root.
1345
+ sites.add(f"root:{resource['source']}#{qname}")
1346
+ continue
1347
+ resolved = _resolve_base_root(indexes, resource["source"], base, set())
1348
+ if resolved is not None:
1349
+ sites.add(resolved)
1350
+ return sites or None
1351
+
1352
+
1353
+ def _provably_distinct(
1354
+ indexes: dict[str, "FileIndex"], group: list[dict]
1355
+ ) -> bool:
1356
+ """Whether every same-named declaration pair sits on a different root.
1357
+
1358
+ Args:
1359
+ indexes: Parsed-file indexes of one discovery request.
1360
+ group: The same-``__tablename__`` table resources (≥2).
1361
+
1362
+ Returns:
1363
+ bool: True only when EVERY pair carries fully-resolved,
1364
+ disjoint root-id sets — separate ``MetaData`` at runtime,
1365
+ so no collision is possible. Any unresolved or intersecting
1366
+ pair makes the group a finding candidate (fail closed).
1367
+ """
1368
+ identities = [_table_base_identities(indexes, resource) for resource in group]
1369
+ for first in range(len(identities)):
1370
+ for second in range(first + 1, len(identities)):
1371
+ left = identities[first]
1372
+ right = identities[second]
1373
+ if left is None or right is None or not left.isdisjoint(right):
1374
+ return False
1375
+ return True
1376
+
1377
+
1378
+ def _duplicate_findings(resources: list[dict], indexes: dict[str, "FileIndex"]) -> list[dict]:
1379
+ """Duplicate table names (GF-20), BASE-QUALIFIED since detector 0.2.0.
1380
+
1381
+ Same ``__tablename__`` in 2 files or twice in 1 is a finding unless
1382
+ every pair of declarations provably sits on a different declarative
1383
+ Base root (separate ``MetaData`` at runtime — the motivating real
1384
+ dogfood collisions were a test-file fixture Base and an intentional
1385
+ tenant/master model split, both correct code). Same name on
1386
+ different PLANES is never the detector's call either: plane
1387
+ qualification owns identity collapse (the graph's
1388
+ ``detectDuplicateIds``).
1172
1389
 
1173
1390
  Args:
1174
1391
  resources: The business table resources of one discovery request.
1392
+ indexes: Parsed-file indexes of one discovery request.
1175
1393
 
1176
1394
  Returns:
1177
1395
  list[dict]: One finding per duplicated table name, locations sorted.
@@ -1185,6 +1403,8 @@ def _duplicate_findings(resources: list[dict]) -> list[dict]:
1185
1403
  group = by_table[table_name]
1186
1404
  if len(group) < 2:
1187
1405
  continue
1406
+ if _provably_distinct(indexes, group):
1407
+ continue
1188
1408
  sorted_group = sorted(
1189
1409
  group,
1190
1410
  key=lambda g: (g["location"]["file"], g["location"]["line"], g["location"]["col"], g["id"]),
@@ -1423,7 +1643,7 @@ def scan(paths: list[str], root: Path | None = None) -> dict:
1423
1643
  u["location"]["col"], u["code"], u["detail"],
1424
1644
  )
1425
1645
  )
1426
- findings.extend(_duplicate_findings(resources))
1646
+ findings.extend(_duplicate_findings(resources, indexes))
1427
1647
  findings.extend(_class_name_findings(indexes, frozenset(model_names)))
1428
1648
  findings.sort(
1429
1649
  key=lambda f: (