pactkit-codex 5.0.0__tar.gz → 5.0.3__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 (18) hide show
  1. {pactkit_codex-5.0.0/src/pactkit_codex.egg-info → pactkit_codex-5.0.3}/PKG-INFO +2 -2
  2. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/pyproject.toml +6 -6
  3. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/src/pactkit_codex/deployer.py +136 -28
  4. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3/src/pactkit_codex.egg-info}/PKG-INFO +2 -2
  5. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/src/pactkit_codex.egg-info/requires.txt +1 -1
  6. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/LICENSE +0 -0
  7. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/README.md +0 -0
  8. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/setup.cfg +0 -0
  9. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/src/pactkit_codex/__init__.py +0 -0
  10. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/src/pactkit_codex/declarations.py +0 -0
  11. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/src/pactkit_codex/enforcement.py +0 -0
  12. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/src/pactkit_codex.egg-info/SOURCES.txt +0 -0
  13. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/src/pactkit_codex.egg-info/dependency_links.txt +0 -0
  14. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/src/pactkit_codex.egg-info/entry_points.txt +0 -0
  15. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/src/pactkit_codex.egg-info/top_level.txt +0 -0
  16. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/tests/test_capability_contract.py +0 -0
  17. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/tests/test_host_body_snapshot.py +0 -0
  18. {pactkit_codex-5.0.0 → pactkit_codex-5.0.3}/tests/test_profile_contract.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pactkit-codex
3
- Version: 5.0.0
3
+ Version: 5.0.3
4
4
  Summary: PactKit adapter for OpenAI Codex CLI
5
5
  Author: Slim
6
6
  License: MIT
@@ -21,7 +21,7 @@ Classifier: Topic :: Software Development :: Quality Assurance
21
21
  Requires-Python: >=3.10
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
- Requires-Dist: pactkit<5.1.0,>=5.0.0
24
+ Requires-Dist: pactkit<5.1.0,>=5.0.3
25
25
  Requires-Dist: tomli>=1.1.0; python_version < "3.11"
26
26
  Dynamic: license-file
27
27
 
@@ -4,17 +4,17 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pactkit-codex"
7
- version = "5.0.0"
7
+ version = "5.0.3"
8
8
  description = "PactKit adapter for OpenAI Codex CLI"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
11
11
  requires-python = ">=3.10"
12
12
  dependencies = [
13
- # 2026-10-14: the project-level AGENTS.md write goes through
14
- # `pactkit.managed_docs.upsert_managed_block`, which first ships in
15
- # core 4.1.3. The previous floor (>=4.1.0) allowed a released-core
16
- # combination whose deploy raises ImportError.
17
- "pactkit>=5.0.0,<5.1.0",
13
+ # 2026-11-26 (review round4 #4): project integration imports
14
+ # `pactkit.config.resolve_integration_config`, which first ships in core
15
+ # 5.0.2. The previous floor (>=5.0.0) allowed released core 5.0.0/5.0.1,
16
+ # whose deploy raises ImportError. The floor matches the API's first version.
17
+ "pactkit>=5.0.3,<5.1.0",
18
18
  "tomli>=1.1.0; python_version < '3.11'",
19
19
  ]
20
20
 
@@ -179,12 +179,31 @@ class CodexDeployer(DeployerBase):
179
179
 
180
180
  print("🚀 PactKit Codex CLI Deployment")
181
181
 
182
+ # round18 #1: terminate before ANY global write (command Skills, references,
183
+ # post-processing) if a component dir or nested entry escapes into a project.
184
+ if not project_only:
185
+ from pactkit.deploy_shared import assert_global_component_boundary
186
+
187
+ assert_global_component_boundary(codex_root)
188
+
182
189
  from pactkit.config import find_pactkit_yaml
183
190
 
184
- project_yaml = None if global_only else find_pactkit_yaml(project_root)
191
+ if global_only:
192
+ project_yaml = None
193
+ elif project_only:
194
+ # Review A#1: integration is scoped to the target project — never walk
195
+ # up to an outer project's YAML. Imported here (not at module top) so a
196
+ # global-only deploy never needs the integration API (round4 #4).
197
+ from pactkit.config import resolve_integration_config
198
+
199
+ _scoped_cfg, project_yaml = resolve_integration_config(project_root, format="codex")
200
+ if config is None:
201
+ config = _scoped_cfg
202
+ else:
203
+ project_yaml = find_pactkit_yaml(project_root)
185
204
  if config is not None:
186
205
  cfg = config
