pythia-plsql 0.11.0__tar.gz → 0.11.1__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 (44) hide show
  1. {pythia_plsql-0.11.0/scripts/pythia_plsql.egg-info → pythia_plsql-0.11.1}/PKG-INFO +1 -1
  2. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/pyproject.toml +1 -1
  3. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/scripts/pythia.py +30 -6
  4. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1/scripts/pythia_plsql.egg-info}/PKG-INFO +1 -1
  5. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/tests/test_phase3.py +58 -0
  6. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/LICENSE +0 -0
  7. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/README.md +0 -0
  8. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/compile-errors.sql +0 -0
  9. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/current-schema.sql +0 -0
  10. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/dependencies.sql +0 -0
  11. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/impact.sql +0 -0
  12. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/invalid-objects.sql +0 -0
  13. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/name-occupants.sql +0 -0
  14. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/object-names.sql +0 -0
  15. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/object-source.sql +0 -0
  16. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/plscope-enabled.sql +0 -0
  17. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/plscope-statements.sql +0 -0
  18. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/plscope-usages.sql +0 -0
  19. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/session-privileges.sql +0 -0
  20. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/similar-candidates.sql +0 -0
  21. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/queries/source.sql +0 -0
  22. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/scripts/pythia_plsql.egg-info/SOURCES.txt +0 -0
  23. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/scripts/pythia_plsql.egg-info/dependency_links.txt +0 -0
  24. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/scripts/pythia_plsql.egg-info/entry_points.txt +0 -0
  25. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/scripts/pythia_plsql.egg-info/requires.txt +0 -0
  26. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/scripts/pythia_plsql.egg-info/top_level.txt +0 -0
  27. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/setup.cfg +0 -0
  28. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-apply/SKILL.md +0 -0
  29. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-conventions/SKILL.md +0 -0
  30. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-explore/SKILL.md +0 -0
  31. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-explore/reference/data-dictionary.md +0 -0
  32. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-impact/SKILL.md +0 -0
  33. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-review/SKILL.md +0 -0
  34. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-review/reference/antipatterns.md +0 -0
  35. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-setup/SKILL.md +0 -0
  36. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-skill-author/SKILL.md +0 -0
  37. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-spec/SKILL.md +0 -0
  38. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-write/SKILL.md +0 -0
  39. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/pythia-write/reference/patterns.md +0 -0
  40. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/skills/using-pythia/SKILL.md +0 -0
  41. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/tests/test_install.py +0 -0
  42. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/tests/test_phase1.py +0 -0
  43. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/tests/test_phase2.py +0 -0
  44. {pythia_plsql-0.11.0 → pythia_plsql-0.11.1}/tests/test_phase5.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythia-plsql
3
- Version: 0.11.0
3
+ Version: 0.11.1
4
4
  Summary: PL/SQL development for AI agents on Oracle Database - expert data-dictionary queries, impact analysis, and a snapshot-verified write path with honest rollback.
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/thaildhe172591/pythia
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pythia-plsql"
7
- version = "0.11.0"
7
+ version = "0.11.1"
8
8
  description = "PL/SQL development for AI agents on Oracle Database - expert data-dictionary queries, impact analysis, and a snapshot-verified write path with honest rollback."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -713,7 +713,12 @@ def plscope_message(name, has_any_data):
713
713
  GROUPS = ("plsql_source", "data_dml", "structural", "grants", "session")
714
714
 
715
715
  PLSQL_SOURCE_RE = re.compile(
716
- r"^create\s+(?:or\s+replace\s+)?(?:(?:no)?editionable\s+|(?:no)?force\s+)*"
716
+ # NONEDITIONABLE, not "noeditionable": Oracle's keyword has the middle N,
717
+ # and missing it dropped every NONEDITIONABLE object into structural —
718
+ # deny by default, and counted by semicolons, so a PL/SQL body read as
719
+ # "more than one statement". Both spellings are accepted here; only the
720
+ # database decides whether the statement is valid.
721
+ r"^create\s+(?:or\s+replace\s+)?(?:(?:non?)?editionable\s+|(?:no)?force\s+)*"
717
722
  r"(procedure|function|package\s+body|package|trigger|view|type\s+body|type)\b",
718
723
  re.I | re.S)
719
724
 
@@ -1231,12 +1236,29 @@ def prune_expired_grants(root, now=None):
1231
1236
  return gone
1232
1237
 
1233
1238
 
