devflow-cli 11.2.0__py3-none-any.whl → 11.3.0__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 CHANGED
@@ -1,6 +1,6 @@
1
1
  """devflow CLI — workflow de développement adaptatif."""
2
2
 
3
- VERSION = "11.2.0"
3
+ VERSION = "11.3.0"
4
4
 
5
5
  ACTIVITY_LINEAR_MAPPING = {
6
6
  "assess": "Backlog",
@@ -936,16 +936,26 @@ def _execute_local_verification(
936
936
  None if outcome.passed
937
937
  else _verify_recovery(feature_dir, issue_id, outcome, refresh=refresh)
938
938
  )
939
+ reused = (
940
+ {"commands": outcome.reusedCommands, "from": outcome.reusedFrom}
941
+ if outcome.reusedCommands
942
+ else None
943
+ )
939
944
  if json_output:
940
945
  _print_execution_json(
941
946
  issue_id, "verify", outcome.passed, outcome.reason, outcome.detail,
942
947
  outcome.nextActivity,
943
948
  ExitCode.OK if outcome.passed else ExitCode.VERIFICATION_FAILURE,
944
- recovery=recovery,
949
+ recovery=recovery, reused=reused,
945
950
  )
946
951
  if not outcome.passed:
947
952
  raise typer.Exit(int(ExitCode.VERIFICATION_FAILURE))
948
953
  return
954
+ if reused is not None:
955
+ console.print(
956
+ f" Reprise : {reused['commands']} commande(s) verte(s) reprise(s) du "
957
+ f"passage du {reused['from']}, sur le meme code"
958
+ )
949
959
  if outcome.passed:
950
960
  if refresh:
951
961
  ok(f"Preuves de verify rafraichies. Activite courante : {outcome.nextActivity}")
@@ -1071,6 +1081,11 @@ def _verify_recovery(
1071
1081
  "purpose": (
1072
1082
  "voie 3 : echec passager (reseau, conteneur, service externe), "
1073
1083
  "relancer la verification"
1084
+ + (
1085
+ "" if refresh
1086
+ else " ; si le code n'a pas change, seules les commandes en echec "
1087
+ "sont rejouees"
1088
+ )
1074
1089
  ),
1075
1090
  })
