getcodexy 2.3.0__tar.gz → 2.4.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 (98) hide show
  1. {getcodexy-2.3.0 → getcodexy-2.4.1}/PKG-INFO +1 -1
  2. {getcodexy-2.3.0 → getcodexy-2.4.1}/pyproject.toml +1 -1
  3. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/_version_data/uv.lock +1 -1
  4. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component-manifest.json +8 -8
  5. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_core_hooks.py +18 -2
  6. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_hook_registration.py +16 -2
  7. getcodexy-2.4.1/src/codexy_runtime_tools/component_host_mutations.py +31 -0
  8. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_lifecycle_admission.py +44 -1
  9. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_lifecycle_operation.py +28 -41
  10. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_lifecycle_preflight.py +18 -1
  11. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_lifecycle_recovery.py +29 -29
  12. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_transaction_state.py +3 -0
  13. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/local_marketplace.py +16 -0
  14. getcodexy-2.4.1/src/codexy_runtime_tools/local_release_bundle.py +151 -0
  15. getcodexy-2.4.1/src/codexy_runtime_tools/local_upgrade.py +214 -0
  16. getcodexy-2.4.1/src/codexy_runtime_tools/local_upgrade_host.py +93 -0
  17. getcodexy-2.4.1/src/codexy_runtime_tools/local_upgrade_state.py +149 -0
  18. getcodexy-2.4.1/src/codexy_runtime_tools/public_marketplace_bundle.py +162 -0
  19. {getcodexy-2.3.0 → getcodexy-2.4.1}/uv.lock +1 -1
  20. {getcodexy-2.3.0 → getcodexy-2.4.1}/README.md +0 -0
  21. {getcodexy-2.3.0 → getcodexy-2.4.1}/build_backend.py +0 -0
  22. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/__init__.py +0 -0
  23. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/activation_transaction.py +0 -0
  24. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/cache.py +0 -0
  25. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_capability_observation.py +0 -0
  26. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_capability_probe.py +0 -0
  27. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_capability_probe_process.py +0 -0
  28. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_cli.py +0 -0
  29. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_health.py +0 -0
  30. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_health_support.py +0 -0
  31. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_hook_activation.py +0 -0
  32. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_hook_activation_expected.py +0 -0
  33. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_hook_activation_host.py +0 -0
  34. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_hook_activation_validation.py +0 -0
  35. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_inspection.py +0 -0
  36. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_inspection_host.py +0 -0
  37. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_inspection_types.py +0 -0
  38. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_integrity.py +0 -0
  39. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_interactive_probe.py +0 -0
  40. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_inventory_classification.py +0 -0
  41. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_inventory_records.py +0 -0
  42. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_lifecycle.py +0 -0
  43. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_lifecycle_finish.py +0 -0
  44. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_lifecycle_interlock.py +0 -0
  45. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_lifecycle_mcp.py +0 -0
  46. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_lifecycle_support.py +0 -0
  47. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_lifecycle_terminal.py +0 -0
  48. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_manifest.py +0 -0
  49. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_manifest_dependencies.py +0 -0
  50. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_manifest_values.py +0 -0
  51. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_mcp_cache.py +0 -0
  52. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_mcp_capability.py +0 -0
  53. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_mcp_materialization.py +0 -0
  54. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_mcp_probe.py +0 -0
  55. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_observed_inventory.py +0 -0
  56. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_registration_catalog.py +0 -0
  57. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_registration_files.py +0 -0
  58. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_registration_health.py +0 -0
  59. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_registration_lifecycle.py +0 -0
  60. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_registration_orphans.py +0 -0
  61. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_registration_projection.py +0 -0
  62. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_registration_snapshot.py +0 -0
  63. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_resolver.py +0 -0
  64. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_transaction_durability.py +0 -0
  65. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_transaction_identity.py +0 -0
  66. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_transaction_receipts.py +0 -0
  67. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_transaction_snapshot.py +0 -0
  68. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_transition_journal.py +0 -0
  69. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_transition_model.py +0 -0
  70. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_transition_receipt.py +0 -0
  71. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/component_transition_rejections.py +0 -0
  72. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/contract.py +0 -0
  73. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/github_checks.py +0 -0
  74. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/github_pre_session.py +0 -0
  75. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/identity.py +0 -0
  76. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/installer.py +0 -0
  77. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/marketplace_identity.py +0 -0
  78. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/marketplace_repin.py +0 -0
  79. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/mcp_bootstrap.py +0 -0
  80. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/monolith_baseline.py +0 -0
  81. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/monolith_classifier.py +0 -0
  82. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/monolith_migration.py +0 -0
  83. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/monolith_migration_host.py +0 -0
  84. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/monolith_migration_plan.py +0 -0
  85. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/monolith_migration_state.py +0 -0
  86. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/package.py +0 -0
  87. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/package_archive.py +0 -0
  88. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/plugin_resolution.py +0 -0
  89. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/pre_session.py +0 -0
  90. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/release_contract_validation.py +0 -0
  91. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/release_provenance.py +0 -0
  92. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/release_watcher_contract.py +0 -0
  93. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/runtime.py +0 -0
  94. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/runtime_configuration.py +0 -0
  95. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/source.py +0 -0
  96. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/title_policy.py +0 -0
  97. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/updater.py +0 -0
  98. {getcodexy-2.3.0 → getcodexy-2.4.1}/src/codexy_runtime_tools/version_lock.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: getcodexy