1234
- def render_restore(obj_type, name, before_text):
1239
+ EDITIONABLE_KW_RE = re.compile(
1240
+ r"^create\s+(?:or\s+replace\s+)?((?:non?)?editionable)\b", re.I)
1241
+
1242
+
1243
+ def create_prefix(after_text):
1244
+ """The CREATE header ALL_SOURCE does not store, rebuilt for the version
1245
+ held in the database. The editionable keyword is read off the file being
1246
+ applied, because the database's own answer is not in ALL_SOURCE and
1247
+ Oracle refuses to *change* the property through CREATE OR REPLACE
1248
+ (ORA-38824) — so a file that applies cleanly already spells the property
1249
+ the object has. Getting this wrong costs twice: a restore that fails
1250
+ exactly when it is needed, and a phantom line in the diff the developer
1251
+ approves."""
1252
+ m = EDITIONABLE_KW_RE.match(skip_leading_noise(after_text))
1253
+ return "CREATE OR REPLACE " + (f"{m.group(1).upper()} " if m else "")
1254
+
1255
+
1256
+ def render_restore(obj_type, name, before_text, after_text=""):
1235
1257
  """The statement that puts things back. For an object that did not exist,
1236
1258
  undo means DROP — a genuinely different promise than restoring source, so
1237
1259
  the caller records created=True and the report says it plainly."""
1238
1260
  if before_text.strip():
1239
- return "CREATE OR REPLACE " + before_text.rstrip() + "\n"
1261
+ return create_prefix(after_text) + before_text.rstrip() + "\n"
1240
1262
  return f"DROP {obj_type} {name}\n"
1241
1263
 
1242
1264
 
@@ -1256,7 +1278,7 @@ def write_journal_entry(root, obj_type, name, before, after, meta, now=None):
1256
1278
  d.mkdir(parents=True)
1257
1279
  (d / "before.sql").write_text(before, encoding="utf-8")
1258
1280
  (d / "after.sql").write_text(after, encoding="utf-8")