187
- elif project_yaml is not None:
206
+ elif project_yaml is not None and project_yaml.is_file():
188
207
  auto_added = auto_merge_config_file(project_yaml)
189
208
  for item in auto_added:
190
209
  print(f" -> Auto-added: {item}")
@@ -201,7 +220,7 @@ class CodexDeployer(DeployerBase):
201
220
  # A global-only deployment never touches the project, so the rollback
202
221
  # scope must not include project paths either.
203
222
  transaction_root = project_root if (target is None and not global_only) else None
204
- with rollback_paths(self._transaction_paths(codex_root, transaction_root)):
223
+ with rollback_paths(self._transaction_paths(codex_root, transaction_root, project_only=project_only)):
205
224
  # Project-only integration writes NO machine-global Codex components
206
225
  # (R3): integrating a project must not re-select what other projects
207
226
  # load. Only the default mixed path deploys global components.
@@ -262,8 +281,21 @@ class CodexDeployer(DeployerBase):
262
281
  )
263
282
 
264
283
  @staticmethod
265
- def _transaction_paths(codex_root, project_root=None):
266
- """Return the exact Codex paths a deployment may mutate."""
284
+ def _transaction_paths(codex_root, project_root=None, project_only=False):
285
+ """Return the exact Codex paths a deployment may mutate.
286
+
287
+ Review #2: a project-only integration must NOT include machine-global
288
+ Codex paths in its rollback scope — a failed project write would otherwise
289
+ delete/restore ~/.codex files shared by every other project.
290
+ """
291
+ if project_only:
292
+ if project_root is None:
293
+ return ()
294
+ return (
295
+ project_root / "AGENTS.md",
296
+ project_root / ".codex" / "AGENTS.local.md",
297
+ project_root / ".codex" / "pactkit.yaml",
298
+ )
267
299
  from pactkit.portable_methods import get_portable_methods
268
300
  from pactkit.prompts.skills import get_skill_manifest
269
301
 
@@ -297,10 +329,15 @@ class CodexDeployer(DeployerBase):
297
329
  / "phases" / f"{phase}.md"
298
330
  for phase in ("plan", "act", "check", "done")
299
331
  )
332
+ # round26 #4: the shared preserve writer now generates .pactkit-new
333
+ # candidates for plain skills, command SKILL.md and scripts too — not
334
+ # only references/. Snapshot every candidate path so a failed deploy
335
+ # removes newly-created candidates and restores pre-existing ones;
336
+ # residue would otherwise read as a conflict marker and skew later
337
+ # ownership reads (load_previous_hashes excludes candidate-marked paths).
300
338
  skill_files.extend(
301
339
  path.with_suffix(path.suffix + ".pactkit-new")
302
340
  for path in tuple(skill_files)
303
- if "references" in path.parts
304
341
  )
305
342
  skill_files.extend(
306
343
  codex_root / "skills" / "_rules" / "guides" / filename
@@ -782,16 +819,12 @@ class CodexDeployer(DeployerBase):
782
819
  if (normalized := normalize_rule_id(rule_id)) is not None
783
820
  }
784
821
  codex_root = skills_dir.parent
785
- previous_hashes = {}
786
- deployment_manifest = codex_root / ".pactkit-deployed.json"
787
- if deployment_manifest.is_file():
788
- try:
789
- payload = json.loads(deployment_manifest.read_text(encoding="utf-8"))
790
- files = payload.get("files", {})
791
- if isinstance(files, dict):
792
- previous_hashes = files
793
- except (OSError, ValueError, TypeError):
794
- pass
822
+ # round25 #2 / round24 #1: conflict-aware ownership read (excludes records
823
+ # beside a .pactkit-new candidate) instead of a raw json read, so a stale
824
+ # old-manifest claim cannot authorize overwriting a preserved original.
825
+ from pactkit.deploy_manifest import load_previous_hashes, preserve_or_write
826
+
827
+ previous_hashes = load_previous_hashes(codex_root)
795
828
  # STORY-slim-20260903a24e1ece0d7f: merged ownership view — the deploy
796
829
  # check previously read only .pactkit-deployed.json (which never carries
797
830
  # reference paths), so every content change produced a .pactkit-new
@@ -952,7 +985,13 @@ class CodexDeployer(DeployerBase):
952
985
  for cmd_name, skill_content in rendered.items():
953
986
  skill_path = skills_dir / cmd_name / "SKILL.md"
954
987
  snapshots[skill_path] = skill_path.read_bytes() if skill_path.is_file() else None
