devflow-cli 8.3.0__py3-none-any.whl → 8.4.1__py3-none-any.whl
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.
- devflow_cli/__init__.py +1 -1
- devflow_cli/commands/adaptive.py +178 -2
- devflow_cli/core/activity_base.py +16 -4
- devflow_cli/core/adaptive_runner.py +200 -25
- {devflow_cli-8.3.0.dist-info → devflow_cli-8.4.1.dist-info}/METADATA +17 -1
- {devflow_cli-8.3.0.dist-info → devflow_cli-8.4.1.dist-info}/RECORD +9 -9
- {devflow_cli-8.3.0.dist-info → devflow_cli-8.4.1.dist-info}/WHEEL +0 -0
- {devflow_cli-8.3.0.dist-info → devflow_cli-8.4.1.dist-info}/entry_points.txt +0 -0
- {devflow_cli-8.3.0.dist-info → devflow_cli-8.4.1.dist-info}/licenses/LICENSE +0 -0
devflow_cli/__init__.py
CHANGED
devflow_cli/commands/adaptive.py
CHANGED
|
@@ -27,9 +27,11 @@ from devflow_cli.core.adaptive_workflow import (
|
|
|
27
27
|
from devflow_cli.core.assessment import read_assessment
|
|
28
28
|
from devflow_cli.core.activity_base import (
|
|
29
29
|
enter_current_activity,
|
|
30
|
+
feature_path_for,
|
|
30
31
|
files_since_activity_base,
|
|
31
32
|
)
|
|
32
33
|
from devflow_cli.core.activity_contracts import (
|
|
34
|
+
DOCUMENT_ARTIFACTS,
|
|
33
35
|
build_activity_contract,
|
|
34
36
|
NEED_STATEMENT,
|
|
35
37
|
render_contract_prompt,
|
|
@@ -39,6 +41,7 @@ from devflow_cli.core.activity_contracts import (
|
|
|
39
41
|
)
|
|
40
42
|
from devflow_cli.core.adaptive_runner import (
|
|
41
43
|
MANUAL_RECONCILIATION_ACTIVITIES,
|
|
44
|
+
AdaptiveRunOutcome,
|
|
42
45
|
AgentActivityExecution,
|
|
43
46
|
reconcile_current_activity,
|
|
44
47
|
record_human_review,
|
|
@@ -519,6 +522,8 @@ def run_adaptive(
|
|
|
519
522
|
)
|
|
520
523
|
if outcome.reason == "preflight-evidence-stale":
|
|
521
524
|
recovery = _stale_preflight_recovery(current_state)
|
|
525
|
+
if outcome.reason == "artifact-files-mismatch":
|
|
526
|
+
recovery = _artifact_mismatch_recovery(current_state, outcome, agent)
|
|
522
527
|
if json_output:
|
|
523
528
|
_print_execution_json(
|
|
524
529
|
current_state.issueId, outcome.activity, False, outcome.reason,
|
|
@@ -700,6 +705,13 @@ def reconcile_adaptive(
|
|
|
700
705
|
console.print(" Suite : attendez la fin de l'activite en cours, puis relancez.")
|
|
701
706
|
raise typer.Exit(int(exit_code_for_run_reason(outcome.reason)))
|
|
702
707
|
console.print(f" Suite : devflow adaptive status {state.issueId}")
|
|
708
|
+
if outcome.reason == "artifact-files-mismatch":
|
|
709
|
+
console.print(" Reprise guidee :")
|
|
710
|
+
_print_recovery_steps(
|
|
711
|
+
_artifact_mismatch_recovery(
|
|
712
|
+
state, outcome, _attempt_agent(feature_dir, outcome.activity)
|
|
713
|
+
)
|
|
714
|
+
)
|
|
703
715
|
if (
|
|
704
716
|
outcome.reason == "reconcile-refused"
|
|
705
717
|
and activity_attempt_file(feature_dir, outcome.activity).is_file()
|
|
@@ -921,16 +933,45 @@ def discard_attempt_command(
|
|
|
921
933
|
f"Tentative '{entry['activity']}' abandonnee (audit #{entry['sequence']}, "
|
|
922
934
|
f"archive : {entry['archivePath']})."
|
|
923
935
|
)
|
|
924
|
-
|
|
936
|
+
discarded = list(entry["discardedFiles"])
|
|
937
|
+
inputs = (
|
|
938
|
+
[
|
|
939
|
+
path for path in discarded
|
|
940
|
+
if _is_need_input(path, feature_path_for(
|
|
941
|
+
project_root_for_feature(feature_dir), feature_dir
|
|
942
|
+
))
|
|
943
|
+
]
|
|
944
|
+
if entry["activity"] in DOCUMENT_ARTIFACTS
|
|
945
|
+
else []
|
|
946
|
+
)
|
|
947
|
+
others = [path for path in discarded if path not in inputs]
|
|
948
|
+
if inputs:
|
|
949
|
+
warn(
|
|
950
|
+
"Entrees du besoin modifiees depuis le debut de l'activite "
|
|
951
|
+
f"'{entry['activity']}' : " + ", ".join(inputs) + " ; elles ne sont plus "
|
|
952
|
+
"imputees a un agent apres cet abandon et seront acceptees comme amendees "
|
|
953
|
+
"a la relance : a verifier"
|
|
954
|
+
)
|
|
955
|
+
if others:
|
|
925
956
|
warn(
|
|
926
957
|
"Fichiers modifies depuis le debut de l'activite "
|
|
927
958
|
f"'{entry['activity']}', comptes dans le lot a la relance ; remise en "
|
|
928
|
-
"etat a la charge du superviseur : " + ", ".join(
|
|
959
|
+
"etat a la charge du superviseur : " + ", ".join(others)
|
|
929
960
|
)
|
|
930
961
|
if entry.get("observationError"):
|
|
931
962
|
warn(f"Fichiers depuis la base non calcules : {entry['observationError']}")
|
|
932
963
|
|
|
933
964
|
|
|
965
|
+
def _is_need_input(path: str, feature_path: str | None) -> bool:
|
|
966
|
+
"""Vrai pour need.md ou issue-*.md directement sous le dossier de la feature."""
|
|
967
|
+
if feature_path is None:
|
|
968
|
+
return False
|
|
969
|
+
parent, _, name = path.rpartition("/")
|
|
970
|
+
return parent == feature_path and (
|
|
971
|
+
name == NEED_STATEMENT or (name.startswith("issue-") and name.endswith(".md"))
|
|
972
|
+
)
|
|
973
|
+
|
|
974
|
+
|
|
934
975
|
def _execute_local_verification(
|
|
935
976
|
feature_dir: Path, project_root: Path, issue_id: str, *,
|
|
936
977
|
refresh: bool = False, json_output: bool = False,
|
|
@@ -1557,9 +1598,126 @@ def _stale_preflight_recovery(state: AdaptiveWorkflowState) -> dict:
|
|
|
1557
1598
|
}
|
|
1558
1599
|
|
|
1559
1600
|
|
|
1601
|
+
ARTIFACT_FILE_CAUSES = {
|
|
1602
|
+
"during-agent": "modifie pendant l'agent",
|
|
1603
|
+
"before-launch": "modifie avant le lancement de l'agent",
|
|
1604
|
+
"agent-input": "entree du besoin modifiee par un agent de cette activite",
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
def _artifact_mismatch_recovery(
|
|
1609
|
+
state: AdaptiveWorkflowState, outcome: AdaptiveRunOutcome, agent: str
|
|
1610
|
+
) -> dict:
|
|
1611
|
+
"""Reprise guidee d'un refus d'artefact, par cause observee de chaque fichier en trop."""
|
|
1612
|
+
issue = shlex.quote(state.issueId)
|
|
1613
|
+
files = [
|
|
1614
|
+
{"path": path, "cause": cause, "label": ARTIFACT_FILE_CAUSES[cause]}
|
|
1615
|
+
for path, cause in outcome.extraFiles
|
|
1616
|
+
]
|
|
1617
|
+
causes = {cause for _, cause in outcome.extraFiles}
|
|
1618
|
+
if not files:
|
|
1619
|
+
return {
|
|
1620
|
+
"kind": "artifact-files-mismatch",
|
|
1621
|
+
"summary": (
|
|
1622
|
+
"Artefact attendu absent ou inchange depuis la base, sans fichier en "
|
|
1623
|
+
"trop : l'agent doit l'ecrire."
|
|
1624
|
+
),
|
|
1625
|
+
"files": files,
|
|
1626
|
+
"commands": [{
|
|
1627
|
+
"command": f"devflow adaptive run {issue}"
|
|
1628
|
+
+ (f" --agent {shlex.quote(agent)}" if agent else ""),
|
|
1629
|
+
"purpose": "relancer l'agent pour qu'il ecrive l'artefact",
|
|
1630
|
+
}],
|
|
1631
|
+
}
|
|
1632
|
+
if causes == {"agent-input"}:
|
|
1633
|
+
# Refus avant l'agent : ni reconcile ni reopen ne leve l'imputation.
|
|
1634
|
+
run = f"devflow adaptive run {issue}" + (
|
|
1635
|
+
f" --agent {shlex.quote(agent)}" if agent else ""
|
|
1636
|
+
)
|
|
1637
|
+
return {
|
|
1638
|
+
"kind": "artifact-files-mismatch",
|
|
1639
|
+
"summary": (
|
|
1640
|
+
"Entree du besoin modifiee par un agent de cette activite et pas remise "
|
|
1641
|
+
"en etat : l'agent n'a pas ete lance. Deux sorties : remettre l'entree "
|
|
1642
|
+
"dans son etat de base, ou abandonner la tentative (l'entree modifiee "
|
|
1643
|
+
"est gardee, a verifier)."
|
|
1644
|
+
),
|
|
1645
|
+
"files": files,
|
|
1646
|
+
"commands": [
|
|
1647
|
+
{
|
|
1648
|
+
"command": run,
|
|
1649
|
+
"purpose": "apres remise en etat de l'entree dans son etat de base",
|
|
1650
|
+
},
|
|
1651
|
+
{
|
|
1652
|
+
"command": f"devflow adaptive discard-attempt {issue} --reason MOTIF",
|
|
1653
|
+
"purpose": (
|
|
1654
|
+
"sinon, garder l'entree modifiee : abandon audite de la "
|
|
1655
|
+
"tentative, puis devflow adaptive run"
|
|
1656
|
+
),
|
|
1657
|
+
},
|
|
1658
|
+
],
|
|
1659
|
+
}
|
|
1660
|
+
commands = [{
|
|
1661
|
+
"command": f"devflow adaptive reconcile {issue}",
|
|
1662
|
+
"purpose": (
|
|
1663
|
+
"une fois chaque fichier en trop retire ou remis dans son etat de base : "
|
|
1664
|
+
"valider l'artefact sans relancer l'agent"
|
|
1665
|
+
),
|
|
1666
|
+
}]
|
|
1667
|
+
index = state.activities.index(state.currentActivity)
|
|
1668
|
+
previous = state.activities[index - 1] if index > 0 else ""
|
|
1669
|
+
if (
|
|
1670
|
+
"before-launch" in causes
|
|
1671
|
+
and "agent-input" not in causes
|
|
1672
|
+
and previous not in {"", "assess"}
|
|
1673
|
+
and _reopenable(state, previous)
|
|
1674
|
+
):
|
|
1675
|
+
commands.append({
|
|
1676
|
+
"command": f"devflow adaptive reopen {issue} {previous} --reason MOTIF",
|
|
1677
|
+
"purpose": (
|
|
1678
|
+
"sinon, garder le fichier modifie avant le lancement : rouvrir "
|
|
1679
|
+
"l'activite precedente pour repartir d'une base fraiche"
|
|
1680
|
+
),
|
|
1681
|
+
})
|
|
1682
|
+
if "agent-input" in causes:
|
|
1683
|
+
commands.append({
|
|
1684
|
+
"command": f"devflow adaptive discard-attempt {issue} --reason MOTIF",
|
|
1685
|
+
"purpose": (
|
|
1686
|
+
"sinon, garder l'entree du besoin modifiee par l'agent : abandon "
|
|
1687
|
+
"audite de la tentative, puis devflow adaptive run"
|
|
1688
|
+
),
|
|
1689
|
+
})
|
|
1690
|
+
return {
|
|
1691
|
+
"kind": "artifact-files-mismatch",
|
|
1692
|
+
"summary": (
|
|
1693
|
+
"Fichiers en trop pour une activite documentaire : retirer ceux ecrits "
|
|
1694
|
+
"pendant l'agent, remettre dans leur etat de base ceux modifies avant son "
|
|
1695
|
+
"lancement. Relancer l'agent a l'identique donnerait le meme refus."
|
|
1696
|
+
),
|
|
1697
|
+
"files": files,
|
|
1698
|
+
"commands": commands,
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
|
|
1702
|
+
def _attempt_agent(feature_dir: Path, activity: str) -> str:
|
|
1703
|
+
"""Agent de la fiche de tentative, ou '' si elle est illisible."""
|
|
1704
|
+
try:
|
|
1705
|
+
attempt = json.loads(
|
|
1706
|
+
activity_attempt_file(feature_dir, activity).read_text(encoding="utf-8")
|
|
1707
|
+
)
|
|
1708
|
+
except (OSError, UnicodeDecodeError, json.JSONDecodeError):
|
|
1709
|
+
return ""
|
|
1710
|
+
agent = attempt.get("agent") if isinstance(attempt, dict) else None
|
|
1711
|
+
return agent if isinstance(agent, str) else ""
|
|
1712
|
+
|
|
1713
|
+
|
|
1560
1714
|
def _print_recovery_steps(recovery: dict) -> None:
|
|
1561
1715
|
# soft_wrap : la commande a copier reste sur une seule ligne.
|
|
1562
1716
|
console.print(f" {recovery['summary']}", markup=False, soft_wrap=True)
|
|
1717
|
+
for item in recovery.get("files", []):
|
|
1718
|
+
console.print(
|
|
1719
|
+
f" {item['path']} : {item['label']}", markup=False, soft_wrap=True
|
|
1720
|
+
)
|
|
1563
1721
|
for step in recovery["commands"]:
|
|
1564
1722
|
console.print(
|
|
1565
1723
|
f" {step['command']} # {step['purpose']}", markup=False, soft_wrap=True
|
|
@@ -1599,6 +1757,24 @@ def _print_run_recovery(
|
|
|
1599
1757
|
" Les entrees du besoin ont change pendant l'execution. "
|
|
1600
1758
|
"Verifiez-les avant une nouvelle tentative."
|
|
1601
1759
|
)
|
|
1760
|
+
if activity in DOCUMENT_ARTIFACTS:
|
|
1761
|
+
console.print(
|
|
1762
|
+
" Activite documentaire : la relance reste refusee tant que l'entree "
|
|
1763
|
+
"n'est pas remise dans son etat de base, ou la tentative abandonnee :",
|
|
1764
|
+
markup=False, soft_wrap=True,
|
|
1765
|
+
)
|
|
1766
|
+
issue, agent_arg = shlex.quote(issue_id), shlex.quote(agent)
|
|
1767
|
+
console.print(
|
|
1768
|
+
f" devflow adaptive discard-attempt {issue} --reason MOTIF"
|
|
1769
|
+
" # garder l'entree modifiee : abandon audite",
|
|
1770
|
+
markup=False, soft_wrap=True,
|
|
1771
|
+
)
|
|
1772
|
+
console.print(
|
|
1773
|
+
f" devflow adaptive run {issue} --agent {agent_arg}"
|
|
1774
|
+
" # apres remise en etat de l'entree, ou apres l'abandon",
|
|
1775
|
+
markup=False, soft_wrap=True,
|
|
1776
|
+
)
|
|
1777
|
+
return
|
|
1602
1778
|
console.print(f" devflow adaptive run {issue_id} --agent {agent}")
|
|
1603
1779
|
return
|
|
1604
1780
|
if reason == "agent-running":
|
|
@@ -369,17 +369,29 @@ def declaration_warning(declared: list[str], observed: list[str]) -> str:
|
|
|
369
369
|
|
|
370
370
|
|
|
371
371
|
def recorded_observation(
|
|
372
|
-
observation: ActivityObservation,
|
|
372
|
+
observation: ActivityObservation,
|
|
373
|
+
declared: list[str],
|
|
374
|
+
*,
|
|
375
|
+
exempted: Iterable[str] = (),
|
|
376
|
+
amendment_warning: str = "",
|
|
373
377
|
) -> dict[str, Any]:
|
|
374
|
-
"""Bloc ``observation`` ecrit par la CLI seule dans le resultat enregistre.
|
|
375
|
-
|
|
378
|
+
"""Bloc ``observation`` ecrit par la CLI seule dans le resultat enregistre.
|
|
379
|
+
|
|
380
|
+
``exempted`` : entrees du besoin amendees avant l'agent, hors ecart de
|
|
381
|
+
declaration ; ``amendment_warning`` les nomme dans la cle ``warning``.
|
|
382
|
+
"""
|
|
383
|
+
observed = sorted(set(observation.sinceBase) - set(exempted))
|
|
376
384
|
block: dict[str, Any] = {
|
|
377
385
|
"baseRecordedAt": observation.base.recordedAt,
|
|
378
386
|
"baseHead": observation.base.head,
|
|
379
387
|
"observedAt": observation.observedAt,
|
|
380
388
|
"head": observation.head,
|
|
381
389
|
}
|
|
382
|
-
warning =
|
|
390
|
+
warning = " ; ".join(
|
|
391
|
+
message
|
|
392
|
+
for message in (declaration_warning(declared, observed), amendment_warning)
|
|
393
|
+
if message
|
|
394
|
+
)
|
|
383
395
|
if warning:
|
|
384
396
|
block["declaredChangedFiles"] = list(declared)
|
|
385
397
|
block["warning"] = warning
|
|
@@ -12,7 +12,7 @@ from contextlib import ExitStack
|
|
|
12
12
|
from dataclasses import dataclass, replace
|
|
13
13
|
from datetime import datetime, timezone
|
|
14
14
|
from pathlib import Path
|
|
15
|
-
from typing import Callable
|
|
15
|
+
from typing import Callable, Iterable
|
|
16
16
|
|
|
17
17
|
from devflow_cli.core.activity_contracts import (
|
|
18
18
|
ActivityContract,
|
|
@@ -51,6 +51,7 @@ from devflow_cli.core.automatic_evidence import (
|
|
|
51
51
|
review_worktree_fingerprint,
|
|
52
52
|
)
|
|
53
53
|
from devflow_cli.core.adaptive_workflow import (
|
|
54
|
+
AdaptiveWorkflowState,
|
|
54
55
|
complete_activity,
|
|
55
56
|
read_adaptive_state,
|
|
56
57
|
record_evidence,
|
|
@@ -92,6 +93,8 @@ class AdaptiveRunOutcome:
|
|
|
92
93
|
detail: str = ""
|
|
93
94
|
result: ActivityResult | None = None
|
|
94
95
|
warnings: tuple[str, ...] = ()
|
|
96
|
+
# artifact-files-mismatch : (chemin, cause observee) de chaque fichier en trop.
|
|
97
|
+
extraFiles: tuple[tuple[str, str], ...] = ()
|
|
95
98
|
|
|
96
99
|
@property
|
|
97
100
|
def advanced(self) -> bool:
|
|
@@ -144,6 +147,11 @@ def run_current_activity(
|
|
|
144
147
|
preflight_evidence=(feature_dir / "preflight-evidence.md").is_file(),
|
|
145
148
|
files_since_base=since_base,
|
|
146
149
|
)
|
|
150
|
+
imputed_inputs = (
|
|
151
|
+
_imputed_inputs(feature_dir, feature_path, contract.activity, since_base)
|
|
152
|
+
if contract.activity in DOCUMENT_ARTIFACTS
|
|
153
|
+
else []
|
|
154
|
+
)
|
|
147
155
|
if state.currentActivity == "implement":
|
|
148
156
|
upstream = [
|
|
149
157
|
feature_dir / Path(item).name
|
|
@@ -168,6 +176,18 @@ def run_current_activity(
|
|
|
168
176
|
return AdaptiveRunOutcome(
|
|
169
177
|
"unsupported-activity", state.currentActivity, state.currentActivity, str(exc)
|
|
170
178
|
)
|
|
179
|
+
if imputed_inputs:
|
|
180
|
+
# N5 : refus avant toute ecriture et avant l'agent ; la fiche reste intacte.
|
|
181
|
+
return AdaptiveRunOutcome(
|
|
182
|
+
"artifact-files-mismatch",
|
|
183
|
+
contract.activity,
|
|
184
|
+
contract.activity,
|
|
185
|
+
"entrees du besoin modifiees par un agent de cette activite et pas "
|
|
186
|
+
"remises en etat : " + ", ".join(imputed_inputs) + " ; agent non lance",
|
|
187
|
+
extraFiles=tuple(
|
|
188
|
+
(f"{feature_path}/{name}", "agent-input") for name in imputed_inputs
|
|
189
|
+
),
|
|
190
|
+
)
|
|
171
191
|
raw_file = activity_raw_file(feature_dir, contract.activity)
|
|
172
192
|
guard = ExitStack()
|
|
173
193
|
try:
|
|
@@ -212,8 +232,19 @@ def run_current_activity(
|
|
|
212
232
|
restored = backup.restore() if runtime_mutated else []
|
|
213
233
|
guard.close()
|
|
214
234
|
_write_text_atomic(raw_file, execution.output)
|
|
235
|
+
current_inputs = _input_fingerprints(feature_dir)
|
|
236
|
+
changed_inputs = sorted(
|
|
237
|
+
name
|
|
238
|
+
for name in set(input_fingerprints) | set(current_inputs)
|
|
239
|
+
if input_fingerprints.get(name) != current_inputs.get(name)
|
|
240
|
+
)
|
|
241
|
+
# N5 : une entree modifiee par un agent reste imputee de fiche en fiche.
|
|
242
|
+
attributed_inputs = sorted({*changed_inputs, *imputed_inputs})
|
|
215
243
|
if runtime_mutated:
|
|
216
|
-
_record_failed_attempt(
|
|
244
|
+
_record_failed_attempt(
|
|
245
|
+
feature_dir, contract, execution, "runtime-file-mutated",
|
|
246
|
+
changed_inputs=attributed_inputs,
|
|
247
|
+
)
|
|
217
248
|
return AdaptiveRunOutcome(
|
|
218
249
|
"runtime-file-mutated",
|
|
219
250
|
contract.activity,
|
|
@@ -223,16 +254,10 @@ def run_current_activity(
|
|
|
223
254
|
+ " ; remis dans leur etat d'avant l'agent : "
|
|
224
255
|
+ (", ".join(restored) if restored else "aucun fichier a restaurer"),
|
|
225
256
|
)
|
|
226
|
-
current_inputs = _input_fingerprints(feature_dir)
|
|
227
|
-
changed_inputs = sorted(
|
|
228
|
-
name
|
|
229
|
-
for name in set(input_fingerprints) | set(current_inputs)
|
|
230
|
-
if input_fingerprints.get(name) != current_inputs.get(name)
|
|
231
|
-
)
|
|
232
257
|
if changed_inputs:
|
|
233
258
|
_record_failed_attempt(
|
|
234
259
|
feature_dir, contract, execution,
|
|
235
|
-
"inputs-changed-during-activity", changed_inputs=
|
|
260
|
+
"inputs-changed-during-activity", changed_inputs=attributed_inputs,
|
|
236
261
|
)
|
|
237
262
|
return AdaptiveRunOutcome(
|
|
238
263
|
"inputs-changed-during-activity", contract.activity, contract.activity,
|
|
@@ -252,7 +277,9 @@ def run_current_activity(
|
|
|
252
277
|
reason = "agent-failed"
|
|
253
278
|
if execution.observedChangedFiles:
|
|
254
279
|
detail += f"; mutations observees : {len(set(execution.observedChangedFiles))} fichier(s)"
|
|
255
|
-
_record_failed_attempt(
|
|
280
|
+
_record_failed_attempt(
|
|
281
|
+
feature_dir, contract, execution, reason, changed_inputs=attributed_inputs
|
|
282
|
+
)
|
|
256
283
|
return AdaptiveRunOutcome(reason, contract.activity, contract.activity, detail)
|
|
257
284
|
|
|
258
285
|
try:
|
|
@@ -261,7 +288,10 @@ def run_current_activity(
|
|
|
261
288
|
outcome = AdaptiveRunOutcome(
|
|
262
289
|
"invalid-result", contract.activity, contract.activity, str(exc)
|
|
263
290
|
)
|
|
264
|
-
_record_failed_attempt(
|
|
291
|
+
_record_failed_attempt(
|
|
292
|
+
feature_dir, contract, execution, outcome.reason,
|
|
293
|
+
changed_inputs=attributed_inputs,
|
|
294
|
+
)
|
|
265
295
|
return outcome
|
|
266
296
|
try:
|
|
267
297
|
observation = observe_activity(
|
|
@@ -282,9 +312,15 @@ def run_current_activity(
|
|
|
282
312
|
observation,
|
|
283
313
|
source="agent",
|
|
284
314
|
agent=execution.agent,
|
|
315
|
+
execution_files=execution.observedChangedFiles,
|
|
316
|
+
imputed_inputs=imputed_inputs,
|
|
317
|
+
closed_activities=_closed_activities(state),
|
|
285
318
|
)
|
|
286
319
|
if not outcome.advanced and outcome.reason not in {"blocked", "state-changed"}:
|
|
287
|
-
_record_failed_attempt(
|
|
320
|
+
_record_failed_attempt(
|
|
321
|
+
feature_dir, contract, execution, outcome.reason,
|
|
322
|
+
changed_inputs=attributed_inputs,
|
|
323
|
+
)
|
|
288
324
|
return outcome
|
|
289
325
|
|
|
290
326
|
|
|
@@ -364,6 +400,20 @@ def reconcile_current_activity(
|
|
|
364
400
|
attempt_reason = attempt["reason"]
|
|
365
401
|
observed_files = attempt["observedFiles"]
|
|
366
402
|
execution_files = attempt["executionFiles"]
|
|
403
|
+
imputed_inputs = sorted(
|
|
404
|
+
name
|
|
405
|
+
for name in attempt.get("changedInputs", [])
|
|
406
|
+
if f"{feature_path}/{name}" in since_base
|
|
407
|
+
)
|
|
408
|
+
if imputed_inputs:
|
|
409
|
+
# N5 : reconcile ne blanchit pas une entree imputee a un agent.
|
|
410
|
+
raise ValueError(
|
|
411
|
+
"entrees du besoin modifiees par un agent de cette activite et pas "
|
|
412
|
+
"remises en etat : " + ", ".join(imputed_inputs) + " ; les remettre "
|
|
413
|
+
"dans leur etat de base, ou abandonner la tentative (devflow adaptive "
|
|
414
|
+
f"discard-attempt {shlex.quote(state.issueId)} --reason MOTIF), puis "
|
|
415
|
+
"relancez l'activite"
|
|
416
|
+
)
|
|
367
417
|
if attempt_reason == "inputs-changed-during-activity":
|
|
368
418
|
raise ValueError(
|
|
369
419
|
"les entrees ont change pendant la tentative ; inspectez-les "
|
|
@@ -383,10 +433,18 @@ def reconcile_current_activity(
|
|
|
383
433
|
)
|
|
384
434
|
if head != attempt["head"] or branch != attempt["branch"]:
|
|
385
435
|
raise ValueError("HEAD ou la branche a change depuis la tentative")
|
|
436
|
+
# N6 : pour une activite documentaire, un fichier de la fiche autre que
|
|
437
|
+
# l'artefact peut etre revenu a son etat de base (fichier en trop retire).
|
|
438
|
+
artifact = (
|
|
439
|
+
f"{feature_path}/{DOCUMENT_ARTIFACTS[activity]}"
|
|
440
|
+
if activity in DOCUMENT_ARTIFACTS
|
|
441
|
+
else None
|
|
442
|
+
)
|
|
386
443
|
drifted = sorted(
|
|
387
444
|
path
|
|
388
445
|
for path in set(observed_files) | set(since_base)
|
|
389
446
|
if observed_files.get(path) != since_base.get(path)
|
|
447
|
+
and (artifact is None or path == artifact or path in since_base)
|
|
390
448
|
)
|
|
391
449
|
if drifted:
|
|
392
450
|
raise ValueError(
|
|
@@ -467,6 +525,8 @@ def reconcile_current_activity(
|
|
|
467
525
|
observation,
|
|
468
526
|
source="reconciled",
|
|
469
527
|
agent=agent,
|
|
528
|
+
execution_files=execution_files,
|
|
529
|
+
closed_activities=_closed_activities(state),
|
|
470
530
|
)
|
|
471
531
|
if orphan_warning:
|
|
472
532
|
outcome = replace(outcome, warnings=(orphan_warning, *outcome.warnings))
|
|
@@ -546,12 +606,17 @@ def _apply_activity_result(
|
|
|
546
606
|
*,
|
|
547
607
|
source: str,
|
|
548
608
|
agent: str,
|
|
609
|
+
execution_files: Iterable[str] = (),
|
|
610
|
+
imputed_inputs: Iterable[str] = (),
|
|
611
|
+
closed_activities: Iterable[str] = (),
|
|
549
612
|
) -> AdaptiveRunOutcome:
|
|
550
613
|
"""Valide un resultat agent puis transitionne ; commun a run et reconcile.
|
|
551
614
|
|
|
552
615
|
L'observation fait foi : ``O`` (fichiers depuis la base) et ``E`` (fichiers
|
|
553
616
|
modifies pendant l'agent) fondent les refus ; la declaration de l'agent ne
|
|
554
|
-
produit qu'un avertissement.
|
|
617
|
+
produit qu'un avertissement. ``execution_files`` est la liste brute des fichiers
|
|
618
|
+
modifies pendant l'agent, ``imputed_inputs`` les entrees du besoin deja imputees
|
|
619
|
+
a un agent de l'activite (N5) : ils fondent l'exemption N1.
|
|
555
620
|
"""
|
|
556
621
|
state_file = feature_dir / "workflow-state.json"
|
|
557
622
|
observed = sorted(observation.sinceBase)
|
|
@@ -576,13 +641,35 @@ def _apply_activity_result(
|
|
|
576
641
|
"invalid-result", contract.activity, contract.activity, str(exc)
|
|
577
642
|
)
|
|
578
643
|
|
|
644
|
+
executed = set(execution_files)
|
|
645
|
+
imputed_paths = {f"{feature_path}/{name}" for name in imputed_inputs}
|
|
646
|
+
# N1 : entrees du besoin amendees avant le lancement de l'agent, non comptees.
|
|
647
|
+
amended = (
|
|
648
|
+
[
|
|
649
|
+
path
|
|
650
|
+
for path in _input_paths(feature_dir, feature_path)
|
|
651
|
+
if path in observation.sinceBase
|
|
652
|
+
and path not in executed
|
|
653
|
+
and path not in imputed_paths
|
|
654
|
+
]
|
|
655
|
+
if contract.activity in DOCUMENT_ARTIFACTS
|
|
656
|
+
else []
|
|
657
|
+
)
|
|
658
|
+
counted = [path for path in observed if path not in amended]
|
|
579
659
|
declared = sorted(set(result.changedFiles))
|
|
580
|
-
|
|
581
|
-
warnings = (
|
|
660
|
+
amendment = _amendment_warning(contract.issueId, amended, closed_activities)
|
|
661
|
+
warnings = tuple(
|
|
662
|
+
message
|
|
663
|
+
for message in (declaration_warning(declared, counted), amendment)
|
|
664
|
+
if message
|
|
665
|
+
)
|
|
582
666
|
|
|
583
|
-
def refuse(
|
|
667
|
+
def refuse(
|
|
668
|
+
reason: str, detail: str, extra_files: tuple[tuple[str, str], ...] = ()
|
|
669
|
+
) -> AdaptiveRunOutcome:
|
|
584
670
|
return AdaptiveRunOutcome(
|
|
585
|
-
reason, contract.activity, contract.activity, detail, result, warnings
|
|
671
|
+
reason, contract.activity, contract.activity, detail, result, warnings,
|
|
672
|
+
extra_files,
|
|
586
673
|
)
|
|
587
674
|
|
|
588
675
|
if contract.activity == "implement" and result.status == "completed" and not observed:
|
|
@@ -594,11 +681,22 @@ def _apply_activity_result(
|
|
|
594
681
|
contract.activity, reopened=contract_is_reopened_plan(contract)
|
|
595
682
|
)
|
|
596
683
|
expected = f"{feature_path}/{artifact_name}"
|
|
597
|
-
if any(path != expected for path in
|
|
598
|
-
result.status == "completed" and
|
|
684
|
+
if any(path != expected for path in counted) or (
|
|
685
|
+
result.status == "completed" and counted != [expected]
|
|
599
686
|
):
|
|
600
687
|
return refuse(
|
|
601
|
-
"artifact-files-mismatch",
|
|
688
|
+
"artifact-files-mismatch",
|
|
689
|
+
f"attendu={[expected]}, observes={counted}",
|
|
690
|
+
tuple(
|
|
691
|
+
(
|
|
692
|
+
path,
|
|
693
|
+
"agent-input" if path in imputed_paths
|
|
694
|
+
else "during-agent" if path in executed
|
|
695
|
+
else "before-launch",
|
|
696
|
+
)
|
|
697
|
+
for path in counted
|
|
698
|
+
if path != expected
|
|
699
|
+
),
|
|
602
700
|
)
|
|
603
701
|
if contract.activity in DOCUMENT_ARTIFACTS and result.status == "completed":
|
|
604
702
|
artifact_name = document_artifact_name(
|
|
@@ -642,7 +740,9 @@ def _apply_activity_result(
|
|
|
642
740
|
|
|
643
741
|
recorded = result.to_dict()
|
|
644
742
|
recorded["changedFiles"] = observed
|
|
645
|
-
recorded["observation"] = recorded_observation(
|
|
743
|
+
recorded["observation"] = recorded_observation(
|
|
744
|
+
observation, declared, exempted=amended, amendment_warning=amendment
|
|
745
|
+
)
|
|
646
746
|
_write_json_atomic(activity_result_file(feature_dir, contract.activity), recorded)
|
|
647
747
|
if result.status == "blocked":
|
|
648
748
|
safe_refresh_worklog(feature_dir)
|
|
@@ -932,15 +1032,22 @@ def _record_failed_attempt(
|
|
|
932
1032
|
|
|
933
1033
|
``executionFiles`` est la liste brute des fichiers modifies pendant
|
|
934
1034
|
l'agent, non filtree. ``observedFiles`` vaut les fichiers depuis la base de l'activite ; si
|
|
935
|
-
l'observation est impossible,
|
|
1035
|
+
l'observation est impossible, une fiche minimale (``head`` et ``branch`` vides,
|
|
1036
|
+
``observedFiles`` vide) n'est ecrite que si une entree du besoin est imputee ;
|
|
1037
|
+
sinon aucune fiche n'est ecrite (N7).
|
|
936
1038
|
"""
|
|
937
1039
|
try:
|
|
938
1040
|
state = read_adaptive_state(feature_dir / "workflow-state.json")
|
|
939
|
-
if state is None:
|
|
940
|
-
return
|
|
941
|
-
head, branch, observed = observe_attempt(feature_dir, state)
|
|
942
1041
|
except (OSError, ValueError):
|
|
943
1042
|
return
|
|
1043
|
+
if state is None:
|
|
1044
|
+
return
|
|
1045
|
+
try:
|
|
1046
|
+
head, branch, observed = observe_attempt(feature_dir, state)
|
|
1047
|
+
except (OSError, ValueError):
|
|
1048
|
+
if not changed_inputs:
|
|
1049
|
+
return
|
|
1050
|
+
head, branch, observed = "", "", {}
|
|
944
1051
|
if changed_inputs:
|
|
945
1052
|
input_paths = {f"{contract.featurePath}/{name}" for name in changed_inputs}
|
|
946
1053
|
observed = {
|
|
@@ -966,6 +1073,74 @@ def _record_failed_attempt(
|
|
|
966
1073
|
_write_json_atomic(activity_attempt_file(feature_dir, contract.activity), payload)
|
|
967
1074
|
|
|
968
1075
|
|
|
1076
|
+
def _input_paths(feature_dir: Path, feature_path: str) -> list[str]:
|
|
1077
|
+
"""Chemins des entrees du besoin qui sont des fichiers ordinaires lisibles.
|
|
1078
|
+
|
|
1079
|
+
Un lien symbolique ou une entree illisible n'en fait pas partie : il reste compte.
|
|
1080
|
+
"""
|
|
1081
|
+
return [
|
|
1082
|
+
f"{feature_path}/{name}"
|
|
1083
|
+
for name, fingerprint in sorted(_input_fingerprints(feature_dir).items())
|
|
1084
|
+
if not fingerprint.startswith(("symlink:", "unreadable:"))
|
|
1085
|
+
]
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
def _imputed_inputs(
|
|
1089
|
+
feature_dir: Path, feature_path: str, activity: str, since_base: dict[str, str]
|
|
1090
|
+
) -> list[str]:
|
|
1091
|
+
"""Entrees que la fiche de tentative impute a un agent de l'activite (N5).
|
|
1092
|
+
|
|
1093
|
+
Seules comptent celles qui different encore de la base : une entree remise en
|
|
1094
|
+
etat n'est plus imputee.
|
|
1095
|
+
"""
|
|
1096
|
+
try:
|
|
1097
|
+
attempt = json.loads(
|
|
1098
|
+
activity_attempt_file(feature_dir, activity).read_text(encoding="utf-8")
|
|
1099
|
+
)
|
|
1100
|
+
except (OSError, UnicodeDecodeError, json.JSONDecodeError):
|
|
1101
|
+
return []
|
|
1102
|
+
if not _valid_attempt(attempt) or attempt["activity"] != activity:
|
|
1103
|
+
return []
|
|
1104
|
+
return sorted(
|
|
1105
|
+
name
|
|
1106
|
+
for name in attempt.get("changedInputs", [])
|
|
1107
|
+
if f"{feature_path}/{name}" in since_base
|
|
1108
|
+
)
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
def _closed_activities(state: AdaptiveWorkflowState) -> list[str]:
|
|
1112
|
+
"""Activites closes qu'``adaptive reopen`` accepte comme cible."""
|
|
1113
|
+
return [
|
|
1114
|
+
activity
|
|
1115
|
+
for activity in state.completedActivities
|
|
1116
|
+
if activity not in {"assess", "done"}
|
|
1117
|
+
]
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
def _amendment_warning(
|
|
1121
|
+
issue_id: str, amended: list[str], closed_activities: Iterable[str]
|
|
1122
|
+
) -> str:
|
|
1123
|
+
"""Avertissement d'une entree du besoin amendee avant l'agent (N2), ou ''."""
|
|
1124
|
+
if not amended:
|
|
1125
|
+
return ""
|
|
1126
|
+
parts = [
|
|
1127
|
+
"entrees du besoin amendees avant le lancement de l'agent, non comptees "
|
|
1128
|
+
"contre l'artefact attendu : " + ", ".join(amended)
|
|
1129
|
+
]
|
|
1130
|
+
closed = list(closed_activities)
|
|
1131
|
+
if closed:
|
|
1132
|
+
parts.append(
|
|
1133
|
+
"activites deja closes, produites sur l'ancien besoin : " + ", ".join(closed)
|
|
1134
|
+
)
|
|
1135
|
+
parts.append(
|
|
1136
|
+
"si l'amendement change leur resultat : devflow adaptive reopen "
|
|
1137
|
+
f"{shlex.quote(issue_id)} ACTIVITE --reason MOTIF"
|
|
1138
|
+
)
|
|
1139
|
+
else:
|
|
1140
|
+
parts.append("aucune activite close a rouvrir")
|
|
1141
|
+
return " ; ".join(parts)
|
|
1142
|
+
|
|
1143
|
+
|
|
969
1144
|
def _input_fingerprints(feature_dir: Path) -> dict[str, str]:
|
|
970
1145
|
"""Empreinte les entrees modifiables sans conserver leur contenu."""
|
|
971
1146
|
paths = [feature_dir / NEED_STATEMENT, *sorted(feature_dir.glob("issue-*.md"))]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: devflow-cli
|
|
3
|
-
Version: 8.
|
|
3
|
+
Version: 8.4.1
|
|
4
4
|
Summary: Spec-Driven Development workflow CLI
|
|
5
5
|
Project-URL: Homepage, https://github.com/sopequenoteck/devflow
|
|
6
6
|
Project-URL: Repository, https://github.com/sopequenoteck/devflow
|
|
@@ -116,6 +116,22 @@ nomme la cause (`structured-output-missing`) et propose
|
|
|
116
116
|
`devflow adaptive reconcile KS-123 --result MODELE --reason MOTIF` avec un
|
|
117
117
|
modèle de résultat prérempli, écrit dans `~/.devflow/reconcile/` et à compléter.
|
|
118
118
|
|
|
119
|
+
`need.md` peut être amendé en cours de parcours. Avant une activité
|
|
120
|
+
documentaire, l'amendement est accepté avec un avertissement qui nomme les
|
|
121
|
+
activités déjà closes, à rouvrir si leur résultat en dépend ; avant `prepare`,
|
|
122
|
+
il est accepté sans cet avertissement ; pendant l'exécution d'un agent, il est refusé ;
|
|
123
|
+
avant `implement`, il périme la preuve de pré-vol ; après `implement`, il
|
|
124
|
+
périme une revue déjà faite. Pour arbitrer après un blocage d'`implement` :
|
|
125
|
+
amender `need.md`, puis `devflow adaptive reopen KS-123 preflight-evidence
|
|
126
|
+
--reason MOTIF`, refaire le pré-vol et relancer `implement`. Un refus
|
|
127
|
+
d'artefact (`artifact-files-mismatch`) nomme chaque fichier en trop et sa
|
|
128
|
+
cause : retirer ou remettre en état le fichier, puis
|
|
129
|
+
`devflow adaptive reconcile KS-123` ; la relance à l'identique n'est plus
|
|
130
|
+
proposée. Pour une entrée du besoin modifiée par un agent, la relance est
|
|
131
|
+
refusée avant le lancement de l'agent : remettre l'entrée en état, ou
|
|
132
|
+
`devflow adaptive discard-attempt KS-123 --reason MOTIF`, puis
|
|
133
|
+
`devflow adaptive run KS-123`.
|
|
134
|
+
|
|
119
135
|
Chaque invocation de `adaptive run` traite une activité. La politique est dans
|
|
120
136
|
`assessment.json`; la progression et les preuves sont dans
|
|
121
137
|
`workflow-state.json`. Les résultats agent sont validés par schéma et les
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
devflow_cli/__init__.py,sha256=
|
|
1
|
+
devflow_cli/__init__.py,sha256=MQEclHX75ybzzUEyJ3iAVMLUfzOpBzaQ_E5gi0d-TUc,925
|
|
2
2
|
devflow_cli/cli.py,sha256=0_SmhJX_k7OQfp-jNV_jq9EOgWY4rTjStGIoc9pH6Ec,2686
|
|
3
3
|
devflow_cli/adapters/__init__.py,sha256=RkjHPU2Lp4hSVIq2iOmyTrv2zYU9NuiIF9wEMWzLdMI,377
|
|
4
4
|
devflow_cli/adapters/agents.py,sha256=01ZQb96koWMKH-mma3AtttdEjNEbu3mM89vFetD9iR8,29689
|
|
5
5
|
devflow_cli/adapters/linear.py,sha256=HE1YzjBxwoj2jJ_3bmh9Pn_7Mt5u3EOLk891vMXBEj4,8700
|
|
6
6
|
devflow_cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
devflow_cli/commands/adaptive.py,sha256=
|
|
7
|
+
devflow_cli/commands/adaptive.py,sha256=5D8K4aevxMlehsE65wnEn6ny6g_4A1Bes_OBVIUrbSM,71520
|
|
8
8
|
devflow_cli/commands/assess.py,sha256=V-E3ft41ljCrqp2WLjR1Dqw-JtswcqsK2nD1-euNbNE,5655
|
|
9
9
|
devflow_cli/commands/check.py,sha256=hsfeOg9yDOTAIvNm6XhRmTIFgv7w9wC8zvrwm4ojfZs,6923
|
|
10
10
|
devflow_cli/commands/context.py,sha256=hwTitOHxIpJMx1X8R1jHHy9CpE4HVZpJKkyeOujxAio,6246
|
|
@@ -23,9 +23,9 @@ devflow_cli/commands/upgrade_cmd.py,sha256=d5uBFUPzPsCJDLxhQBFaeHWJv3GWWLmPpkYHR
|
|
|
23
23
|
devflow_cli/commands/usage.py,sha256=ehH1AH5J-XfkebFx6qLBwpKN-MOoX2uUbq4LejBpNsk,3148
|
|
24
24
|
devflow_cli/commands/verify.py,sha256=GBFCfsN-xWyROCcngOANz-3ftNVeNZ4Y_JeWFo2muwE,4139
|
|
25
25
|
devflow_cli/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
-
devflow_cli/core/activity_base.py,sha256=
|
|
26
|
+
devflow_cli/core/activity_base.py,sha256=YId_tUxiL6TYmnVpG2VYGkA31nPjIrskx6Dof27XR6E,16696
|
|
27
27
|
devflow_cli/core/activity_contracts.py,sha256=n9arBw-SWEFqTlCDNed6lV4WolkZKAvmQg1qcfk57ss,39036
|
|
28
|
-
devflow_cli/core/adaptive_runner.py,sha256=
|
|
28
|
+
devflow_cli/core/adaptive_runner.py,sha256=BU3LZzM2f7dNvgKm_ul0CZYIs8z7WN1hM--TrF9o07s,48852
|
|
29
29
|
devflow_cli/core/adaptive_workflow.py,sha256=F4uV5okQpFidZmneVZwW52XAO7gAmtuBAqBO9K9q7Uk,12173
|
|
30
30
|
devflow_cli/core/agent_failure.py,sha256=iX4q249lAHeVdD_ZF1aObmU-FX6sjfYP9dfLSnWGAD0,3771
|
|
31
31
|
devflow_cli/core/agent_run_marker.py,sha256=QW3ScA2ZpqfQdUo5ANTbenDVyY2iHpB_wTaN6VUKlzc,3451
|
|
@@ -90,8 +90,8 @@ devflow_cli/resources/templates/contracts/api-template.md,sha256=rC5v7JBz71PznCn
|
|
|
90
90
|
devflow_cli/resources/templates/contracts/components-template.md,sha256=XIWfEXfC72sNmL5OA3V-7xIywkNDU2DBPLfyiagOWcs,484
|
|
91
91
|
devflow_cli/resources/templates/contracts/interfaces-template.md,sha256=kf8B7b6HsmN7jyRlLNU7RnZl0rTMlI5s97yVRyI-6yc,336
|
|
92
92
|
devflow_cli/resources/templates/contracts/services-template.md,sha256=cFafKCyLmq_a7aR7G0LXAaMO2z4Fuflq6iKdxfVg0vg,477
|
|
93
|
-
devflow_cli-8.
|
|
94
|
-
devflow_cli-8.
|
|
95
|
-
devflow_cli-8.
|
|
96
|
-
devflow_cli-8.
|
|
97
|
-
devflow_cli-8.
|
|
93
|
+
devflow_cli-8.4.1.dist-info/METADATA,sha256=Z1ZlFp1ND90t29jlf-ofmvs_JOnZUOk7KMJB8M-HmEA,9846
|
|
94
|
+
devflow_cli-8.4.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
95
|
+
devflow_cli-8.4.1.dist-info/entry_points.txt,sha256=GVJ6bMvFpqyO5589iC4nFKeGTpGIW8aKn_QPPpSZ6kU,48
|
|
96
|
+
devflow_cli-8.4.1.dist-info/licenses/LICENSE,sha256=v79PvnmqOdKhQiOa_QcWxng4q8GuGscLOwi7ygUpwpo,1070
|
|
97
|
+
devflow_cli-8.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|