1259
- (d / "restore.sql").write_text(render_restore(obj_type, name, before),
1281
+ (d / "restore.sql").write_text(render_restore(obj_type, name, before, after),
1260
1282
  encoding="utf-8")
1261
1283
  full = {"object": name, "type": obj_type, "created": not before.strip(),
1262
1284
  "entry": eid, **meta}
@@ -2105,8 +2127,10 @@ def run_apply(conn, schema, ns, file_text, origin=None):
2105
2127
 
2106
2128
  # 3. PREVIEW — diff like against like: ALL_SOURCE never stores the
2107
2129
  # CREATE OR REPLACE header, so prepend it before comparing, or an
2108
- # unchanged object would show a phantom two-line change forever.
2109
- base = ("CREATE OR REPLACE " + db_source) if db_source.strip() else ""
2130
+ # unchanged object would show a phantom two-line change forever. The
2131
+ # editionable keyword is part of that header, or a NONEDITIONABLE file
2132
+ # shows its own first line as a change that is not one.
2133
+ base = (create_prefix(stmt) + db_source) if db_source.strip() else ""
2110
2134
  diff_text, changed = render_diff(base, stmt)
2111
2135
  warn = privilege_warning(conn, schema, ns.conn_user)
2112
2136
  style = (naming_violation(otype, name, load_conventions(ns.project_root))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythia-plsql
3
- Version: 0.11.0
3
+ Version: 0.11.1
4
4
  Summary: PL/SQL development for AI agents on Oracle Database - expert data-dictionary queries, impact analysis, and a snapshot-verified write path with honest rollback.
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/thaildhe172591/pythia
@@ -32,6 +32,11 @@ def test_classify_groups():
32
32
  assert c("alter table t_order add (x number)") == "structural" # session tested first
33
33
  assert c("CREATE OR REPLACE PROCEDURE p AS BEGIN NULL; END;") == "plsql_source"
34
34
  assert c("create or replace editionable package body pkg_order as end;") == "plsql_source"
35
+ # Oracle's keyword is NONEDITIONABLE, with the middle N. Missing it sent
36
+ # every such object to structural — deny by default, and counted by
37
+ # semicolons, so a PL/SQL body came back as "more than one statement".
38
+ assert c("create or replace NONEDITIONABLE procedure p as begin null; end;") == "plsql_source"
39
+ assert c("CREATE OR REPLACE NONEDITIONABLE PACKAGE BODY pkg AS END;") == "plsql_source"
35
40
  assert c("CREATE OR REPLACE FORCE VIEW v AS SELECT 1 FROM dual") == "plsql_source"
36
41
  assert c("CREATE TABLE t (x number)") == "structural" # other CREATE
37
42
  assert c("insert into t values (1)") == "data_dml"
@@ -54,6 +59,27 @@ def test_parse_object():
54
59
  assert (t, n, s) == ("TYPE BODY", "T_THING", None)
55
60
  t, n, s = pythia.parse_object("CREATE OR REPLACE TRIGGER trg_x BEFORE INSERT ON t BEGIN NULL; END;")
56
61
  assert (t, n, s) == ("TRIGGER", "TRG_X", None)
62
+ # the identity drives the snapshot, so the editionable keyword must not
63
+ # shift what is parsed out of the statement
64
+ t, n, s = pythia.parse_object(
65
+ "CREATE OR REPLACE NONEDITIONABLE PROCEDURE core_bh.pbh_file_nh AS BEGIN NULL; END;")
66
+ assert (t, n, s) == ("PROCEDURE", "PBH_FILE_NH", "CORE_BH")
67
+
68
+
69
+ def test_restore_keeps_the_editionable_property():
70
+ """ALL_SOURCE holds no CREATE prefix, so the restore builds one. On an
71
+ editions-enabled schema a bare CREATE OR REPLACE over a NONEDITIONABLE
72
+ object is ORA-38824 — an undo that fails exactly when it is needed."""
73
+ body = "PROCEDURE p AS BEGIN NULL; END;"
74
+ assert pythia.render_restore("PROCEDURE", "P", body, "CREATE OR REPLACE " + body) \
75
+ == "CREATE OR REPLACE " + body + "\n"
76
+ assert pythia.render_restore(
77
+ "PROCEDURE", "P", body,
78
+ "create or replace noneditionable procedure p as begin null; end;") \
79
+ == "CREATE OR REPLACE NONEDITIONABLE " + body + "\n"
80
+ # a new object still has no source to put back: undo is a DROP
81
+ assert pythia.render_restore("PROCEDURE", "P", "", "CREATE OR REPLACE NONEDITIONABLE PROCEDURE p") \
82
+ == "DROP PROCEDURE P\n"
57
83
 
58
84
 
59
85
  def test_prepare_statement_terminators():
@@ -1475,6 +1501,38 @@ def test_apply_reads_a_bom_file_as_the_statement_it_is():
1475
1501
  assert "approve --card" in buf.getvalue() # it previewed
1476
1502
 
1477
1503
 
1504
+ def test_apply_previews_a_noneditionable_object_end_to_end():
1505
+ """The reported bug, from the outside: NONEDITIONABLE missed the
1506
+ classifier, fell through to structural — which counts statements by
1507
+ semicolon — and a PL/SQL body came back as 'more than one statement'.
1508
+ The only escape was dropping the keyword, which Oracle then met with
1509
+ ORA-38824. Preview must produce a token, and the restore must keep the
1510
+ property."""
1511
+ import contextlib
1512
+ import io
1513
+ import pathlib
1514
+ src = ("CREATE OR REPLACE NONEDITIONABLE PACKAGE BODY pkg_order AS\n"
1515
+ " new line;\nEND;\n/\n")
1516
+ with tempfile.TemporaryDirectory() as td:
1517
+ f = pathlib.Path(td) / "f.sql"
1518
+ f.write_text(src, encoding="utf-8")
1519
+ buf = io.StringIO()
1520
+ with contextlib.redirect_stdout(buf):
1521
+ pythia.cmd_apply(FakeConn(base_script()), "APP",
1522
+ apply_ns(td, file=str(f)))
1523
+ out = buf.getvalue()
1524
+ assert "more than one statement" not in out
1525
+ assert "approve --card" in out # it previewed
1526
+ entry = pythia.list_journal_entries(td)[0]
1527
+ restore = (pythia.journal_root(td) / entry / "restore.sql").read_text(
1528
+ encoding="utf-8")
1529
+ assert restore.startswith("CREATE OR REPLACE NONEDITIONABLE ")
1530
+ # and the keyword is not shown as a change it is not: ALL_SOURCE holds
1531
+ # no header, so the diff's base has to carry the same one
1532
+ assert "-CREATE OR REPLACE" not in out and "+CREATE OR REPLACE" not in out
1533
+ assert "2 lines changed" in out # the body line, not the header
1534
+
1535
+
1478
1536
  def test_apply_refuses_when_the_session_schema_is_not_the_configured_one():
1479
1537
  """A proxy into another user, or a stale `schema` in connections.json:
1480
1538
  an unqualified CREATE would land in one schema while pythia snapshots
File without changes
File without changes
File without changes