@gate-forge/pack-sqlalchemy 0.7.1 → 0.9.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 +98 -5
- package/dist/detector.d.ts +19 -2
- package/dist/detector.d.ts.map +1 -1
- package/dist/detector.js +42 -9
- package/dist/detector.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/singleton.d.ts +103 -0
- package/dist/singleton.d.ts.map +1 -0
- package/dist/singleton.js +146 -0
- package/dist/singleton.js.map +1 -0
- package/dist/tenancy.d.ts +18 -0
- package/dist/tenancy.d.ts.map +1 -0
- package/dist/tenancy.js +93 -0
- package/dist/tenancy.js.map +1 -0
- package/dist/test-paths.d.ts +40 -0
- package/dist/test-paths.d.ts.map +1 -0
- package/dist/test-paths.js +49 -0
- package/dist/test-paths.js.map +1 -0
- package/package.json +7 -4
- package/python/gateforge_sqlalchemy_detector/__init__.py +12 -2
- package/python/gateforge_sqlalchemy_detector/scan.py +343 -30
- package/python/gateforge_sqlalchemy_detector/__pycache__/__init__.cpython-314.pyc +0 -0
- package/python/gateforge_sqlalchemy_detector/__pycache__/__main__.cpython-314.pyc +0 -0
- package/python/gateforge_sqlalchemy_detector/__pycache__/scan.cpython-314.pyc +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singleton.js","sourceRoot":"","sources":["../src/singleton.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,oBAAoB,GAAsB,MAAM,CAAC,MAAM,CAAC;IACnE,WAAW;IACX,QAAQ;IACR,UAAU;IACV,aAAa;IACb,YAAY;CACb,CAAC,CAAC;AA+BH;;;GAGG;AACH,SAAS,kBAAkB,CAAC,KAAc;IACxC,IAAI,OAAO,KAAK,KAA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,EAAE,CAAC;IAC3F,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Repo-relative path of the owner config this channel reads. */
|
|
2
|
+
export declare const CONFIG_PATH = ".gateforge.yml";
|
|
3
|
+
/**
|
|
4
|
+
* Reads the owner-declared tenant scope columns out of a config file.
|
|
5
|
+
*
|
|
6
|
+
* Args:
|
|
7
|
+
* path: Absolute or cwd-relative config path; null disables the
|
|
8
|
+
* channel entirely (today's behavior, byte-identical).
|
|
9
|
+
*
|
|
10
|
+
* Returns:
|
|
11
|
+
* readonly string[] | null: the declared columns, or null when the
|
|
12
|
+
* file is absent/unreadable or declares no tenancy scope.
|
|
13
|
+
*
|
|
14
|
+
* Raises:
|
|
15
|
+
* Error: for unparsable YAML or a malformed `tenancy` block.
|
|
16
|
+
*/
|
|
17
|
+
export declare function readTenancyScopeColumnsOrNull(path: string | null): readonly string[] | null;
|
|
18
|
+
//# sourceMappingURL=tenancy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenancy.d.ts","sourceRoot":"","sources":["../src/tenancy.ts"],"names":[],"mappings":"AA+BA,iEAAiE;AACjE,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAE5C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CA2C3F"}
|
package/dist/tenancy.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The owner-declared tenant scope channel (plan 2026-09-25 Phase 4b
|
|
3
|
+
* item 3a).
|
|
4
|
+
*
|
|
5
|
+
* The per-tenant-singleton tag needs to know which column carries the
|
|
6
|
+
* tenant scope. The pack ships a FIXED default list of the usual
|
|
7
|
+
* spellings (`tenant_id`, `tenant`, ...), but scope columns differ per
|
|
8
|
+
* application — the incident's ledger table is scoped by
|
|
9
|
+
* `contractor_id`. The owner therefore declares them in `.gateforge.yml`:
|
|
10
|
+
*
|
|
11
|
+
* ```yaml
|
|
12
|
+
* tenancy:
|
|
13
|
+
* scopeColumns: [contractor_id]
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* The declaration REPLACES the default list (never extends it), so the
|
|
17
|
+
* recognized scope is exactly what the owner said and nothing else. A
|
|
18
|
+
* missing file, a missing key, and a config that says nothing about
|
|
19
|
+
* tenancy all read as `null` — absence, byte-identical to today. A
|
|
20
|
+
* present but MALFORMED `tenancy` block throws (fail closed, a typo must
|
|
21
|
+
* not silently disable the tag).
|
|
22
|
+
*
|
|
23
|
+
* SCOPE: this reader validates the `tenancy` block only. The pack is a
|
|
24
|
+
* detector, not the config authority — the CLI loads `.gateforge.yml`
|
|
25
|
+
* fail-closed before any pack runs, and a detector must keep working
|
|
26
|
+
* (byte-identically) in a repository whose config carries an unrelated
|
|
27
|
+
* problem it has no opinion about.
|
|
28
|
+
*/
|
|
29
|
+
import { readFileSync } from 'node:fs';
|
|
30
|
+
import { parse as parseYaml } from 'yaml';
|
|
31
|
+
/** Repo-relative path of the owner config this channel reads. */
|
|
32
|
+
export const CONFIG_PATH = '.gateforge.yml';
|
|
33
|
+
/**
|
|
34
|
+
* Reads the owner-declared tenant scope columns out of a config file.
|
|
35
|
+
*
|
|
36
|
+
* Args:
|
|
37
|
+
* path: Absolute or cwd-relative config path; null disables the
|
|
38
|
+
* channel entirely (today's behavior, byte-identical).
|
|
39
|
+
*
|
|
40
|
+
* Returns:
|
|
41
|
+
* readonly string[] | null: the declared columns, or null when the
|
|
42
|
+
* file is absent/unreadable or declares no tenancy scope.
|
|
43
|
+
*
|
|
44
|
+
* Raises:
|
|
45
|
+
* Error: for unparsable YAML or a malformed `tenancy` block.
|
|
46
|
+
*/
|
|
47
|
+
export function readTenancyScopeColumnsOrNull(path) {
|
|
48
|
+
if (path === null)
|
|
49
|
+
return null;
|
|
50
|
+
let text;
|
|
51
|
+
try {
|
|
52
|
+
text = readFileSync(path, 'utf8');
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return null; // absence is normal; malformed is not (below)
|
|
56
|
+
}
|
|
57
|
+
let document;
|
|
58
|
+
try {
|
|
59
|
+
document = parseYaml(text);
|
|
60
|
+
}
|
|
61
|
+
catch (cause) {
|
|
62
|
+
throw new Error(`invalid config ${path}: invalid YAML: ${cause.message.split('\n')[0] ?? 'parse error'}`);
|
|
63
|
+
}
|
|
64
|
+
if (document === null || document === undefined)
|
|
65
|
+
return null;
|
|
66
|
+
if (typeof document !== 'object' || Array.isArray(document)) {
|
|
67
|
+
throw new Error(`invalid config ${path}: expected a mapping at the document root`);
|
|
68
|
+
}
|
|
69
|
+
const tenancy = document['tenancy'];
|
|
70
|
+
if (tenancy === undefined)
|
|
71
|
+
return null;
|
|
72
|
+
if (typeof tenancy !== 'object' || tenancy === null || Array.isArray(tenancy)) {
|
|
73
|
+
throw new Error(`invalid config ${path}: 'tenancy' must be a mapping`);
|
|
74
|
+
}
|
|
75
|
+
const block = tenancy;
|
|
76
|
+
const unknownKeys = Object.keys(block).filter((key) => key !== 'scopeColumns');
|
|
77
|
+
if (unknownKeys.length > 0) {
|
|
78
|
+
throw new Error(`invalid config ${path}: unknown key(s) ${unknownKeys.sort().join(', ')} under 'tenancy'`);
|
|
79
|
+
}
|
|
80
|
+
const declared = block['scopeColumns'];
|
|
81
|
+
if (declared === undefined)
|
|
82
|
+
return null; // the block exists but says nothing
|
|
83
|
+
if (!Array.isArray(declared) || declared.length === 0) {
|
|
84
|
+
throw new Error(`invalid config ${path}: 'tenancy.scopeColumns' must be a nonempty list of column names`);
|
|
85
|
+
}
|
|
86
|
+
for (const column of declared) {
|
|
87
|
+
if (typeof column !== 'string' || column.length === 0) {
|
|
88
|
+
throw new Error(`invalid config ${path}: 'tenancy.scopeColumns' must be a nonempty list of column names`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return Object.freeze([...declared]);
|
|
92
|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qB,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one generic rule for "this path is test fixture surface, not
|
|
3
|
+
* business surface", shared by everything in this pack and by the CLI's
|
|
4
|
+
* plane-proposal steps.
|
|
5
|
+
*
|
|
6
|
+
* WHY it exists (problem 14): `gateforge init` already refused to infer
|
|
7
|
+
* a business plane for a table declared under a test directory, but the
|
|
8
|
+
* RESOURCE GRAPH still ingested those tables. A test module that declares
|
|
9
|
+
* a fixture table with the same name as a real one (a very common pytest
|
|
10
|
+
* pattern) then collided with it, and the real resource became
|
|
11
|
+
* plane-unresolved or unclassified — a blocking entry with no honest
|
|
12
|
+
* answer. A fixture is not business surface: it never carries the plane
|
|
13
|
+
* of the table it copies, so it must not enter the graph at all.
|
|
14
|
+
*
|
|
15
|
+
* The rule is deliberately the narrowest one that covers the convention:
|
|
16
|
+
* a path is test surface when ANY of its DIRECTORY segments is exactly
|
|
17
|
+
* `test` or `tests` (case-insensitive). It is segment-exact, never a
|
|
18
|
+
* string prefix — `contest/` and `tests_old/` are business surface, and
|
|
19
|
+
* so is a file merely NAMED `test_foo.py` next to real models. The
|
|
20
|
+
* detector in `python/gateforge_sqlalchemy_detector/scan.py` applies the
|
|
21
|
+
* identical segment rule; the two must stay in step, which
|
|
22
|
+
* `test/test-directory-models.test.ts` pins by scanning one repo through
|
|
23
|
+
* both.
|
|
24
|
+
*/
|
|
25
|
+
/** Directory segments that mark test fixture surface (exact segment match). */
|
|
26
|
+
export declare const TEST_PATH_SEGMENTS: readonly string[];
|
|
27
|
+
/**
|
|
28
|
+
* Whether a repo-relative posix path names test fixture surface.
|
|
29
|
+
*
|
|
30
|
+
* Args:
|
|
31
|
+
* source: Repo-root-relative source path of a resource or route
|
|
32
|
+
* (backslashes accepted and normalized).
|
|
33
|
+
*
|
|
34
|
+
* Returns:
|
|
35
|
+
* boolean: true when any directory segment of the path is `test` or
|
|
36
|
+
* `tests` (case-insensitive); false for everything else, including
|
|
37
|
+
* the repository root and files whose NAME merely starts with `test`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isTestSourcePath(source: string): boolean;
|
|
40
|
+
//# sourceMappingURL=test-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-paths.d.ts","sourceRoot":"","sources":["../src/test-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAqC,CAAC;AAEtF;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAWxD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one generic rule for "this path is test fixture surface, not
|
|
3
|
+
* business surface", shared by everything in this pack and by the CLI's
|
|
4
|
+
* plane-proposal steps.
|
|
5
|
+
*
|
|
6
|
+
* WHY it exists (problem 14): `gateforge init` already refused to infer
|
|
7
|
+
* a business plane for a table declared under a test directory, but the
|
|
8
|
+
* RESOURCE GRAPH still ingested those tables. A test module that declares
|
|
9
|
+
* a fixture table with the same name as a real one (a very common pytest
|
|
10
|
+
* pattern) then collided with it, and the real resource became
|
|
11
|
+
* plane-unresolved or unclassified — a blocking entry with no honest
|
|
12
|
+
* answer. A fixture is not business surface: it never carries the plane
|
|
13
|
+
* of the table it copies, so it must not enter the graph at all.
|
|
14
|
+
*
|
|
15
|
+
* The rule is deliberately the narrowest one that covers the convention:
|
|
16
|
+
* a path is test surface when ANY of its DIRECTORY segments is exactly
|
|
17
|
+
* `test` or `tests` (case-insensitive). It is segment-exact, never a
|
|
18
|
+
* string prefix — `contest/` and `tests_old/` are business surface, and
|
|
19
|
+
* so is a file merely NAMED `test_foo.py` next to real models. The
|
|
20
|
+
* detector in `python/gateforge_sqlalchemy_detector/scan.py` applies the
|
|
21
|
+
* identical segment rule; the two must stay in step, which
|
|
22
|
+
* `test/test-directory-models.test.ts` pins by scanning one repo through
|
|
23
|
+
* both.
|
|
24
|
+
*/
|
|
25
|
+
/** Directory segments that mark test fixture surface (exact segment match). */
|
|
26
|
+
export const TEST_PATH_SEGMENTS = Object.freeze(['tests', 'test']);
|
|
27
|
+
/**
|
|
28
|
+
* Whether a repo-relative posix path names test fixture surface.
|
|
29
|
+
*
|
|
30
|
+
* Args:
|
|
31
|
+
* source: Repo-root-relative source path of a resource or route
|
|
32
|
+
* (backslashes accepted and normalized).
|
|
33
|
+
*
|
|
34
|
+
* Returns:
|
|
35
|
+
* boolean: true when any directory segment of the path is `test` or
|
|
36
|
+
* `tests` (case-insensitive); false for everything else, including
|
|
37
|
+
* the repository root and files whose NAME merely starts with `test`.
|
|
38
|
+
*/
|
|
39
|
+
export function isTestSourcePath(source) {
|
|
40
|
+
const segments = source
|
|
41
|
+
.replaceAll('\\', '/')
|
|
42
|
+
.split('/')
|
|
43
|
+
// The last segment is the file name itself; only DIRECTORY segments
|
|
44
|
+
// decide, so `models/test_accounts.py` is not test surface while
|
|
45
|
+
// `tests/models.py` is.
|
|
46
|
+
.slice(0, -1);
|
|
47
|
+
return segments.some((segment) => TEST_PATH_SEGMENTS.includes(segment.toLowerCase()));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=test-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-paths.js","sourceRoot":"","sources":["../src/test-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,MAAM,QAAQ,GAAG,MAAM;SACpB,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC;SACrB,KAAK,CAAC,GAAG,CAAC;QACX,oEAAoE;QACpE,iEAAiE;QACjE,wBAAwB;SACvB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAChB,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAC/B,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CACnD,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gate-forge/pack-sqlalchemy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
"README.md",
|
|
18
18
|
"dist",
|
|
19
19
|
"examples",
|
|
20
|
-
"python"
|
|
20
|
+
"python",
|
|
21
|
+
"!**/__pycache__",
|
|
22
|
+
"!**/*.pyc",
|
|
23
|
+
"!**/*.pyo"
|
|
21
24
|
],
|
|
22
25
|
"scripts": {
|
|
23
26
|
"build": "tsc -p tsconfig.build.json",
|
|
@@ -25,8 +28,8 @@
|
|
|
25
28
|
"test": "vitest run"
|
|
26
29
|
},
|
|
27
30
|
"dependencies": {
|
|
28
|
-
"@gate-forge/core": "^0.
|
|
29
|
-
"@gate-forge/plugin-protocol": "^0.
|
|
31
|
+
"@gate-forge/core": "^0.9.0",
|
|
32
|
+
"@gate-forge/plugin-protocol": "^0.9.0",
|
|
30
33
|
"yaml": "^2.8.1",
|
|
31
34
|
"zod": "^4.1.5"
|
|
32
35
|
},
|
|
@@ -31,8 +31,17 @@ Detector vocabulary (frozen with the pack):
|
|
|
31
31
|
``argparse``, ``dataclasses``, ``marshmallow``, ``fastapi`` — can
|
|
32
32
|
never qualify. A non-candidate class is emitted NOWHERE: no symbol,
|
|
33
33
|
no table, no unresolved entry.
|
|
34
|
+
- SQLModel tables: ``class X(SQLModel, table=True)`` (or a shared
|
|
35
|
+
``SQLModel`` base, resolved through a cross-file SQLModel closure) is a
|
|
36
|
+
table whose name SQLModel derives at runtime by lowercasing the class
|
|
37
|
+
name. The AST can see that rule, so the name is a FACT
|
|
38
|
+
(``tablenameProvenance`` ``sqlmodel-class-name``), not a guess. A
|
|
39
|
+
``Field(...)`` call counts as a column constructor only when the file
|
|
40
|
+
imports it from ``sqlmodel``; ``table=False`` (or a computed value) is
|
|
41
|
+
NOT a table, so a plain SQLModel class is invisible in every channel.
|
|
34
42
|
- ``unresolved`` entries: typed reasons (``computed_tablename``,
|
|
35
|
-
``table_name_derived_runtime
|
|
43
|
+
``table_name_derived_runtime`` — a ``table=True`` on a NON-SQLModel
|
|
44
|
+
base, whose name the AST cannot see, ``no_tablename_source``) located at
|
|
36
45
|
the class statement; the graph retires them when it resolves the name
|
|
37
46
|
and synthesizes ``inherited_tablename_unresolved`` when it cannot
|
|
38
47
|
(GF-21: computed identity is typed, never absent).
|
|
@@ -43,7 +52,8 @@ Detector vocabulary (frozen with the pack):
|
|
|
43
52
|
``__gateforge_delete_semantics__``, ``__gateforge_archive_state__``,
|
|
44
53
|
``__gateforge_read_only__``; never an exposure claim (a table
|
|
45
54
|
declaration proves nothing about external reachability).
|
|
46
|
-
- additional table attributes: ``
|
|
55
|
+
- additional table attributes: ``columnNames`` (every literal column,
|
|
56
|
+
written order), ``primaryKeyColumns``,
|
|
47
57
|
``foreignKeyReferences`` (literal ``ForeignKey`` targets),
|
|
48
58
|
``softDeleteCandidateFields`` (bookkeeping-resembling column names —
|
|
49
59
|
facts for reviewers, never semantics), ``readOnly``.
|