3
- Version: 2.3.0
3
+ Version: 2.4.1
4
4
  Summary: A Codex harness for coordinating agents through planning, implementation, verification, and review.
5
5
  Author: Eunsoo Lee
6
6
  License-Expression: MIT
@@ -5,7 +5,7 @@ backend-path = ["."]
5
5
 
6
6
  [project]
7
7
  name = "getcodexy"
8
- version = "2.3.0"
8
+ version = "2.4.1"
9
9
  description = "A Codex harness for coordinating agents through planning, implementation, verification, and review."
10
10
  readme = { file = "README.md", content-type = "text/markdown" }
11
11
  requires-python = ">=3.10"
@@ -4,5 +4,5 @@ requires-python = ">=3.10"
4
4
 
5
5
  [[package]]
6
6
  name = "getcodexy"
7
- version = "2.3.0"
7
+ version = "2.4.1"
8
8
  source = { editable = "." }
@@ -29,7 +29,7 @@
29
29
  {
30
30
  "id": "core",
31
31
  "plugin": "codexy",
32
- "version": "2.3.0",
32
+ "version": "2.4.1",
33
33
  "dependencies": [],
34
34
  "asset": {
35
35
  "pluginId": "codexy@codexy",
@@ -71,7 +71,7 @@
71
71
  {
72
72
  "id": "github",
73
73
  "plugin": "codexy-github",
74
- "version": "2.3.0",
74
+ "version": "2.4.1",
75
75
  "dependencies": [
76
76
  "core"
77
77
  ],
@@ -87,7 +87,7 @@
87
87
  {
88
88
  "id": "devtools",
89
89
  "plugin": "codexy-devtools",
90
- "version": "2.3.0",
90
+ "version": "2.4.1",
91
91
  "dependencies": [
92
92
  "core"
93
93
  ],
@@ -105,27 +105,27 @@
105
105
  "compatibleCombinations": [
106
106
  {
107
107
  "components": [],
108
- "version": "2.3.0"
108
+ "version": "2.4.1"
109
109
  },
110
110
  {
111
111
  "components": [
112
112
  "core"
113
113
  ],
114
- "version": "2.3.0"
114
+ "version": "2.4.1"
115
115
  },
116
116
  {
117
117
  "components": [
118
118
  "core",
119
119
  "github"
120
120
  ],
121
- "version": "2.3.0"
121
+ "version": "2.4.1"
122
122
  },
123
123
  {
124
124
  "components": [
125
125
  "core",
126
126
  "devtools"
127
127
  ],
128
- "version": "2.3.0"
128
+ "version": "2.4.1"
129
129
  },
130
130
  {
131
131
  "components": [
@@ -133,7 +133,7 @@
133
133
  "github",
134
134
  "devtools"
135
135
  ],
136
- "version": "2.3.0"
136
+ "version": "2.4.1"
137
137
  }
138
138
  ]
139
139
  }
@@ -6,7 +6,7 @@ COMMAND_HOOKS = (
6
6
  (_TOOL_PREFIX + "send_message_to_thread$", "codexy-thread-delivery"),
7
7
  (_TOOL_PREFIX + "create_thread$", "codexy-child-thread-creation"),
8
8
  (
9
- r"^(?:(?:agents|multi_agent_v1)__)?(?:spawn_agent|send_message|followup_task)$",
9
+ r"^(?:(?:agents|multi_agent_v1)__|agents|collaboration|multi_agent_v1)?(?:spawn_agent|send_message|followup_task|send_input)$",
10
10
  "codexy-subagent-ownership",
11
11
  ),
12
12
  )
@@ -15,13 +15,20 @@ LAUNCHERS = tuple(
15
15
  f"hooks/{stem}.{extension}"
16
16
  for _, stem in COMMAND_HOOKS
17
17
  for extension in ("sh", "cmd")
18
- ) + ("hooks/codexy-cleanup-progress.sh", "hooks/codexy-cleanup-progress.cmd")
18
+ ) + (
19
+ "hooks/codexy-cleanup-progress.sh",
20
+ "hooks/codexy-cleanup-progress.cmd",
21
+ "hooks/codexy-supervision-capacity.sh",
22
+ "hooks/codexy-supervision-capacity.cmd",
23
+ )
19
24
  # Windows invokes the event script with `py.exe -3 -I -B`, bypassing the POSIX
20
25
  # resolver; keep the entrypoint and sibling event helper in this required set.
21
26
  DEPENDENCIES = (
22
27
  "hooks/codexy-hook-runtime.sh",
23
28
  "hooks/codexy-thread-delivery.py",
24
29
  "hooks/codexy_policy/thread_delivery.py",
30
+ "hooks/codexy_policy/recipient_store.py",
31
+ "hooks/codexy_policy/recipient_initialization.py",
25
32
  "hooks/codexy-child-thread-creation.py",
26
33
  "hooks/codexy_policy/child_thread_creation.py",
27
34
  # The admission module imports this helper when constructing denial feedback.
@@ -37,4 +44,13 @@ DEPENDENCIES = (
37
44
  "hooks/codexy_policy/windows_timing.py",
38
45
  "hooks/codexy_cleanup_progress.py",
39
46
  "hooks/codexy_policy/cleanup_progress.py",
47
+ "hooks/codexy_supervision_capacity.py",
48
+ "hooks/codexy_supervision_prepare.py",
49
+ "hooks/codexy_supervision_owner.py",
50
+ "hooks/codexy_policy/supervision_reservations.py",
51
+ "hooks/codexy_policy/supervision_dispatch.py",
52
+ "hooks/codexy_policy/supervision_observation.py",
53
+ "hooks/codexy_policy/supervision_storage.py",
54
+ "hooks/codexy_policy/supervision_resume.py",
55
+ "hooks/codexy_policy/supervision_reconciliation.py",
40
56
  )
@@ -85,8 +85,22 @@ def _core_hooks() -> dict[str, object]:
85
85
  return {
86
86
  "hooks": {
87
87
  "PermissionRequest": command("PermissionRequest"),
88
- "PreToolUse": command("PreToolUse"),
89
- "PostToolUse": [post],
88
+ "PreToolUse": command("PreToolUse")
89
+ + [
90
+ _command_hook(
91
+ "^(?:codex_app__|mcp__codex_app__)create_thread$",
92
+ "codexy-supervision-capacity",
93
+ "PreToolUse",
94
+ )
95
+ ],
96
+ "PostToolUse": [
97
+ _command_hook(
98
+ "^(?:codex_app__|mcp__codex_app__)create_thread$",
99
+ "codexy-supervision-capacity",
100
+ "PostToolUse",
101
+ ),
102
+ post,
103
+ ],
90
104
  "Stop": [lifecycle("Stop")],
91
105
  "Interrupt": [lifecycle("Interrupt", 1)],
92
106
  }
@@ -0,0 +1,31 @@
1
+ """Small JSON host mutation adapters shared by lifecycle recovery."""
2
+
3
+ from pathlib import Path
4
+ from .component_lifecycle_preflight import Runner
5
+ from .component_manifest import ComponentManifest
6
+ from .pre_session import _json
7
+
8
+
9
+ def mutate(
10
+ executable: Path,
11
+ invoke: Runner,
12
+ action: str,
13
+ manifest: ComponentManifest,
14
+ component_id: str,
15
+ ) -> None:
16
+ _json(
17
+ invoke(
18
+ [
19
+ str(executable),
20
+ "plugin",
21
+ action,
22
+ manifest.component(component_id).asset.plugin_id,
23
+ "--json",
24
+ ]
25
+ ),
26
+ f"plugin {action}",
27
+ )
28
+
29
+
30
+ def list_installed(executable: Path, invoke: Runner) -> object:
31
+ return _json(invoke([str(executable), "plugin", "list", "--json"]), "plugin list")
@@ -23,7 +23,11 @@ def admitted_selection(
23
23
  command: str,
24
24
  ) -> tuple[str, ...]:
25
25
  """Resolve the operation selection before any lifecycle mutation begins."""
26
- return admit_operation_inventory(manifest, inventory, marketplace_root, command)
26
+ selected = admit_operation_inventory(manifest, inventory, marketplace_root, command)
27
+ from .local_upgrade import validate_inventory_version
28
+
29
+ validate_inventory_version(manifest, inventory, marketplace_root)
30
+ return selected
27
31
 
28
32
 
29
33
  def admitted_recovery_selection(
@@ -123,3 +127,42 @@ def _validate_receipt(manifest: ComponentManifest, receipt: dict[str, object]) -
123
127
  if str(error).startswith("operation receipt"):
124
128
  raise
125
129
  raise ValueError(f"operation receipt {error}") from error
130
+
131
+
132
+ def admit_request(
133
+ home: Path,
134
+ manifest: ComponentManifest,
135
+ identifier: str,
136
+ command: str,
137
+ requested: tuple[str, ...],
138
+ ):
139
+ from .component_lifecycle_preflight import validate_request, recorded_selection
140
+ from .component_lifecycle_terminal import reject
141
+ from .component_resolver import ComponentResolutionError
142
+ from .component_transition_model import RejectionStage, StateFailure
143
+
144
+ try:
145
+ validate_request(command, requested, manifest)
146
+ return recorded_selection(home, manifest), None
147
+ except ComponentResolutionError as error:
148
+ return None, reject(
149
+ home,
150
+ manifest,
151
+ identifier,
152
+ command,
153
+ requested,
154
+ (),
155
+ RejectionStage.REQUEST,
156
+ error,
157
+ )
158
+ except (OSError, ValueError, RuntimeError):
159
+ return None, reject(
160
+ home,
161
+ manifest,
162
+ identifier,
163
+ command,
164
+ requested,
165
+ (),
166
+ RejectionStage.PRESTATE,
167
+ StateFailure.INCONSISTENT_INSTALLED_STATE,
168
+ )
@@ -2,24 +2,22 @@ from __future__ import annotations
2
2
 
3
3
  import os
4
4
  from contextlib import nullcontext
5
- from functools import partial
6
5
  from pathlib import Path
7
6
 
8
7
  from .component_lifecycle_admission import (
9
- admit_pending_receipt,
10
8
  admitted_bootstrap_recovery_selection,
11
9
  admitted_recovery_selection,
12
10
  admitted_selection,
11
+ admit_request,
13
12
  replay_receipt,
14
13
  )
15
14
  from .component_hook_activation import HookLister
16
15
  from .component_lifecycle_interlock import migration_rejection
17
16
  from .component_manifest import ComponentManifest, load_component_manifest
17
+ from .local_upgrade import pending_state, refresh as refresh_local
18
18
  from .component_lifecycle_preflight import (
19
19
  existing_marketplace,
20
20
  recorded_selection,
21
- refresh_operation_root as _refresh,
22
- validate_request,
23
21
  )
24
22
  from .component_lifecycle_recovery import (
25
23
  apply_forward as _apply_forward,
@@ -41,9 +39,7 @@ from .component_transaction_state import (
41
39
  Journal,
42
40
  PreAdmissionError,
43
41
  clear_journal,
44
- decode_inventory,
45
42
  inventory_path,
46
- read_journal,
47
43
  transaction_lock,
48
44
  write_inventory,
49
45
  write_journal,
@@ -86,42 +82,22 @@ def run_operation(
86
82
  home, manifest, identifier, command, requested, lock_held
87
83
  ):
88
84
  return rejection
89
- pending = read_journal(home)
90
- if pending is not None:
91
- pending.validate(manifest, decode_inventory)
92
- pending_receipt = admit_pending_receipt(home, manifest, pending)
93
- else:
94
- pending_receipt = None
85
+ pending, pending_receipt = pending_state(home, executable, invoke, manifest)
95
86
  replay = replay_receipt(home, manifest, identifier, command, requested)
96
87
  if replay is not None and pending is None:
97
88
  return replay
89
+ recorded, rejection = admit_request(
90
+ home, manifest, identifier, command, requested
91
+ )
92
+ if rejection is not None:
93
+ return rejection
98
94
  try:
99
- validate_request(command, requested, manifest)
100
- recorded = recorded_selection(home, manifest)
101
- except ComponentResolutionError as error:
102
- return _reject(
103
- home,
104
- manifest,
105
- identifier,
106
- command,
107
- requested,
108
- (),
109
- RejectionStage.REQUEST,
110
- error,
111
- )
112
- except (OSError, ValueError, RuntimeError):
113
- return _reject(
114
- home,
95
+ root = existing_marketplace(
96
+ executable,
97
+ invoke,
115
98
  manifest,
116
- identifier,
117
- command,
118
- requested,
119
- (),
120
- RejectionStage.PRESTATE,
121
- StateFailure.INCONSISTENT_INSTALLED_STATE,
99
+ allow_older_local=command in {"update", "bootstrap"},
122
100
  )
123
- try:
124
- root = existing_marketplace(executable, invoke, manifest)
125
101
  inventory = _list(executable, invoke)
126
102
  if (
127
103
  pending is not None
@@ -181,7 +157,12 @@ def run_operation(
181
157
  _recover_if_needed(
182
158
  home, executable, invoke, manifest, root, hook_lister
183
159
  )
184
- root = existing_marketplace(executable, invoke, manifest)
160
+ root = existing_marketplace(
161
+ executable,
162
+ invoke,
163
+ manifest,
164
+ allow_older_local=command in {"update", "bootstrap"},
165
+ )
185
166
  inventory = _list(executable, invoke)
186
167
  before = admitted_selection(manifest, inventory, root, command)
187
168
  recorded = recorded_selection(home, manifest)
@@ -228,16 +209,22 @@ def run_operation(
228
209
  write_journal(home, journal) # Save the before-state before package changes.
229
210
  try:
230
211
  root = root or official_marketplace_root(executable, invoke)
231
- forward = partial(_apply_forward, home=home)
232
- installed, root = forward(
233
- executable, invoke, manifest, root, journal, plan.adds, plan.removes
212
+ installed, root = _apply_forward(
213
+ executable,
214
+ invoke,
215
+ manifest,
216
+ root,
217
+ journal,
218
+ plan.adds,
219
+ plan.removes,
220
+ home,
234
221
  )
235
222
  except BaseException as error:
236
223
  if root is None:
237
224
  raise RuntimeError(
238
225
  "component operation failed; durable recovery is required"
239
226
  ) from error
240
- root = _refresh(executable, invoke, manifest, root, home, journal.command)
227
+ root = refresh_local(home, executable, invoke, manifest, root, journal)
241
228
  _rollback_or_raise(home, executable, invoke, manifest, root, journal, error)
242
229
  receipt = _terminal(
243
230
  home, manifest, journal.receipt("rolled-back", journal.before)
@@ -41,6 +41,8 @@ def existing_marketplace(
41
41
  executable: Path,
42
42
  invoke: Runner,
43
43
  manifest: ComponentManifest | None = None,
44
+ *,
45
+ allow_older_local: bool = False,
44
46
  ) -> MarketplaceBinding | None:
45
47
  payload = _json(
46
48
  invoke([str(executable), "plugin", "marketplace", "list", "--json"]),
@@ -48,9 +50,24 @@ def existing_marketplace(
48
50
  )
49
51
  binding = marketplace_identity(payload) if named_marketplace(payload) else None
50
52
  if binding is not None and manifest is not None:
53
+ version = manifest.version
54
+ if (
55
+ allow_older_local
56
+ and isinstance(binding, MarketplaceIdentity)
57
+ and binding.source_type == "local"
58
+ ):
59
+ from .local_marketplace import archive_version
60
+
61
+ version = archive_version(
62
+ binding.root, tuple(c.plugin for c in manifest.components)
63
+ )
64
+ if tuple(map(int, version.split("."))) > tuple(
65
+ map(int, manifest.version.split("."))
66
+ ):
67
+ raise ValueError("local marketplace is newer than the installer")
51
68
  validate_local_marketplace(
52
69
  binding,
53
- manifest.version,
70
+ version,
54
71
  tuple(component.plugin for component in manifest.components),
55
72
  )
56
73
  return binding
@@ -10,7 +10,12 @@ from .component_hook_activation import HookLister
10
10
  from .component_lifecycle_finish import finish_committed
11
11
  from .component_lifecycle_mcp import materialize_mcp_caches, materialize_mcp_sources
12
12
  from .component_lifecycle_preflight import existing_marketplace
13
- from .component_lifecycle_preflight import refresh_operation_root as _refresh
13
+ from .local_upgrade import (
14
+ forward as local_forward,
15
+ rollback as local_rollback,
16
+ refresh as local_refresh,
17
+ verify_target,
18
+ )
14
19
  from .component_registration_lifecycle import synchronize_component_registrations
15
20
  from .component_manifest import ComponentManifest
16
21
  from .component_resolver import (
@@ -30,7 +35,8 @@ from .component_transaction_state import (
30
35
  )
31
36
  from .component_lifecycle_terminal import terminal
32
37
  from .marketplace_repin import reconcile_official_marketplace_root
33
- from .pre_session import _json, official_marketplace_root
38
+ from .pre_session import official_marketplace_root
39
+ from .component_host_mutations import mutate, list_installed
34
40
  from .plugin_resolution import MarketplaceBinding, MarketplaceIdentity
35
41
 
36
42
 
@@ -70,7 +76,7 @@ def recover_if_needed(
70
76
  executable, invoke, manifest, root, journal, journal.resolved, (), home
71
77
  )
72
78
  except BaseException as error:
73
- root = _refresh(executable, invoke, manifest, root, home, journal.command)
79
+ root = local_refresh(home, executable, invoke, manifest, root, journal)
74
80
  rollback_or_raise(home, executable, invoke, manifest, root, journal, error)
75
81
  terminal(home, manifest, journal.receipt("rolled-back", journal.before))
76
82
  clear_journal(home)
@@ -122,6 +128,8 @@ def rollback_or_raise(
122
128
  ) -> None:
123
129
  try:
124
130
  write_journal(home, journal.with_phase("rolling-back")) # Record phase first.
131
+ if local_rollback(home, executable, invoke, manifest, root, journal):
132
+ return
125
133
  restore_selection(home, executable, invoke, manifest, root, journal.before)
126
134
  installed = list_installed(executable, invoke)
127
135
  if reconcile_installed_inventory(manifest, installed, root) != journal.before:
@@ -150,7 +158,9 @@ def write_completed(
150
158
  hook_lister: HookLister | None = None,
151
159
  ) -> dict[str, object]:
152
160
  try:
161
+ verify_target(home, journal, manifest)
153
162
  synchronize_component_registrations(home, root, journal)
163
+ verify_target(home, journal, manifest)
154
164
  except BaseException as error:
155
165
  rollback_or_raise(home, executable, invoke, manifest, root, journal, error)
156
166
  receipt = terminal(
@@ -206,8 +216,19 @@ def apply_forward(
206
216
  ) -> tuple[tuple[str, ...], MarketplaceBinding]:
207
217
  if journal.command in {"update", "bootstrap"}:
208
218
  if isinstance(root, MarketplaceIdentity) and root.source_type == "local":
209
- if existing_marketplace(executable, invoke, manifest) != root:
219
+ if (
220
+ existing_marketplace(
221
+ executable, invoke, manifest, allow_older_local=True
222
+ )
223
+ != root
224
+ ):
210
225
  raise ValueError("local Codexy marketplace identity changed")
226
+ previous = root
227
+ root = local_forward(home, executable, invoke, manifest, root, journal)
228
+ if root != previous:
229
+ adds = (
230
+ journal.target
231
+ ) # A marketplace version is atomic across its selected plugins.
211
232
  else:
212
233
  root = reconcile_official_marketplace_root(
213
234
  executable,
@@ -215,36 +236,15 @@ def apply_forward(
215
236
  manifest.version,
216
237
  home,
217
238
  )
239
+ verify_target(home, journal, manifest)
218
240
  materialize_mcp_sources(root, manifest, journal.target)
219
241
  for component in adds:
242
+ verify_target(home, journal, manifest)
220
243
  mutate(executable, invoke, "add", manifest, component)
221
244
  for component in removes:
245
+ verify_target(home, journal, manifest)
222
246
  mutate(executable, invoke, "remove", manifest, component)
223
247
  installed = list_installed(executable, invoke)
248
+ verify_target(home, journal, manifest)
224
249
  materialize_mcp_caches(home, root, manifest, journal.target)
225
250
  return _verify(manifest, installed, journal.target, root), root
226
-
227
-
228
- def mutate(
229
- executable: Path,
230
- invoke: Runner,
231
- action: str,
232
- manifest: ComponentManifest,
233
- component_id: str,
234
- ) -> None:
235
- _json(
236
- invoke(
237
- [
238
- str(executable),
239
- "plugin",
240
- action,
241
- manifest.component(component_id).asset.plugin_id,
242
- "--json",
243
- ]
244
- ),
245
- f"plugin {action}",
246
- )
247
-
248
-
249
- def list_installed(executable: Path, invoke: Runner) -> object:
250
- return _json(invoke([str(executable), "plugin", "list", "--json"]), "plugin list")
@@ -146,6 +146,9 @@ def write_journal(home: Path, journal: Journal) -> None:
146
146
 
147
147
 
148
148
  def clear_journal(home: Path) -> None:
149
+ from .local_upgrade_state import clear
150
+
151
+ clear(home)
149
152
  _unlink_regular(_journal_path(home))
150
153
 
151
154
 
@@ -77,3 +77,19 @@ def _unique_object(pairs: list[tuple[str, object]]) -> dict[str, object]:
77
77
  raise ValueError("local Codexy marketplace provenance has duplicate keys")
78
78
  result[key] = value
79
79
  return result
80
+
81
+
82
+ def archive_version(root: Path, plugin_names: tuple[str, ...]) -> str:
83
+ """Require one canonical version across all independently matching packages."""
84
+ from .component_manifest import valid_semver
85
+
86
+ validate_local_archive(root, plugin_names=plugin_names)
87
+ data = json.loads(
88
+ (root / ".agents/plugins/marketplace.json").read_text(),
89
+ object_pairs_hook=_unique_object,
90
+ )
91
+ versions = {entry["version"] for entry in data["plugins"]}
92
+ if len(versions) != 1 or not valid_semver(version := next(iter(versions))):
93
+ raise ValueError("local Codexy marketplace has mixed or invalid versions")
94
+ validate_local_archive(root, version, plugin_names)
95
+ return version