pythia-core 0.1.0__tar.gz

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 (37) hide show
  1. pythia_core-0.1.0/LICENSE +21 -0
  2. pythia_core-0.1.0/PKG-INFO +146 -0
  3. pythia_core-0.1.0/README.md +120 -0
  4. pythia_core-0.1.0/pyproject.toml +38 -0
  5. pythia_core-0.1.0/setup.cfg +4 -0
  6. pythia_core-0.1.0/src/pythia_core/__init__.py +6 -0
  7. pythia_core-0.1.0/src/pythia_core/cli.py +762 -0
  8. pythia_core-0.1.0/src/pythia_core/config.py +161 -0
  9. pythia_core-0.1.0/src/pythia_core/doors.py +385 -0
  10. pythia_core-0.1.0/src/pythia_core/engine.py +195 -0
  11. pythia_core-0.1.0/src/pythia_core/gate.py +748 -0
  12. pythia_core-0.1.0/src/pythia_core/grants.py +108 -0
  13. pythia_core-0.1.0/src/pythia_core/harness.py +549 -0
  14. pythia_core-0.1.0/src/pythia_core/human.py +55 -0
  15. pythia_core-0.1.0/src/pythia_core/install.py +562 -0
  16. pythia_core-0.1.0/src/pythia_core/journal.py +98 -0
  17. pythia_core-0.1.0/src/pythia_core/lease.py +315 -0
  18. pythia_core-0.1.0/src/pythia_core/lint.py +134 -0
  19. pythia_core-0.1.0/src/pythia_core/output.py +167 -0
  20. pythia_core-0.1.0/src/pythia_core/policy.py +61 -0
  21. pythia_core-0.1.0/src/pythia_core/queries.py +88 -0
  22. pythia_core-0.1.0/src/pythia_core/release.py +519 -0
  23. pythia_core-0.1.0/src/pythia_core/skills.py +65 -0
  24. pythia_core-0.1.0/src/pythia_core.egg-info/PKG-INFO +146 -0
  25. pythia_core-0.1.0/src/pythia_core.egg-info/SOURCES.txt +35 -0
  26. pythia_core-0.1.0/src/pythia_core.egg-info/dependency_links.txt +1 -0
  27. pythia_core-0.1.0/src/pythia_core.egg-info/top_level.txt +1 -0
  28. pythia_core-0.1.0/tests/test_cli.py +165 -0
  29. pythia_core-0.1.0/tests/test_core.py +326 -0
  30. pythia_core-0.1.0/tests/test_doors.py +394 -0
  31. pythia_core-0.1.0/tests/test_family.py +313 -0
  32. pythia_core-0.1.0/tests/test_gate.py +639 -0
  33. pythia_core-0.1.0/tests/test_harness.py +490 -0
  34. pythia_core-0.1.0/tests/test_lease.py +329 -0
  35. pythia_core-0.1.0/tests/test_lint.py +178 -0
  36. pythia_core-0.1.0/tests/test_read.py +310 -0
  37. pythia_core-0.1.0/tests/test_release.py +358 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 thaild
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: pythia-core
3
+ Version: 0.1.0
4
+ Summary: Shared core of the pythia family: the engine contract, connection resolution and the write gate every pythia-<engine> package drives.
5
+ License-Expression: MIT
6
+ Project-URL: Repository, https://github.com/thaildhe172591/pythia-core
7
+ Project-URL: Changelog, https://github.com/thaildhe172591/pythia-core/blob/main/CHANGELOG.md
8
+ Project-URL: Issues, https://github.com/thaildhe172591/pythia-core/issues
9
+ Keywords: database,agent-skills,sql,postgresql,sql-server,mongodb
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Database
21
+ Classifier: Topic :: Software Development
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Dynamic: license-file
26
+
27
+ # pythia-core
28
+
29
+ **English** · [Tiếng Việt](https://github.com/thaildhe172591/pythia-core/blob/main/README.vi.md)
30
+
31
+ The part of pythia that is the same for every database. Engine packages
32
+ build on it: [pythia-postgres](https://github.com/thaildhe172591/pythia-postgres),
33
+ [pythia-mssql](https://github.com/thaildhe172591/pythia-mssql) and
34
+ [pythia-mongo](https://github.com/thaildhe172591/pythia-mongo).
35
+
36
+ **Alpha (0.1.0).** What is here today:
37
+ - the engine contract and its conformance check;
38
+ - per-engine connection resolution;
39
+ - the query-contract lint;
40
+ - the commands every engine's command line inherits:
41
+ - `version`, `connections` and `check`;
42
+ - the read commands `ls`, `src`, `cols`, `ddl`, `grep`, `deps`, `impact`
43
+ and `errors`, windowed and never truncated silently;
44
+ - the write gate: `apply` (snapshot, rehearse inside a transaction and
45
+ roll back — or, for what cannot be rehearsed, predict, then write once
46
+ and check what landed — preview), `approve` (the developer: at a console, or from
47
+ chat through AskUserQuestion and `approve --hook`, or the MCP approver
48
+ `mcp`),
49
+ `apply --confirm` (commits only what was approved), `policy`,
50
+ `journal list | show | restore` and `history`;
51
+ - `deploy <files>`: a release rehearsed and committed as one transaction,
52
+ under one approval — all of it lands, or none of it;
53
+ - `autopilot request | on | off | status | report`: a lease the developer
54
+ approves once, covering only the connection, groups and limits its card
55
+ names;
56
+ - `lint <files>` (and `lint --rules`): the engine's rules and the team's
57
+ severities and naming patterns over a change, shown in every preview;
58
+ - the harness: `hook pre-tool` (the guard that denies the ways around the
59
+ gate and waves through what cannot write), `hook session-start` (the
60
+ rules and the project's state), `install` (connections scaffold,
61
+ `.gitignore`, hooks, the MCP approver in this machine's own files,
62
+ instruction blocks, skills — a second run changes nothing), `doctor` and
63
+ `skill lint`.
64
+
65
+ What each gate stops, and what it does not, is in
66
+ [SECURITY.md](https://github.com/thaildhe172591/pythia-core/blob/main/SECURITY.md). The plan, and how each idea maps to each
67
+ database, is in [DESIGN.md](https://github.com/thaildhe172591/pythia-core/blob/main/DESIGN.md).
68
+
69
+ [pythia](https://github.com/thaildhe172591/pythia) for Oracle is a separate,
70
+ self-contained tool. It does not use this package and is not changed by it.
71
+
72
+ ## Install
73
+
74
+ ```bash
75
+ pip install pythia-core
76
+ ```
77
+
78
+ pythia-core alone has no command: install an engine package —
79
+ `pythia-postgres`, `pythia-mssql` or `pythia-mongo` — and it comes with it.
80
+ It depends on nothing outside the Python standard library, by contract. The
81
+ development version is the main branch:
82
+
83
+ ```bash
84
+ pip install "git+https://github.com/thaildhe172591/pythia-core"
85
+ ```
86
+
87
+ ## Writing an engine
88
+
89
+ ```python
90
+ from pythia_core import cli
91
+ from pythia_core.engine import engine_problems
92
+
93
+ class PostgresEngine:
94
+ name, label, command = "postgres", "PostgreSQL", "pythia-pg"
95
+ env_prefix, version, bind_style = "PYTHIA_PG", "0.1.0", "pyformat"
96
+ # ...the connect tier: driver_errors, connect, session, close,
97
+ # connect_failure, schema_of, target_of, server_version, current_schema
98
+ # ...the read tier: object_names, source, columns (which may name a
99
+ # blind spot, when its columns are inferred), ddl, grep, dependencies,
100
+ # dependents, compile_errors
101
+ # ...and the write tier: classify, prepare_statement, parse_object,
102
+ # destructive_reason, dml_probe, measure_row_set, snapshot, rehearse,
103
+ # restore_statement, privilege_warning
104
+ # ...the predict tier, for statements that cannot be rehearsed:
105
+ # execute, verify_written
106
+ # ...the harness tier: raw_client_pattern, write_sql_pattern,
107
+ # script_pattern, connections_template, skills_dir
108
+ # ...the release tier: split_script
109
+ # ...and the lint tier: lint_rules
110
+
111
+ assert engine_problems(PostgresEngine(),
112
+ ("connect", "read", "write", "harness", "release",
113
+ "lint")) == []
114
+
115
+ def main(argv=None):
116
+ return cli.main(PostgresEngine(), argv) # your console script
117
+ ```
118
+
119
+ Each engine keeps its connections in `.pythia/<engine>/connections.json`.
120
+ That is never pythia for Oracle's `.pythia/connections.json`, so one project
121
+ can use both safely.
122
+
123
+ ## Tests (no database, no driver)
124
+
125
+ ```bash
126
+ python tests/test_core.py
127
+ python tests/test_cli.py
128
+ python tests/test_read.py
129
+ python tests/test_gate.py
130
+ python tests/test_harness.py
131
+ python tests/test_doors.py
132
+ python tests/test_release.py
133
+ python tests/test_lease.py
134
+ python tests/test_lint.py
135
+ python tests/test_family.py # several engines in one project, with two fakes
136
+ ```
137
+
138
+ CI runs them on Ubuntu, Windows and macOS, Python 3.9 and 3.13. Its
139
+ `family` job also installs pythia for Oracle and the three engines into one
140
+ project and runs `tests/family_check.py`: every install keeps the others'
141
+ hooks and blocks, a second run changes nothing, each doctor passes, each
142
+ guard and answer hook acts for its own engine only.
143
+
144
+ ## License
145
+
146
+ MIT
@@ -0,0 +1,120 @@
1
+ # pythia-core
2
+
3
+ **English** · [Tiếng Việt](https://github.com/thaildhe172591/pythia-core/blob/main/README.vi.md)
4
+
5
+ The part of pythia that is the same for every database. Engine packages
6
+ build on it: [pythia-postgres](https://github.com/thaildhe172591/pythia-postgres),
7
+ [pythia-mssql](https://github.com/thaildhe172591/pythia-mssql) and
8
+ [pythia-mongo](https://github.com/thaildhe172591/pythia-mongo).
9
+
10
+ **Alpha (0.1.0).** What is here today:
11
+ - the engine contract and its conformance check;
12
+ - per-engine connection resolution;
13
+ - the query-contract lint;
14
+ - the commands every engine's command line inherits:
15
+ - `version`, `connections` and `check`;
16
+ - the read commands `ls`, `src`, `cols`, `ddl`, `grep`, `deps`, `impact`
17
+ and `errors`, windowed and never truncated silently;
18
+ - the write gate: `apply` (snapshot, rehearse inside a transaction and
19
+ roll back — or, for what cannot be rehearsed, predict, then write once
20
+ and check what landed — preview), `approve` (the developer: at a console, or from
21
+ chat through AskUserQuestion and `approve --hook`, or the MCP approver
22
+ `mcp`),
23
+ `apply --confirm` (commits only what was approved), `policy`,
24
+ `journal list | show | restore` and `history`;
25
+ - `deploy <files>`: a release rehearsed and committed as one transaction,
26
+ under one approval — all of it lands, or none of it;
27
+ - `autopilot request | on | off | status | report`: a lease the developer
28
+ approves once, covering only the connection, groups and limits its card
29
+ names;
30
+ - `lint <files>` (and `lint --rules`): the engine's rules and the team's
31
+ severities and naming patterns over a change, shown in every preview;
32
+ - the harness: `hook pre-tool` (the guard that denies the ways around the
33
+ gate and waves through what cannot write), `hook session-start` (the
34
+ rules and the project's state), `install` (connections scaffold,
35
+ `.gitignore`, hooks, the MCP approver in this machine's own files,
36
+ instruction blocks, skills — a second run changes nothing), `doctor` and
37
+ `skill lint`.
38
+
39
+ What each gate stops, and what it does not, is in
40
+ [SECURITY.md](https://github.com/thaildhe172591/pythia-core/blob/main/SECURITY.md). The plan, and how each idea maps to each
41
+ database, is in [DESIGN.md](https://github.com/thaildhe172591/pythia-core/blob/main/DESIGN.md).
42
+
43
+ [pythia](https://github.com/thaildhe172591/pythia) for Oracle is a separate,
44
+ self-contained tool. It does not use this package and is not changed by it.
45
+
46
+ ## Install
47
+
48
+ ```bash
49
+ pip install pythia-core
50
+ ```
51
+
52
+ pythia-core alone has no command: install an engine package —
53
+ `pythia-postgres`, `pythia-mssql` or `pythia-mongo` — and it comes with it.
54
+ It depends on nothing outside the Python standard library, by contract. The
55
+ development version is the main branch:
56
+
57
+ ```bash
58
+ pip install "git+https://github.com/thaildhe172591/pythia-core"
59
+ ```
60
+
61
+ ## Writing an engine
62
+
63
+ ```python
64
+ from pythia_core import cli
65
+ from pythia_core.engine import engine_problems
66
+
67
+ class PostgresEngine:
68
+ name, label, command = "postgres", "PostgreSQL", "pythia-pg"
69
+ env_prefix, version, bind_style = "PYTHIA_PG", "0.1.0", "pyformat"
70
+ # ...the connect tier: driver_errors, connect, session, close,
71
+ # connect_failure, schema_of, target_of, server_version, current_schema
72
+ # ...the read tier: object_names, source, columns (which may name a
73
+ # blind spot, when its columns are inferred), ddl, grep, dependencies,
74
+ # dependents, compile_errors
75
+ # ...and the write tier: classify, prepare_statement, parse_object,
76
+ # destructive_reason, dml_probe, measure_row_set, snapshot, rehearse,
77
+ # restore_statement, privilege_warning
78
+ # ...the predict tier, for statements that cannot be rehearsed:
79
+ # execute, verify_written
80
+ # ...the harness tier: raw_client_pattern, write_sql_pattern,
81
+ # script_pattern, connections_template, skills_dir
82
+ # ...the release tier: split_script
83
+ # ...and the lint tier: lint_rules
84
+
85
+ assert engine_problems(PostgresEngine(),
86
+ ("connect", "read", "write", "harness", "release",
87
+ "lint")) == []
88
+
89
+ def main(argv=None):
90
+ return cli.main(PostgresEngine(), argv) # your console script
91
+ ```
92
+
93
+ Each engine keeps its connections in `.pythia/<engine>/connections.json`.
94
+ That is never pythia for Oracle's `.pythia/connections.json`, so one project
95
+ can use both safely.
96
+
97
+ ## Tests (no database, no driver)
98
+
99
+ ```bash
100
+ python tests/test_core.py
101
+ python tests/test_cli.py
102
+ python tests/test_read.py
103
+ python tests/test_gate.py
104
+ python tests/test_harness.py
105
+ python tests/test_doors.py
106
+ python tests/test_release.py
107
+ python tests/test_lease.py
108
+ python tests/test_lint.py
109
+ python tests/test_family.py # several engines in one project, with two fakes
110
+ ```
111
+
112
+ CI runs them on Ubuntu, Windows and macOS, Python 3.9 and 3.13. Its
113
+ `family` job also installs pythia for Oracle and the three engines into one
114
+ project and runs `tests/family_check.py`: every install keeps the others'
115
+ hooks and blocks, a second run changes nothing, each doctor passes, each
116
+ guard and answer hook acts for its own engine only.
117
+
118
+ ## License
119
+
120
+ MIT
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pythia-core"
7
+ version = "0.1.0"
8
+ description = "Shared core of the pythia family: the engine contract, connection resolution and the write gate every pythia-<engine> package drives."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.9"
13
+ # stdlib only, by contract (tests/test_core.py): a driver belongs to the
14
+ # engine package that needs it, so nobody installs one they do not use
15
+ dependencies = []
16
+ keywords = ["database", "agent-skills", "sql", "postgresql", "sql-server", "mongodb"]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Environment :: Console",
20
+ "Intended Audience :: Developers",
21
+ "Operating System :: OS Independent",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Programming Language :: Python :: 3.13",
28
+ "Topic :: Database",
29
+ "Topic :: Software Development",
30
+ ]
31
+
32
+ [project.urls]
33
+ Repository = "https://github.com/thaildhe172591/pythia-core"
34
+ Changelog = "https://github.com/thaildhe172591/pythia-core/blob/main/CHANGELOG.md"
35
+ Issues = "https://github.com/thaildhe172591/pythia-core/issues"
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ """pythia-core: the part of pythia that is the same for every database.
2
+
3
+ Engine packages (pythia-postgres first) build on it; see DESIGN.md. pythia
4
+ for Oracle is a separate, self-contained tool and does not use this package.
5
+ """
6
+ __version__ = "0.1.0" # kept equal to pyproject.toml (tests/test_core.py)