955
- atomic_write(skill_path, skill_content)
988
+ # round25 #2: ownership judgment before overwrite (shared writer).
989
+ # A user-edited command SKILL.md is preserved + candidate, not
990
+ # clobbered; the preview classifies this path as preserve-writer.
991
+ skill_written = preserve_or_write(
992
+ codex_root, skill_path, skill_content,
993
+ ownership_proofs, f"command_skill:{cmd_name}",
994
+ )
956
995
  for relative, reference_content in references_by_command[cmd_name].items():
957
996
  reference = skill_path.parent / "references" / relative
958
997
  snapshots[reference] = (
@@ -1004,13 +1043,28 @@ class CodexDeployer(DeployerBase):
1004
1043
  _enforce_deploy_integrity(
1005
1044
  capsule, profile, f"sprint_phase:{phase}",
1006
1045
  )
1007
- atomic_write(reference, capsule)
1008
- record_deployed_reference(
1009
- manifest_references,
1010
- reference.relative_to(codex_root).as_posix(),
1011
- reference,
1046
+ # round26 #2: phase references go through the same shared
1047
+ # ownership writer as the main SKILL.md. A user-edited
1048
+ # phase file is preserved + candidate, not clobbered in the
1049
+ # same update that preserves the main skill. Only a
1050
+ # confirmed write is recorded in the reference ledger.
1051
+ phase_written = preserve_or_write(
1052
+ codex_root, reference, capsule,
1053
+ ownership_proofs, f"sprint_phase:{phase}",
1012
1054
  )
1013
- record_deployed_command(manifest, cmd_name, skill_path)
1055
+ if phase_written:
1056
+ record_deployed_reference(
1057
+ manifest_references,
1058
+ reference.relative_to(codex_root).as_posix(),
1059
+ reference,
1060
+ )
1061
+ # round25 #2: only a confirmed write may claim ownership. A
1062
+ # preserved user original must not be recorded in the command
1063
+ # ledger — that would authorize the next deploy to overwrite it.
1064
+ if skill_written:
1065
+ record_deployed_command(manifest, cmd_name, skill_path)
1066
+ else:
1067
+ manifest.pop(cmd_name, None)
1014
1068
  deployed += 1
1015
1069
  write_command_manifest(skills_dir, manifest, references=manifest_references)
1016
1070
  except Exception:
@@ -1073,6 +1127,17 @@ class CodexDeployer(DeployerBase):
1073
1127
  if project_root.resolve() == Path.home().resolve():
1074
1128
  return
1075
1129
 
1130
+ # Review round4 #1: refuse an escaping .codex/ symlink before the first
1131
+ # write — AGENTS.md, the local copy, backups and the config YAML must stay
1132
+ # inside the project. Same predicate Core uses for the hook channel.
1133
+ from pactkit.deploy_shared import validate_project_write_boundary
1134
+
1135
+ validate_project_write_boundary(
1136
+ project_root,
1137
+ [".codex", "AGENTS.md", ".codex/AGENTS.local.md", ".codex/pactkit.yaml",
1138
+ ".codex/.pactkit-backups"],
1139
+ )
1140
+
1076
1141
  stack = _detect_stack(project_root)
1077
1142
  project_name = project_root.name
1078
1143
  codex_dir = project_root / ".codex"
@@ -1103,6 +1168,32 @@ class CodexDeployer(DeployerBase):
1103
1168
  # a value Core's own validator rejects — see the classification row.
1104
1169
  generate_config_if_missing(format="codex", project_root=project_root)
1105
1170
 
1171
+ def preserve_writer_paths(self, deploy_root, config=None):
1172
+ """round27 #2: the sprint phase capsules go through the shared
1173
+ preserve_or_write writer (deploy_codex_command_skills), so a directory
1174
+ occupying one is preserved and the deploy continues — not a failure.
1175
+ Core's component enumeration does not know these Host-specific reference
1176
+ paths; the preview must take them from this actual write plan."""
1177
+ paths = super().preserve_writer_paths(deploy_root, config)
1178
+ for phase in ("plan", "act", "check", "done"):
1179
+ paths.add(f"skills/project-sprint/references/phases/{phase}.md")
1180
+ return paths
1181
+
1182
+ def ownership_hashes(self, deploy_root):
1183
+ """round28 #2: the same merged ownership view execution uses
1184
+ (deploy_codex_command_skills): the conflict-aware deployment manifest
1185
+ plus the command-manifest reference table. The preview must judge a
1186
+ phase file's overwrite by this merged proof, not the global manifest
1187
+ alone."""
1188
+ from pactkit.deploy_manifest import load_previous_hashes
1189
+ from pactkit.generators.command_ownership import read_command_references
1190
+
1191
+ deploy_root = Path(deploy_root)
1192
+ return {
1193
+ **load_previous_hashes(deploy_root),
1194
+ **read_command_references(deploy_root / "skills"),
1195
+ }
1196
+
1106
1197
  @staticmethod
1107
1198
  def deploy_codex_skills(skills_dir, enabled_skills, profile):
1108
1199
  """Deploy skills with Codex-specific path replacement in scripts."""
@@ -1111,30 +1202,47 @@ class CodexDeployer(DeployerBase):
1111
1202
  # STORY-slim-139 R4: consume the core SKILL_MANIFEST — no local
1112
1203
  # hardcoded skill list (the old 10-item snapshot silently dropped
1113
1204
  # garden/audit/report when core added them).
1205
+ from pactkit.deploy_manifest import load_previous_hashes, preserve_or_write
1206
+ from pactkit.generators.deployer import _mkdir_within
1114
1207
  from pactkit.prompts.skills import get_skill_manifest
1115
1208
 
1116
1209
  enabled_set = set(enabled_skills)
1117
1210
  deployed = 0
1211
+ deploy_root = skills_dir.parent
1212
+ # round25 #2: ownership judgment BEFORE overwrite — the same shared
1213
+ # writer Core/OpenCode use. A user-edited SKILL.md/script is preserved
1214
+ # with a .pactkit-new candidate instead of clobbered by atomic_write,
1215
+ # which also makes the preview's preserve-writer classification truthful.
1216
+ previous_hashes = load_previous_hashes(deploy_root)
1118
1217
 
1119
1218
  for sd in get_skill_manifest():
1120
1219
  if sd["name"] not in enabled_set:
1121
1220
  continue
1122
1221
  skill_dir = skills_dir / sd["name"]
1123
- skill_dir.mkdir(parents=True, exist_ok=True)
1222
+ # round17 #1: terminate on an escaping nested component dir, before
1223
+ # any create/write (a skills/<name>/ symlink into a project).
1224
+ _mkdir_within(deploy_root, skill_dir)
1124
1225
 
1125
1226
  skill_md = render_skill_md(sd, profile, _prefix)
1126
1227
  skill_md = _replace_cli_with_scripts(skill_md)
1127
1228
  skill_md = CodexDeployer.strip_model_references(skill_md)
1128
1229
  _enforce_deploy_integrity(skill_md, profile, f"skill:{sd['name']}")
1129
- atomic_write(skill_dir / "SKILL.md", skill_md)
1230
+ written = preserve_or_write(
1231
+ deploy_root, skill_dir / "SKILL.md", skill_md,
1232
+ previous_hashes, f"skill:{sd['name']}",
1233
+ )
1130
1234
  if sd["script_name"]:
1131
1235
  scripts_dir = skill_dir / "scripts"
1132
- scripts_dir.mkdir(exist_ok=True)
1236
+ _mkdir_within(deploy_root, scripts_dir)
1133
1237
  script_content = sd["script_source"]
1134
1238
  script_content = script_content.replace("~/.claude/", f"{profile.global_config_dir}/")
1135
1239
  script_content = script_content.replace("~/.config/opencode/", f"{profile.global_config_dir}/")
1136
- atomic_write(scripts_dir / sd["script_name"], script_content)
1137
- deployed += 1
1240
+ preserve_or_write(
1241
+ deploy_root, scripts_dir / sd["script_name"], script_content,
1242
+ previous_hashes, f"skill:{sd['name']} script",
1243
+ )
1244
+ if written:
1245
+ deployed += 1
1138
1246
 
1139
1247
  return deployed
1140
1248
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pactkit-codex
3
- Version: 5.0.0
3
+ Version: 5.0.3
4
4
  Summary: PactKit adapter for OpenAI Codex CLI
5
5
  Author: Slim
6
6
  License: MIT
@@ -21,7 +21,7 @@ Classifier: Topic :: Software Development :: Quality Assurance
21
21
  Requires-Python: >=3.10
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
- Requires-Dist: pactkit<5.1.0,>=5.0.0
24
+ Requires-Dist: pactkit<5.1.0,>=5.0.3
25
25
  Requires-Dist: tomli>=1.1.0; python_version < "3.11"
26
26
  Dynamic: license-file
27
27
 
@@ -1,4 +1,4 @@
1
- pactkit<5.1.0,>=5.0.0
1
+ pactkit<5.1.0,>=5.0.3
2
2
 
3
3
  [:python_version < "3.11"]
4
4
  tomli>=1.1.0
File without changes
File without changes
File without changes