1076
1091
  return {
@@ -1142,6 +1157,7 @@ def _print_execution_json(
1142
1157
  issue_id: str, activity: str | None, passed: bool, reason: str,
1143
1158
  detail: str, next_activity: str | None, exit_code: ExitCode,
1144
1159
  *, warnings: tuple[str, ...] = (), recovery: dict | None = None,
1160
+ reused: dict | None = None,
1145
1161
  ) -> None:
1146
1162
  if not passed:
1147
1163
  note_refusal(reason)
@@ -1158,6 +1174,8 @@ def _print_execution_json(
1158
1174
  }
1159
1175
  if recovery is not None:
1160
1176
  payload["recovery"] = recovery
1177
+ if reused is not None:
1178
+ payload["reused"] = reused
1161
1179
  typer.echo(json.dumps(payload, ensure_ascii=False))
1162
1180
 
1163
1181
 
@@ -46,7 +46,7 @@ RUNTIME_FILE_NAMES = frozenset({
46
46
  "workflow-state.json", ".workflow-state.lock", "activity-contract.json",
47
47
  "agent-execution.json", "worklog.md", "reopen-log.json", "attempt-discard-log.json",
48
48
  "reconcile-log.json", "validation-approvals.json", "waivers.json", "verification.json",
49
- ".agent-run.lock",
49
+ ".agent-run.lock", "verify-pass.json",
50
50
  })
51
51
  RUNTIME_FILE_SUFFIXES = ("-result.json", "-attempt.json", ".raw.txt")
52
52
  RUNTIME_DIRECTORIES = ("attempts", "evidence")
@@ -40,6 +40,7 @@ from devflow_cli.core.assessment import read_assessment
40
40
  from devflow_cli.core.verification import (
41
41
  ValidationCommand,
42
42
  VerificationResult,
43
+ command_fingerprint,
43
44
  redact_command,
44
45
  run_verifications,
45
46
  validate_command_policy,
@@ -84,6 +85,9 @@ class AutomaticVerificationOutcome:
84
85
  nextActivity: str = "verify"
85
86
  pendingApprovals: tuple[str, ...] = ()
86
87
  failures: tuple[VerificationFailure, ...] = ()
88
+ # Commandes vertes reprises du passage precedent, et startedAt de ce passage.
89
+ reusedCommands: int = 0
90
+ reusedFrom: str = ""
87
91
 
88
92
 
89
93
  def select_validation_commands(
@@ -702,16 +706,58 @@ def run_automatic_verification(
702
706
  [commands, regression_commands, security_commands], planned_prefix
703
707
  )
704
708
 
709
+ # Reprise des verts du passage precedent (D2) : jamais avec --refresh (D6).
710
+ verify_entered_at: str | None = None
711
+ lot_before: str | None = None
712
+ reusable: dict[str, dict] = {}
713
+ if not refresh:
714
+ recorded_at = (state.activityBase or {}).get("recordedAt")
715
+ verify_entered_at = recorded_at if isinstance(recorded_at, str) else None
716
+ try:
717
+ lot_before = lot_fingerprint(
718
+ state.implementBase["head"], observed_lot(project_root, feature_dir, state)
719
+ )
720
+ except (BaseObservationError, OSError, ValueError):
721
+ lot_before = None
722
+ if verify_entered_at is not None and lot_before is not None:
723
+ reusable = _reusable_results(
724
+ feature_dir, verify_entered_at=verify_entered_at, lot=lot_before
725
+ )
726
+ # Le passage qui commence remplace le precedent, meme s'il s'interrompt.
727
+ (feature_dir / VERIFY_PASS_FILE).unlink(missing_ok=True)
728
+ executed_commands: list[ValidationCommand] = []
729
+
730
+ def reused_result(item: ValidationCommand) -> VerificationResult | None:
731
+ entry = reusable.get(item.id)
732
+ if entry is None or entry["fingerprint"] != command_fingerprint(
733
+ item.args, item.working_directory
734
+ ):
735
+ return None
736
+ return _green_result(item, entry["result"], entry["startedAt"])
737
+
738
+ def execute_or_reuse(items: list[ValidationCommand]) -> list[VerificationResult]:
739
+ reused = {
740
+ item.id: result
741
+ for item in items
742
+ if (result := reused_result(item)) is not None
743
+ }
744
+ pending_items = [item for item in items if item.id not in reused]
745
+ executed = iter(execute_with_approvals(pending_items))
746
+ executed_commands.extend(pending_items)
747
+ return [
748
+ reused[item.id] if item.id in reused else next(executed) for item in items
749
+ ]
750
+
705
751
  before = snapshot_worktree(project_root)
706
752
  started_at = _now_iso()
707
753
  try:
708
- results = execute_with_approvals(commands)
754
+ results = execute_or_reuse(commands)
709
755
  regression_results = (
710
756
  results
711
757
  if reuse_targeted_as_regression
712
- else execute_with_approvals(regression_commands)
758
+ else execute_or_reuse(regression_commands)
713
759
  )
714
- security_results = execute_with_approvals(security_commands)
760
+ security_results = execute_or_reuse(security_commands)
715
761
  except ValueError as exc:
716
762
  detail = str(exc)
717
763
  for planned in [*regression_commands, *security_commands]:
@@ -733,6 +779,37 @@ def run_automatic_verification(
733
779
  result.id: result
734
780
  for result in [*results, *regression_results, *security_results]
735
781
  }
782
+ reused_ids = {
783
+ result.id for result in results_by_id.values() if result.reused_from is not None
784
+ }
785
+ reused_from = next(
786
+ (
787
+ result.reused_from for result in results_by_id.values()
788
+ if result.reused_from is not None
789
+ ),
790
+ "",
791
+ )
792
+ evidence_files: list[Path] = []
793
+ pass_lot: list[str | None] = [None]
794
+
795
+ def concluded(outcome: AutomaticVerificationOutcome) -> AutomaticVerificationOutcome:
796
+ """Trace un passage refuse sur un code inchange pendant verify (D5)."""
797
+ if (
798
+ not outcome.passed
799
+ and evidence_files
800
+ and verify_entered_at is not None
801
+ and lot_before is not None
802
+ and pass_lot[0] == lot_before
803
+ ):
804
+ _record_verify_pass(
805
+ feature_dir,
806
+ started_at=started_at,
807
+ verify_entered_at=verify_entered_at,
808
+ lot=lot_before,
809
+ evidence_files=evidence_files,
810
+ executed=executed_commands,
811
+ )
812
+ return replace(outcome, reusedCommands=len(reused_ids), reusedFrom=reused_from)
736
813
  targeted_keepers = _keeper_results(covered_targeted, results_by_id)
737
814
  regression_keepers = _keeper_results(covered_regression, results_by_id)
738
815
  security_keepers = _keeper_results(covered_security, results_by_id)
@@ -755,14 +832,15 @@ def run_automatic_verification(
755
832
  try:
756
833
  lot = observed_lot(project_root, feature_dir, state)
757
834
  except BaseObservationError as exc:
758
- return AutomaticVerificationOutcome(False, exc.reason, str(exc))
835
+ return concluded(AutomaticVerificationOutcome(False, exc.reason, str(exc)))
759
836
  base_head = state.implementBase["head"]
837
+ pass_lot[0] = lot_fingerprint(base_head, lot)
760
838
  diff_payload = _inspect_diff(project_root, feature_dir, lot, base_head=base_head)
761
839
  final_snapshot = snapshot_worktree(project_root)
762
840
  try:
763
841
  test_mutations = changed_paths(before, final_snapshot)
764
842
  except ValueError as exc:
765
- return AutomaticVerificationOutcome(False, "worktree-changed", str(exc))
843
+ return concluded(AutomaticVerificationOutcome(False, "worktree-changed", str(exc)))
766
844
 
767
845
  targeted_id = {
768
846
  "quick": "targeted-check",
@@ -800,6 +878,7 @@ def run_automatic_verification(
800
878
  evidence_dir.mkdir(exist_ok=True)
801
879
  targeted_file = evidence_dir / f"{targeted_id}.json"
802
880
  _write_json_atomic(targeted_file, check_payload)
881
+ evidence_files.append(targeted_file)
803
882
 
804
883
  regression_file: Path | None = None
805
884
  if state.profile == "standard":
@@ -816,6 +895,7 @@ def run_automatic_verification(
816
895
  }
817
896
  regression_file = evidence_dir / "regression-check.json"
818
897
  _write_json_atomic(regression_file, regression_payload)
898
+ evidence_files.append(regression_file)
819
899
 
820
900
  security_file: Path | None = None
821
901
  security_payload: dict | None = None
@@ -836,6 +916,7 @@ def run_automatic_verification(
836
916
  }
837
917
  security_file = evidence_dir / "security-or-data-check.json"
838
918
  _write_json_atomic(security_file, security_payload)
919
+ evidence_files.append(security_file)
839
920
 
840
921
  diff_file = evidence_dir / "diff-inspection.json"
841
922
  _write_json_atomic(diff_file, diff_payload)
@@ -853,9 +934,9 @@ def run_automatic_verification(
853
934
  **coverage.to_dict(),
854
935
  }
855
936
  except (OSError, UnicodeDecodeError) as exc:
856
- return AutomaticVerificationOutcome(
937
+ return concluded(AutomaticVerificationOutcome(
857
938
  False, "requirements-coverage-failed", str(exc)
858
- )
939
+ ))
859
940
  coverage_file = evidence_dir / "requirements-coverage.json"
860
941
  _write_json_atomic(coverage_file, coverage_payload)
861
942
 
@@ -868,30 +949,30 @@ def run_automatic_verification(
868
949
  if result.blocking and not result.succeeded
869
950
  ]
870
951
  detail = ", ".join(failed) or "les tests ont modifie le working tree"
871
- return AutomaticVerificationOutcome(
952
+ return concluded(AutomaticVerificationOutcome(
872
953
  False, f"{targeted_id}-failed", detail,
873
954
  failures=_failures(reported),
874
- )
955
+ ))
875
956
  if state.profile == "standard" and not regression_passed:
876
957
  safe_refresh_worklog(feature_dir)
877
958
  reported = _with_keepers(regression_results, regression_keepers)
878
959
  failed = [result.id for result in reported if not result.succeeded]
879
- return AutomaticVerificationOutcome(
960
+ return concluded(AutomaticVerificationOutcome(
880
961
  False, "regression-check-failed", ", ".join(failed),
881
962
  failures=_failures(reported),
882
- )
963
+ ))
883
964
  if diff_payload["outcome"] != "passed":
884
965
  safe_refresh_worklog(feature_dir)
885
- return AutomaticVerificationOutcome(
966
+ return concluded(AutomaticVerificationOutcome(
886
967
  False, "diff-inspection-failed", "; ".join(diff_payload["findings"])
887
- )
968
+ ))
888
969
  if state.profile == "deep" and coverage_payload["outcome"] != "passed":
889
970
  safe_refresh_worklog(feature_dir)
890
- return AutomaticVerificationOutcome(
971
+ return concluded(AutomaticVerificationOutcome(
891
972
  False,
892
973
  "requirements-coverage-failed",
893
974
  ", ".join(coverage_payload["missingRequirements"]),
894
- )
975
+ ))
895
976
  if security_payload is not None and security_payload["outcome"] != "passed":
896
977
  safe_refresh_worklog(feature_dir)
897
978
  reported = _with_keepers(security_results, security_keepers)
@@ -902,7 +983,7 @@ def run_automatic_verification(
902
983
  f"{item['commandId']}: {item['finding']}"
903
984
  for item in security_findings
904
985
  )
905
- return AutomaticVerificationOutcome(
986
+ return concluded(AutomaticVerificationOutcome(
906
987
  False, "security-or-data-check-failed", ", ".join(failed),
907
988
  failures=(
908
989
  *_failures(reported),
@@ -911,21 +992,22 @@ def run_automatic_verification(
911
992
  for item in security_findings
912
993
  ),
913
994
  ),
914
- )
995
+ ))
915
996
 
916
997
  with workflow_lock(feature_dir):
917
998
  latest = read_adaptive_state(state_file)
918
999
  if latest is None or latest.currentActivity != state.currentActivity:
919
- return AutomaticVerificationOutcome(False, "state-changed")
1000
+ return concluded(AutomaticVerificationOutcome(False, "state-changed"))
920
1001
  # Une preuve n'est jamais liee a un contenu qui n'a pas ete inspecte.
921
1002
  try:
922
1003
  recorded_lot = observed_lot(project_root, feature_dir, latest)
923
1004
  except BaseObservationError as exc:
924
- return AutomaticVerificationOutcome(False, exc.reason, str(exc))
1005
+ return concluded(AutomaticVerificationOutcome(False, exc.reason, str(exc)))
925
1006
  if recorded_lot != lot:
926
- return AutomaticVerificationOutcome(
1007
+ pass_lot[0] = None
1008
+ return concluded(AutomaticVerificationOutcome(
927
1009
  False, "worktree-changed", "le lot a change pendant verify"
928
- )
1010
+ ))
929
1011
  worktree = lot_fingerprint(base_head, lot)
930
1012
  record_evidence(
931
1013
  latest,
@@ -971,15 +1053,15 @@ def run_automatic_verification(
971
1053
  try:
972
1054
  enter_current_activity(latest, project_root, feature_dir)
973
1055
  except (OSError, ValueError) as exc:
974
- return AutomaticVerificationOutcome(
1056
+ return concluded(AutomaticVerificationOutcome(
975
1057
  False,
976
1058
  "transition-refused",
977
1059
  f"base de l'activite {latest.currentActivity} non enregistree : {exc}",
978
- )
1060
+ ))
979
1061
  try:
980
1062
  write_adaptive_state(state_file, latest)
981
1063
  except StateInvariantError as exc:
982
- return AutomaticVerificationOutcome(False, "transition-refused", str(exc))
1064
+ return concluded(AutomaticVerificationOutcome(False, "transition-refused", str(exc)))
983
1065
  next_activity = latest.currentActivity
984
1066
  safe_refresh_worklog(feature_dir)
985
1067
  detail = (
@@ -988,8 +1070,191 @@ def run_automatic_verification(
988
1070
  if document_batch is not None
989
1071
  else ""
990
1072
  )
991
- return AutomaticVerificationOutcome(
1073
+ return concluded(AutomaticVerificationOutcome(
992
1074
  True, "passed", detail, nextActivity=next_activity
1075
+ ))
1076
+
1077
+
1078
+ VERIFY_PASS_FILE = "verify-pass.json"
1079
+ VERIFY_PASS_SCHEMA_VERSION = 1
1080
+ VERIFY_PASS_KEYS = frozenset({
1081
+ "schemaVersion", "recordedAt", "startedAt", "verifyEnteredAt", "lotFingerprint",
1082
+ "evidence", "commands",
1083
+ })
1084
+ SHA256_RE = re.compile(r"^[0-9a-f]{64}$")
1085
+ VERIFY_PASS_EVIDENCE_RE = re.compile(r"^evidence/[A-Za-z0-9._-]+\.json$")
1086
+
1087
+
1088
+ def validate_verify_pass(payload: object) -> None:
1089
+ """Invariants de verify-pass.json, controles a l'ecriture comme avant toute reprise.
1090
+
1091
+ Leve ValueError en nommant l'invariant viole.
1092
+ """
1093
+ if not isinstance(payload, dict):
1094
+ raise ValueError("verify-pass invalide : objet JSON attendu")
1095
+ if payload.get("schemaVersion") != VERIFY_PASS_SCHEMA_VERSION:
1096
+ raise ValueError("verify-pass invalide : schemaVersion")
1097
+ if set(payload) != VERIFY_PASS_KEYS:
1098
+ raise ValueError("verify-pass invalide : cles")
1099
+ for key in ("recordedAt", "startedAt", "verifyEnteredAt"):
1100
+ if not isinstance(payload[key], str) or not payload[key]:
1101
+ raise ValueError(f"verify-pass invalide : {key}")
1102
+ if not isinstance(payload["lotFingerprint"], str) or not SHA256_RE.fullmatch(
1103
+ payload["lotFingerprint"]
1104
+ ):
1105
+ raise ValueError("verify-pass invalide : lotFingerprint")
1106
+ evidence = payload["evidence"]
1107
+ if not isinstance(evidence, list) or not evidence:
1108
+ raise ValueError("verify-pass invalide : evidence")
1109
+ paths: set[str] = set()
1110
+ for item in evidence:
1111
+ if (
1112
+ not isinstance(item, dict)
1113
+ or set(item) != {"path", "sha256"}
1114
+ or not isinstance(item["path"], str)
1115
+ or not VERIFY_PASS_EVIDENCE_RE.fullmatch(item["path"])
1116
+ or not isinstance(item["sha256"], str)
1117
+ or not SHA256_RE.fullmatch(item["sha256"])
1118
+ or item["path"] in paths
1119
+ ):
1120
+ raise ValueError("verify-pass invalide : evidence")
1121
+ paths.add(item["path"])
1122
+ commands = payload["commands"]
1123
+ if not isinstance(commands, list):
1124
+ raise ValueError("verify-pass invalide : commands")
1125
+ ids: set[str] = set()
1126
+ for item in commands:
1127
+ if (
1128
+ not isinstance(item, dict)
1129
+ or set(item) != {"id", "fingerprint"}
1130
+ or not isinstance(item["id"], str)
1131
+ or not item["id"]
1132
+ or not isinstance(item["fingerprint"], str)
1133
+ or not SHA256_RE.fullmatch(item["fingerprint"])
1134
+ or item["id"] in ids
1135
+ ):
1136
+ raise ValueError("verify-pass invalide : commands")
1137
+ ids.add(item["id"])
1138
+
1139
+
1140
+ def _record_verify_pass(
1141
+ feature_dir: Path,
1142
+ *,
1143
+ started_at: str,
1144
+ verify_entered_at: str,
1145
+ lot: str,
1146
+ evidence_files: list[Path],
1147
+ executed: list[ValidationCommand],
1148
+ ) -> None:
1149
+ """Ecrit la trace d'un passage refuse ; une trace invalide n'est jamais ecrite."""
1150
+ commands: dict[str, str] = {}
1151
+ for item in executed:
1152
+ commands.setdefault(item.id, command_fingerprint(item.args, item.working_directory))
1153
+ payload = {
1154
+ "schemaVersion": VERIFY_PASS_SCHEMA_VERSION,
1155
+ "recordedAt": _now_iso(),
1156
+ "startedAt": started_at,
1157
+ "verifyEnteredAt": verify_entered_at,
1158
+ "lotFingerprint": lot,
1159
+ "evidence": [
1160
+ {
1161
+ "path": path.relative_to(feature_dir).as_posix(),
1162
+ "sha256": hashlib.sha256(path.read_bytes()).hexdigest(),
1163
+ }
1164
+ for path in evidence_files
1165
+ ],
1166
+ "commands": [
1167
+ {"id": command_id, "fingerprint": fingerprint}
1168
+ for command_id, fingerprint in commands.items()
1169
+ ],
1170
+ }
1171
+ try:
1172
+ validate_verify_pass(payload)
1173
+ except ValueError:
1174
+ return
1175
+ _write_json_atomic(feature_dir / VERIFY_PASS_FILE, payload)
1176
+
1177
+
1178
+ def _reusable_results(
1179
+ feature_dir: Path, *, verify_entered_at: str, lot: str
1180
+ ) -> dict[str, dict]:
1181
+ """Resultats executes au passage precedent, par identifiant de commande (D2, D5).
1182
+
1183
+ Trace absente, illisible, invalide, d'un autre passage dans verify ou d'un autre
1184
+ code, preuve modifiee depuis, ou passage qui a modifie le working tree : rien
1185
+ n'est repris, sans refus.
1186
+ """
1187
+ try:
1188
+ payload = json.loads((feature_dir / VERIFY_PASS_FILE).read_text(encoding="utf-8"))
1189
+ validate_verify_pass(payload)
1190
+ except (OSError, UnicodeDecodeError, ValueError):
1191
+ return {}
1192
+ if payload["verifyEnteredAt"] != verify_entered_at or payload["lotFingerprint"] != lot:
1193
+ return {}
1194
+ recorded: list[dict] = []
1195
+ for item in payload["evidence"]:
1196
+ try:
1197
+ content = (feature_dir / item["path"]).read_bytes()
1198
+ evidence = json.loads(content.decode("utf-8"))
1199
+ except (OSError, UnicodeDecodeError, ValueError):
1200
+ return {}
1201
+ if (
1202
+ hashlib.sha256(content).hexdigest() != item["sha256"]
1203
+ or not isinstance(evidence, dict)
1204
+ or evidence.get("startedAt") != payload["startedAt"]
1205
+ or evidence.get("worktreeMutations") != []
1206
+ or not isinstance(evidence.get("commands"), list)
1207
+ ):
1208
+ return {}
1209
+ recorded.extend(entry for entry in evidence["commands"] if isinstance(entry, dict))
1210
+ reusable: dict[str, dict] = {}
1211
+ for command in payload["commands"]:
1212
+ result = next(
1213
+ (
1214
+ entry for entry in recorded
1215
+ if entry.get("id") == command["id"] and "reusedFrom" not in entry
1216
+ ),
1217
+ None,
1218
+ )
1219
+ if result is not None:
1220
+ reusable[command["id"]] = {
1221
+ "fingerprint": command["fingerprint"],
1222
+ "result": result,
1223
+ "startedAt": payload["startedAt"],
1224
+ }
1225
+ return reusable
1226
+
1227
+
1228
+ def _green_result(
1229
+ command: ValidationCommand, recorded: dict, started_at: str
1230
+ ) -> VerificationResult | None:
1231
+ """Resultat repris d'une commande verte sans constat d'execution (D2.4), sinon None."""
1232
+ stdout, stderr = recorded.get("stdout"), recorded.get("stderr")
1233
+ duration = recorded.get("durationSeconds")
1234
+ if (
1235
+ type(recorded.get("returncode")) is not int
1236
+ or recorded["returncode"] != 0
1237
+ or recorded.get("timedOut") is not False
1238
+ or not isinstance(stdout, str)
1239
+ or not isinstance(stderr, str)
1240
+ or isinstance(duration, bool)
1241
+ or not isinstance(duration, (int, float))
1242
+ ):
1243
+ return None
1244
+ if _is_test_command(command.args) and _test_execution_finding(
1245
+ command.args, ANSI_ESCAPE_RE.sub("", f"{stdout}\n{stderr}")
1246
+ ):
1247
+ return None
1248
+ return VerificationResult(
1249
+ command.id,
1250
+ command.args,
1251
+ command.blocking,
1252
+ 0,
1253
+ stdout=stdout,
1254
+ stderr=stderr,
1255
+ working_directory=command.working_directory,
1256
+ duration_seconds=duration,
1257
+ reused_from=started_at,
993
1258
  )
994
1259
 
995
1260
 
@@ -2,11 +2,14 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import hashlib
6
+ import json
5
7
  import re
6
8
  import subprocess
9
+ import time
7
10
  from dataclasses import dataclass
8
11
  from pathlib import Path
9
- from typing import Collection, Mapping
12
+ from typing import Callable, Collection, Mapping
10
13
 
11
14
  from devflow_cli.adapters.linear import environment_without_linear_key
12
15
  from devflow_cli.core.redaction import redact_command, redact_text
@@ -131,13 +134,16 @@ class VerificationResult:
131
134
  stderr: str = ""
132
135
  timed_out: bool = False
133
136
  working_directory: str = "."
137
+ duration_seconds: float = 0.0
138
+ # startedAt de la preuve du passage qui a execute la commande, pour un resultat repris.
139
+ reused_from: str | None = None
134
140
 
135
141
  @property
136
142
  def succeeded(self) -> bool:
137
143
  return self.returncode == 0 and not self.timed_out
138
144
 
139
145
  def to_dict(self) -> dict:
140
- return {
146
+ payload = {
141
147
  "id": self.id,
142
148
  "command": redact_command(self.command),
143
149
  "blocking": self.blocking,
@@ -147,7 +153,19 @@ class VerificationResult:
147
153
  "workingDirectory": self.working_directory,
148
154
  "stdout": redact_text(self.stdout),
149
155
  "stderr": redact_text(self.stderr),
156
+ "durationSeconds": self.duration_seconds,
150
157
  }
158
+ if self.reused_from is not None:
159
+ payload["reusedFrom"] = self.reused_from
160
+ return payload
161
+
162
+
163
+ def command_fingerprint(args: list[str], working_directory: str) -> str:
164
+ """Empreinte sha256 des arguments exacts, avant masquage, et du dossier d'execution."""
165
+ payload = json.dumps(
166
+ {"args": list(args), "workingDirectory": working_directory}, sort_keys=True
167
+ )
168
+ return hashlib.sha256(payload.encode("utf-8")).hexdigest()
151
169
 
152
170
 
153
171
  def run_verifications(
@@ -157,6 +175,7 @@ def run_verifications(
157
175
  approved_by_id: Mapping[str, Collection[str]] | None = None,
158
176
  *,
159
177
  workflow: bool = False,
178
+ clock: Callable[[], float] = time.monotonic,
160
179
  ) -> list[VerificationResult]:
161
180
  validate_command_policy(
162
181
  commands, allowed_commands, approved_by_id=approved_by_id, workflow=workflow
@@ -167,6 +186,7 @@ def run_verifications(
167
186
  ]
168
187
  results: list[VerificationResult] = []
169
188
  for validation, working_directory in zip(commands, working_directories, strict=True):
189
+ started = clock()
170
190
  try:
171
191
  process = subprocess.run(
172
192
  validation.args,
@@ -185,6 +205,7 @@ def run_verifications(
185
205
  stdout=process.stdout[-MAX_OUTPUT:],
186
206
  stderr=process.stderr[-MAX_OUTPUT:],
187
207
  working_directory=validation.working_directory,
208
+ duration_seconds=_elapsed(clock, started),
188
209
  ))
189
210
  except subprocess.TimeoutExpired as exc:
190
211
  results.append(VerificationResult(
@@ -196,6 +217,7 @@ def run_verifications(
196
217
  stderr=_text(exc.stderr)[-MAX_OUTPUT:],
197
218
  timed_out=True,
198
219
  working_directory=validation.working_directory,
220
+ duration_seconds=_elapsed(clock, started),
199
221
  ))
200
222
  except FileNotFoundError as exc:
201
223
  results.append(VerificationResult(
@@ -205,10 +227,15 @@ def run_verifications(
205
227
  returncode=127,
206
228
  stderr=str(exc),
207
229
  working_directory=validation.working_directory,
230
+ duration_seconds=_elapsed(clock, started),
208
231
  ))
209
232
  return results
210
233
 
211
234
 
235
+ def _elapsed(clock: Callable[[], float], started: float) -> float:
236
+ return round(max(clock() - started, 0.0), 3)
237
+
238
+
212
239
  def validate_command_policy(
213
240
  commands: list[ValidationCommand],
214
241
  allowed_commands: Collection[str] = (),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devflow-cli
3
- Version: 11.2.0
3
+ Version: 11.3.0
4
4
  Summary: Workflow adaptatif pour Claude Code : profils, preuves et contrats d'activité
5
5
  Project-URL: Homepage, https://github.com/sopequenoteck/devflow
6
6
  Project-URL: Repository, https://github.com/sopequenoteck/devflow
@@ -1,10 +1,10 @@
1
- devflow_cli/__init__.py,sha256=vmkwJEwELUxVwxHeL3_1yFRXX8EvZRhDIH3e4hq60C0,871
1
+ devflow_cli/__init__.py,sha256=eYJVjUxdQ7h7sppzw1b8pRVZb8A6fEh7vTwNAfRd3XE,871
2
2
  devflow_cli/cli.py,sha256=QQktLkHK1cEAj0ZlEuGKYumm3xJUHM-aeC-E2RgfcEY,2136
3
3
  devflow_cli/adapters/__init__.py,sha256=z1J7_YJHcgak2a6dTZpOUKKwf-K7UwRqGzS8XY9duC0,299
4
4
  devflow_cli/adapters/agents.py,sha256=gVvxZnYxPQqDq_BQi0WP-mlOZ3-_fjVa8UI7i-JkMIo,22153
5
5
  devflow_cli/adapters/linear.py,sha256=xHKjMuL3fFJEDBF65pPJ-yWHpXom999UAU2A0C7_QeI,8362
6
6
  devflow_cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- devflow_cli/commands/adaptive.py,sha256=BFO0XYhG8T2ACrB1KOMLPKmVU8gt7dTtRut0FWn7WAw,67893
7
+ devflow_cli/commands/adaptive.py,sha256=Ji7PCDoaFfB20jzrJGgauOwwpVzSmRhVlwviGXtaejU,68529
8
8
  devflow_cli/commands/assess.py,sha256=V-E3ft41ljCrqp2WLjR1Dqw-JtswcqsK2nD1-euNbNE,5655
9
9
  devflow_cli/commands/check.py,sha256=nJOHVFvgT3Nq70g-4QGrSDZVwCSetu6g7snZcfLFf9I,4421
10
10
  devflow_cli/commands/docs_sync.py,sha256=Xc0mulpNTjDyeUDumKL7VNG0eumAf3016wEM_dqXpSU,1021
@@ -15,14 +15,14 @@ devflow_cli/commands/report.py,sha256=rLzb2CqMqCU5U6Ssw1ab6NdtpaUGdOsY66hZ51H3DV
15
15
  devflow_cli/commands/status.py,sha256=Votdh_sZkRuC_iui1krrdXE9cZ5dpY2OO2au4PVa7IQ,8647
16
16
  devflow_cli/commands/upgrade_cmd.py,sha256=7GYe1T7SWzkDSYW9x1G-Dznw9qwKT2uI1gJUcWr9_2M,6093
17
17
  devflow_cli/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- devflow_cli/core/activity_base.py,sha256=eEC_YIr5O7WhCglA7xAEPypVzhcdC6f2h9d-SDDecVA,20475
18
+ devflow_cli/core/activity_base.py,sha256=2VXq2SkBVhRYyEKAXLLpQQUJn3UygkTiNjzLvHfSI1Y,20495
19
19
  devflow_cli/core/activity_contracts.py,sha256=M1heF8J_oQl7e8zlws_lUEL-nIN0ub4GJQKWoN9XaTk,40581
20
20
  devflow_cli/core/adaptive_runner.py,sha256=PuixfWdqpdfIkfUAE10r4S2d1qUZqb5WpA_0P2psvrM,50355
21
21
  devflow_cli/core/adaptive_workflow.py,sha256=dCtzURfOSsk_DpdLMwVlGNO4hUXeLH0lUOz29kP64G8,14416
22
22
  devflow_cli/core/agent_failure.py,sha256=iX4q249lAHeVdD_ZF1aObmU-FX6sjfYP9dfLSnWGAD0,3771
23
23
  devflow_cli/core/agent_run_marker.py,sha256=QW3ScA2ZpqfQdUo5ANTbenDVyY2iHpB_wTaN6VUKlzc,3451
24
24
  devflow_cli/core/assessment.py,sha256=ACtJbXq1qZjVfeERjy8Qg6-ioLfSMUBVQm2l-mtGwgI,11522
25
- devflow_cli/core/automatic_evidence.py,sha256=u2vpRm072fIkWkSdrlcaz_3GAW7dfr0IXVkCUEHYnAs,50747
25
+ devflow_cli/core/automatic_evidence.py,sha256=_fIJFMmrYF4FUrD9cNvVsqrJ3hmnbXkq0XkbLJzWrls,61084
26
26
  devflow_cli/core/contract_schemas.py,sha256=CWzaDbJEbe9KjqJG2r-u3KNsAlHnI5NxdA0yf05FRyU,9670
27
27
  devflow_cli/core/decisions.py,sha256=tFYKNDaztMvnhLfVGJKIux5zaSjEPx2nwXs5nb2qv4U,6308
28
28
  devflow_cli/core/docgen.py,sha256=47JoVDWetkcctgHwJZC67AVebOKgl10VB9hZ3Xr63mo,3908
@@ -41,7 +41,7 @@ devflow_cli/core/telemetry.py,sha256=FVR4iU9ywXIPo_5wrqWufpsp3GmHVLYiWaReaZ_DebM
41
41
  devflow_cli/core/traceability.py,sha256=jfNE9MZzGkmaPer9Wa6Y18yA9Y3sqdeR-nzH9h_TB-8,2968
42
42
  devflow_cli/core/validation_approvals.py,sha256=3AHOpnW3BtY3BQrRZr38K7VNYRvbxGNhmQRYAufyhSA,9279
43
43
  devflow_cli/core/validators.py,sha256=HKGG1-td5T8cFx3rbE0iWPtddolk73qsqYreVWVT07g,7081
44
- devflow_cli/core/verification.py,sha256=3_iGhsXNFCs5cpBUyBCRTsmRsfuBAVa38lRgy-LXXww,20349
44
+ devflow_cli/core/verification.py,sha256=hQh3gDnOlKONeCy3pfWo6kBBQpIbZIY0asuikH4sN74,21449
45
45
  devflow_cli/core/waivers.py,sha256=0w38Osjr69mDT6Lsn0ljkaq6bbggVejuhqiOnYHabs4,5586
46
46
  devflow_cli/core/worklog.py,sha256=WPvK0D8b0DBOmnjEoKVum8_EtYR3DjTz7e2p9bulFzk,17577
47
47
  devflow_cli/core/worktree_snapshot.py,sha256=ESNWFJN8fZ7NKeDdEKHZq9f9V_2wv-3Z6dlWusu9oH4,6034
@@ -58,8 +58,8 @@ devflow_cli/utils/strings.py,sha256=bfFXCwBDnFxshgZOYfy6mtysnjiaWO1wFnqBf7HLg4o,
58
58
  devflow_cli/resources/commands/devflow.md,sha256=__hcU7uy7CrKODk-Tsvd8XlTnGsrsgLkgP4OzEMZk3k,5541
59
59
  devflow_cli/resources/commands/devflow.status.md,sha256=tqjQ1IboU99ztG6C4nunBHGJCvMn3qDqx3AoF4SPjCk,338
60
60
  devflow_cli/resources/templates/constitution-template.md,sha256=uSzNuwF-xIRx8cHt9gloynRjNgDGmnN5z2Xck6fCOsI,2102
61
- devflow_cli-11.2.0.dist-info/METADATA,sha256=njgOU2tWroX-ADG5LZPjM-iEhS2TY5ON65aQJ0tfFLQ,6674
62
- devflow_cli-11.2.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
63
- devflow_cli-11.2.0.dist-info/entry_points.txt,sha256=GVJ6bMvFpqyO5589iC4nFKeGTpGIW8aKn_QPPpSZ6kU,48
64
- devflow_cli-11.2.0.dist-info/licenses/LICENSE,sha256=v79PvnmqOdKhQiOa_QcWxng4q8GuGscLOwi7ygUpwpo,1070
65
- devflow_cli-11.2.0.dist-info/RECORD,,
61
+ devflow_cli-11.3.0.dist-info/METADATA,sha256=UxbHBGNnW3oj6yJX33mSpRkELSMmrti-ktU1YkyglGE,6674
62
+ devflow_cli-11.3.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
63
+ devflow_cli-11.3.0.dist-info/entry_points.txt,sha256=GVJ6bMvFpqyO5589iC4nFKeGTpGIW8aKn_QPPpSZ6kU,48
64
+ devflow_cli-11.3.0.dist-info/licenses/LICENSE,sha256=v79PvnmqOdKhQiOa_QcWxng4q8GuGscLOwi7ygUpwpo,1070
65
+ devflow_cli-11.3.0.dist-info/RECORD,,