devflow-cli 11.1.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 +1 -1
- devflow_cli/commands/adaptive.py +19 -1
- devflow_cli/core/activity_base.py +1 -1
- devflow_cli/core/activity_contracts.py +5 -1
- devflow_cli/core/automatic_evidence.py +481 -46
- devflow_cli/core/verification.py +29 -2
- devflow_cli/core/worklog.py +10 -0
- {devflow_cli-11.1.0.dist-info → devflow_cli-11.3.0.dist-info}/METADATA +1 -1
- {devflow_cli-11.1.0.dist-info → devflow_cli-11.3.0.dist-info}/RECORD +12 -12
- {devflow_cli-11.1.0.dist-info → devflow_cli-11.3.0.dist-info}/WHEEL +0 -0
- {devflow_cli-11.1.0.dist-info → devflow_cli-11.3.0.dist-info}/entry_points.txt +0 -0
- {devflow_cli-11.1.0.dist-info → devflow_cli-11.3.0.dist-info}/licenses/LICENSE +0 -0
devflow_cli/__init__.py
CHANGED
devflow_cli/commands/adaptive.py
CHANGED
|
@@ -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")
|
|
@@ -66,7 +66,11 @@ VALIDATION_PLAN_ROLE_CONSTRAINT = (
|
|
|
66
66
|
"validationPlan est la liste que verify executera apres implement pour produire "
|
|
67
67
|
"la preuve : y lancer les tests du lot (suite du projet et tests cibles), ne pas "
|
|
68
68
|
"y controler le document produit par cette activite, et n'y mettre aucune "
|
|
69
|
-
"commande vouee a echouer apres implement (par exemple git diff --exit-code)."
|
|
69
|
+
"commande vouee a echouer apres implement (par exemple git diff --exit-code). "
|
|
70
|
+
"verify lance deja, pour chaque module touche, la suite de regression de la CLI "
|
|
71
|
+
"(mvn verify, et le build ou la verification Node) : ne pas repeter ces commandes "
|
|
72
|
+
"dans validationPlan ; une commande repetee quand meme est couverte par la "
|
|
73
|
+
"commande equivalente gardee, sans refus."
|
|
70
74
|
)
|
|
71
75
|
# KKS-554 (D3) : verify refuse un diff que git diff --check signale.
|
|
72
76
|
FILE_ENDING_CONSTRAINT = (
|
|
@@ -11,7 +11,7 @@ import shutil
|
|
|
11
11
|
import tempfile
|
|
12
12
|
from dataclasses import dataclass, replace
|
|
13
13
|
from datetime import datetime, timezone
|
|
14
|
-
from pathlib import Path
|
|
14
|
+
from pathlib import Path, PurePosixPath
|
|
15
15
|
|
|
16
16
|
from devflow_cli.core.adaptive_workflow import (
|
|
17
17
|
AdaptiveWorkflowState,
|
|
@@ -40,6 +40,8 @@ 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,
|
|
44
|
+
redact_command,
|
|
43
45
|
run_verifications,
|
|
44
46
|
validate_command_policy,
|
|
45
47
|
)
|
|
@@ -83,6 +85,9 @@ class AutomaticVerificationOutcome:
|
|
|
83
85
|
nextActivity: str = "verify"
|
|
84
86
|
pendingApprovals: tuple[str, ...] = ()
|
|
85
87
|
failures: tuple[VerificationFailure, ...] = ()
|
|
88
|
+
# Commandes vertes reprises du passage precedent, et startedAt de ce passage.
|
|
89
|
+
reusedCommands: int = 0
|
|
90
|
+
reusedFrom: str = ""
|
|
86
91
|
|
|
87
92
|
|
|
88
93
|
def select_validation_commands(
|
|
@@ -588,15 +593,7 @@ def run_automatic_verification(
|
|
|
588
593
|
return AutomaticVerificationOutcome(
|
|
589
594
|
False, "invalid-preparation-result", str(exc)
|
|
590
595
|
)
|
|
591
|
-
|
|
592
|
-
(tuple(command.args), command.working_directory)
|
|
593
|
-
for command in regression_commands
|
|
594
|
-
}
|
|
595
|
-
regression_commands.extend(
|
|
596
|
-
command
|
|
597
|
-
for command in planned_commands
|
|
598
|
-
if (tuple(command.args), command.working_directory) not in known_commands
|
|
599
|
-
)
|
|
596
|
+
regression_commands.extend(planned_commands)
|
|
600
597
|
if state.profile in {"standard", "deep"} and not regression_commands:
|
|
601
598
|
return AutomaticVerificationOutcome(
|
|
602
599
|
False,
|
|
@@ -694,16 +691,73 @@ def run_automatic_verification(
|
|
|
694
691
|
False, "validation-policy-refused", "; ".join(refusals)
|
|
695
692
|
)
|
|
696
693
|
|
|
694
|
+
# Les gates et la politique ont vu toutes les commandes : seules les gardees s'executent.
|
|
695
|
+
if reuse_targeted_as_regression:
|
|
696
|
+
(regression_commands, security_commands), (
|
|
697
|
+
covered_regression, covered_security
|
|
698
|
+
) = deduplicate_commands(
|
|
699
|
+
[regression_commands, security_commands], planned_prefix
|
|
700
|
+
)
|
|
701
|
+
commands, covered_targeted = regression_commands, []
|
|
702
|
+
else:
|
|
703
|
+
(commands, regression_commands, security_commands), (
|
|
704
|
+
covered_targeted, covered_regression, covered_security
|
|
705
|
+
) = deduplicate_commands(
|
|
706
|
+
[commands, regression_commands, security_commands], planned_prefix
|
|
707
|
+
)
|
|
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
|
+
|
|
697
751
|
before = snapshot_worktree(project_root)
|
|
698
752
|
started_at = _now_iso()
|
|
699
753
|
try:
|
|
700
|
-
results =
|
|
754
|
+
results = execute_or_reuse(commands)
|
|
701
755
|
regression_results = (
|
|
702
756
|
results
|
|
703
757
|
if reuse_targeted_as_regression
|
|
704
|
-
else
|
|
758
|
+
else execute_or_reuse(regression_commands)
|
|
705
759
|
)
|
|
706
|
-
security_results =
|
|
760
|
+
security_results = execute_or_reuse(security_commands)
|
|
707
761
|
except ValueError as exc:
|
|
708
762
|
detail = str(exc)
|
|
709
763
|
for planned in [*regression_commands, *security_commands]:
|
|
@@ -721,29 +775,72 @@ def run_automatic_verification(
|
|
|
721
775
|
break
|
|
722
776
|
return AutomaticVerificationOutcome(False, "validation-policy-refused", detail)
|
|
723
777
|
completed_at = _now_iso()
|
|
724
|
-
|
|
725
|
-
result.
|
|
778
|
+
results_by_id = {
|
|
779
|
+
result.id: result
|
|
780
|
+
for result in [*results, *regression_results, *security_results]
|
|
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)
|
|
813
|
+
targeted_keepers = _keeper_results(covered_targeted, results_by_id)
|
|
814
|
+
regression_keepers = _keeper_results(covered_regression, results_by_id)
|
|
815
|
+
security_keepers = _keeper_results(covered_security, results_by_id)
|
|
816
|
+
checks_passed = (
|
|
817
|
+
bool(results) or bool(covered_targeted) or document_batch is not None
|
|
818
|
+
) and all(
|
|
819
|
+
result.succeeded or not result.blocking
|
|
820
|
+
for result in [*results, *targeted_keepers]
|
|
726
821
|
)
|
|
727
822
|
regression_passed = all(
|
|
728
|
-
result.succeeded or not result.blocking
|
|
823
|
+
result.succeeded or not result.blocking
|
|
824
|
+
for result in [*regression_results, *regression_keepers]
|
|
729
825
|
)
|
|
730
826
|
security_findings = _sensitive_execution_findings(security_results)
|
|
731
827
|
security_passed = (
|
|
732
|
-
bool(security_results)
|
|
733
|
-
and all(result.succeeded for result in security_results)
|
|
828
|
+
(bool(security_results) or bool(covered_security))
|
|
829
|
+
and all(result.succeeded for result in [*security_results, *security_keepers])
|
|
734
830
|
and not security_findings
|
|
735
831
|
)
|
|
736
832
|
try:
|
|
737
833
|
lot = observed_lot(project_root, feature_dir, state)
|
|
738
834
|
except BaseObservationError as exc:
|
|
739
|
-
return AutomaticVerificationOutcome(False, exc.reason, str(exc))
|
|
835
|
+
return concluded(AutomaticVerificationOutcome(False, exc.reason, str(exc)))
|
|
740
836
|
base_head = state.implementBase["head"]
|
|
837
|
+
pass_lot[0] = lot_fingerprint(base_head, lot)
|
|
741
838
|
diff_payload = _inspect_diff(project_root, feature_dir, lot, base_head=base_head)
|
|
742
839
|
final_snapshot = snapshot_worktree(project_root)
|
|
743
840
|
try:
|
|
744
841
|
test_mutations = changed_paths(before, final_snapshot)
|
|
745
842
|
except ValueError as exc:
|
|
746
|
-
return AutomaticVerificationOutcome(False, "worktree-changed", str(exc))
|
|
843
|
+
return concluded(AutomaticVerificationOutcome(False, "worktree-changed", str(exc)))
|
|
747
844
|
|
|
748
845
|
targeted_id = {
|
|
749
846
|
"quick": "targeted-check",
|
|
@@ -755,6 +852,12 @@ def run_automatic_verification(
|
|
|
755
852
|
if reuse_targeted_as_regression or state.profile != "deep"
|
|
756
853
|
else [*results, *regression_results]
|
|
757
854
|
)
|
|
855
|
+
check_covered = (
|
|
856
|
+
covered_targeted
|
|
857
|
+
if reuse_targeted_as_regression or state.profile != "deep"
|
|
858
|
+
else [*covered_targeted, *covered_regression]
|
|
859
|
+
)
|
|
860
|
+
check_keepers = _keeper_results(check_covered, results_by_id)
|
|
758
861
|
check_passed = (
|
|
759
862
|
checks_passed and regression_passed
|
|
760
863
|
if state.profile == "deep"
|
|
@@ -767,6 +870,7 @@ def run_automatic_verification(
|
|
|
767
870
|
"startedAt": started_at,
|
|
768
871
|
"completedAt": completed_at,
|
|
769
872
|
"commands": [result.to_dict() for result in check_results],
|
|
873
|
+
"coveredCommands": [item.to_dict() for item in check_covered],
|
|
770
874
|
"worktreeMutations": test_mutations,
|
|
771
875
|
"waiversApplied": applied_waivers,
|
|
772
876
|
}
|
|
@@ -774,6 +878,7 @@ def run_automatic_verification(
|
|
|
774
878
|
evidence_dir.mkdir(exist_ok=True)
|
|
775
879
|
targeted_file = evidence_dir / f"{targeted_id}.json"
|
|
776
880
|
_write_json_atomic(targeted_file, check_payload)
|
|
881
|
+
evidence_files.append(targeted_file)
|
|
777
882
|
|
|
778
883
|
regression_file: Path | None = None
|
|
779
884
|
if state.profile == "standard":
|
|
@@ -784,11 +889,13 @@ def run_automatic_verification(
|
|
|
784
889
|
"startedAt": started_at,
|
|
785
890
|
"completedAt": completed_at,
|
|
786
891
|
"commands": [result.to_dict() for result in regression_results],
|
|
892
|
+
"coveredCommands": [item.to_dict() for item in covered_regression],
|
|
787
893
|
"worktreeMutations": test_mutations,
|
|
788
894
|
"waiversApplied": applied_waivers,
|
|
789
895
|
}
|
|
790
896
|
regression_file = evidence_dir / "regression-check.json"
|
|
791
897
|
_write_json_atomic(regression_file, regression_payload)
|
|
898
|
+
evidence_files.append(regression_file)
|
|
792
899
|
|
|
793
900
|
security_file: Path | None = None
|
|
794
901
|
security_payload: dict | None = None
|
|
@@ -802,12 +909,14 @@ def run_automatic_verification(
|
|
|
802
909
|
"startedAt": started_at,
|
|
803
910
|
"completedAt": completed_at,
|
|
804
911
|
"commands": [result.to_dict() for result in security_results],
|
|
912
|
+
"coveredCommands": [item.to_dict() for item in covered_security],
|
|
805
913
|
"executionFindings": security_findings,
|
|
806
914
|
"worktreeMutations": test_mutations,
|
|
807
915
|
"waiversApplied": [],
|
|
808
916
|
}
|
|
809
917
|
security_file = evidence_dir / "security-or-data-check.json"
|
|
810
918
|
_write_json_atomic(security_file, security_payload)
|
|
919
|
+
evidence_files.append(security_file)
|
|
811
920
|
|
|
812
921
|
diff_file = evidence_dir / "diff-inspection.json"
|
|
813
922
|
_write_json_atomic(diff_file, diff_payload)
|
|
@@ -825,76 +934,80 @@ def run_automatic_verification(
|
|
|
825
934
|
**coverage.to_dict(),
|
|
826
935
|
}
|
|
827
936
|
except (OSError, UnicodeDecodeError) as exc:
|
|
828
|
-
return AutomaticVerificationOutcome(
|
|
937
|
+
return concluded(AutomaticVerificationOutcome(
|
|
829
938
|
False, "requirements-coverage-failed", str(exc)
|
|
830
|
-
)
|
|
939
|
+
))
|
|
831
940
|
coverage_file = evidence_dir / "requirements-coverage.json"
|
|
832
941
|
_write_json_atomic(coverage_file, coverage_payload)
|
|
833
942
|
|
|
834
943
|
if check_payload["outcome"] != "passed":
|
|
835
944
|
safe_refresh_worklog(feature_dir)
|
|
945
|
+
reported = _with_keepers(check_results, check_keepers)
|
|
836
946
|
failed = [
|
|
837
947
|
result.id
|
|
838
|
-
for result in
|
|
948
|
+
for result in reported
|
|
839
949
|
if result.blocking and not result.succeeded
|
|
840
950
|
]
|
|
841
951
|
detail = ", ".join(failed) or "les tests ont modifie le working tree"
|
|
842
|
-
return AutomaticVerificationOutcome(
|
|
952
|
+
return concluded(AutomaticVerificationOutcome(
|
|
843
953
|
False, f"{targeted_id}-failed", detail,
|
|
844
|
-
failures=_failures(
|
|
845
|
-
)
|
|
954
|
+
failures=_failures(reported),
|
|
955
|
+
))
|
|
846
956
|
if state.profile == "standard" and not regression_passed:
|
|
847
957
|
safe_refresh_worklog(feature_dir)
|
|
848
|
-
|
|
849
|
-
|
|
958
|
+
reported = _with_keepers(regression_results, regression_keepers)
|
|
959
|
+
failed = [result.id for result in reported if not result.succeeded]
|
|
960
|
+
return concluded(AutomaticVerificationOutcome(
|
|
850
961
|
False, "regression-check-failed", ", ".join(failed),
|
|
851
|
-
failures=_failures(
|
|
852
|
-
)
|
|
962
|
+
failures=_failures(reported),
|
|
963
|
+
))
|
|
853
964
|
if diff_payload["outcome"] != "passed":
|
|
854
965
|
safe_refresh_worklog(feature_dir)
|
|
855
|
-
return AutomaticVerificationOutcome(
|
|
966
|
+
return concluded(AutomaticVerificationOutcome(
|
|
856
967
|
False, "diff-inspection-failed", "; ".join(diff_payload["findings"])
|
|
857
|
-
)
|
|
968
|
+
))
|
|
858
969
|
if state.profile == "deep" and coverage_payload["outcome"] != "passed":
|
|
859
970
|
safe_refresh_worklog(feature_dir)
|
|
860
|
-
return AutomaticVerificationOutcome(
|
|
971
|
+
return concluded(AutomaticVerificationOutcome(
|
|
861
972
|
False,
|
|
862
973
|
"requirements-coverage-failed",
|
|
863
974
|
", ".join(coverage_payload["missingRequirements"]),
|
|
864
|
-
)
|
|
975
|
+
))
|
|
865
976
|
if security_payload is not None and security_payload["outcome"] != "passed":
|
|
866
977
|
safe_refresh_worklog(feature_dir)
|
|
978
|
+
reported = _with_keepers(security_results, security_keepers)
|
|
867
979
|
failed = [
|
|
868
|
-
result.id for result in
|
|
980
|
+
result.id for result in reported if not result.succeeded
|
|
869
981
|
]
|
|
870
982
|
failed.extend(
|
|
871
983
|
f"{item['commandId']}: {item['finding']}"
|
|
872
984
|
for item in security_findings
|
|
873
985
|
)
|
|
874
|
-
return AutomaticVerificationOutcome(
|
|
986
|
+
return concluded(AutomaticVerificationOutcome(
|
|
875
987
|
False, "security-or-data-check-failed", ", ".join(failed),
|
|
876
988
|
failures=(
|
|
877
|
-
*_failures(
|
|
989
|
+
*_failures(reported),
|
|
878
990
|
*(
|
|
879
991
|
VerificationFailure(item["commandId"], None)
|
|
880
992
|
for item in security_findings
|
|
881
993
|
),
|
|
882
994
|
),
|
|
883
|
-
)
|
|
995
|
+
))
|
|
884
996
|
|
|
885
997
|
with workflow_lock(feature_dir):
|
|
886
998
|
latest = read_adaptive_state(state_file)
|
|
887
999
|
if latest is None or latest.currentActivity != state.currentActivity:
|
|
888
|
-
return AutomaticVerificationOutcome(False, "state-changed")
|
|
1000
|
+
return concluded(AutomaticVerificationOutcome(False, "state-changed"))
|
|
889
1001
|
# Une preuve n'est jamais liee a un contenu qui n'a pas ete inspecte.
|
|
890
1002
|
try:
|
|
891
1003
|
recorded_lot = observed_lot(project_root, feature_dir, latest)
|
|
892
1004
|
except BaseObservationError as exc:
|
|
893
|
-
return AutomaticVerificationOutcome(False, exc.reason, str(exc))
|
|
1005
|
+
return concluded(AutomaticVerificationOutcome(False, exc.reason, str(exc)))
|
|
894
1006
|
if recorded_lot != lot:
|
|
895
|
-
|
|
1007
|
+
pass_lot[0] = None
|
|
1008
|
+
return concluded(AutomaticVerificationOutcome(
|
|
896
1009
|
False, "worktree-changed", "le lot a change pendant verify"
|
|
897
|
-
)
|
|
1010
|
+
))
|
|
898
1011
|
worktree = lot_fingerprint(base_head, lot)
|
|
899
1012
|
record_evidence(
|
|
900
1013
|
latest,
|
|
@@ -940,15 +1053,15 @@ def run_automatic_verification(
|
|
|
940
1053
|
try:
|
|
941
1054
|
enter_current_activity(latest, project_root, feature_dir)
|
|
942
1055
|
except (OSError, ValueError) as exc:
|
|
943
|
-
return AutomaticVerificationOutcome(
|
|
1056
|
+
return concluded(AutomaticVerificationOutcome(
|
|
944
1057
|
False,
|
|
945
1058
|
"transition-refused",
|
|
946
1059
|
f"base de l'activite {latest.currentActivity} non enregistree : {exc}",
|
|
947
|
-
)
|
|
1060
|
+
))
|
|
948
1061
|
try:
|
|
949
1062
|
write_adaptive_state(state_file, latest)
|
|
950
1063
|
except StateInvariantError as exc:
|
|
951
|
-
return AutomaticVerificationOutcome(False, "transition-refused", str(exc))
|
|
1064
|
+
return concluded(AutomaticVerificationOutcome(False, "transition-refused", str(exc)))
|
|
952
1065
|
next_activity = latest.currentActivity
|
|
953
1066
|
safe_refresh_worklog(feature_dir)
|
|
954
1067
|
detail = (
|
|
@@ -957,11 +1070,333 @@ def run_automatic_verification(
|
|
|
957
1070
|
if document_batch is not None
|
|
958
1071
|
else ""
|
|
959
1072
|
)
|
|
960
|
-
return AutomaticVerificationOutcome(
|
|
1073
|
+
return concluded(AutomaticVerificationOutcome(
|
|
961
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,
|
|
962
1258
|
)
|
|
963
1259
|
|
|
964
1260
|
|
|
1261
|
+
MAVEN_EXECUTABLES = frozenset({"mvn", "./mvnw"})
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
def normalized_command(command: ValidationCommand) -> tuple[str, tuple[str, ...], str]:
|
|
1265
|
+
"""Forme normalisee (executable, arguments, dossier) qui decide de l'equivalence."""
|
|
1266
|
+
directory = PurePosixPath(command.working_directory or ".")
|
|
1267
|
+
executable, *args = command.args or [""]
|
|
1268
|
+
if executable in MAVEN_EXECUTABLES:
|
|
1269
|
+
kept: list[str] = []
|
|
1270
|
+
project_dir = directory
|
|
1271
|
+
index = 0
|
|
1272
|
+
while index < len(args):
|
|
1273
|
+
arg = args[index]
|
|
1274
|
+
if arg in {"-B", "--batch-mode"}:
|
|
1275
|
+
index += 1
|
|
1276
|
+
continue
|
|
1277
|
+
if arg in {"-f", "--file"} and index + 1 < len(args):
|
|
1278
|
+
pom = PurePosixPath(args[index + 1])
|
|
1279
|
+
if pom.name != "pom.xml":
|
|
1280
|
+
# Un -f vers un autre fichier laisse la commande telle quelle.
|
|
1281
|
+
kept, project_dir = list(args), directory
|
|
1282
|
+
break
|
|
1283
|
+
project_dir = directory / pom.parent
|
|
1284
|
+
index += 2
|
|
1285
|
+
continue
|
|
1286
|
+
kept.append(arg)
|
|
1287
|
+
index += 1
|
|
1288
|
+
args, directory = kept, project_dir
|
|
1289
|
+
elif executable == "npm":
|
|
1290
|
+
kept = []
|
|
1291
|
+
index = 0
|
|
1292
|
+
while index < len(args):
|
|
1293
|
+
if args[index] == "--prefix" and index + 1 < len(args):
|
|
1294
|
+
directory = directory / args[index + 1]
|
|
1295
|
+
index += 2
|
|
1296
|
+
continue
|
|
1297
|
+
kept.append(args[index])
|
|
1298
|
+
index += 1
|
|
1299
|
+
args = kept
|
|
1300
|
+
return executable, tuple(args), PurePosixPath(directory.as_posix()).as_posix()
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
@dataclass(frozen=True)
|
|
1304
|
+
class CoveredCommand:
|
|
1305
|
+
"""Commande ecartee parce qu'une commande equivalente gardee la couvre."""
|
|
1306
|
+
|
|
1307
|
+
command: ValidationCommand
|
|
1308
|
+
coveredBy: str
|
|
1309
|
+
|
|
1310
|
+
@property
|
|
1311
|
+
def blocking(self) -> bool:
|
|
1312
|
+
return self.command.blocking
|
|
1313
|
+
|
|
1314
|
+
def to_dict(self) -> dict:
|
|
1315
|
+
return {
|
|
1316
|
+
"id": self.command.id,
|
|
1317
|
+
"command": redact_command(self.command.args),
|
|
1318
|
+
"workingDirectory": self.command.working_directory,
|
|
1319
|
+
"coveredBy": self.coveredBy,
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
def deduplicate_commands(
|
|
1324
|
+
lists: list[list[ValidationCommand]], planned_prefix: str
|
|
1325
|
+
) -> tuple[list[list[ValidationCommand]], list[list[CoveredCommand]]]:
|
|
1326
|
+
"""Garde une commande par forme normalisee sur l'ensemble des listes.
|
|
1327
|
+
|
|
1328
|
+
La derniere liste est celle des controles proteges. Ordre de garde : controle
|
|
1329
|
+
protege, puis commande du plan, puis commande automatique ; a rang egal, la
|
|
1330
|
+
premiere rencontree. Une commande non bloquante ne couvre jamais une bloquante.
|
|
1331
|
+
La commande gardee recoit le delai le plus long des commandes qu'elle couvre.
|
|
1332
|
+
"""
|
|
1333
|
+
protected = len(lists) - 1
|
|
1334
|
+
entries = [
|
|
1335
|
+
(list_index, position, command)
|
|
1336
|
+
for list_index, items in enumerate(lists)
|
|
1337
|
+
for position, command in enumerate(items)
|
|
1338
|
+
]
|
|
1339
|
+
|
|
1340
|
+
def rank(entry: tuple[int, int, ValidationCommand]) -> int:
|
|
1341
|
+
if entry[0] == protected:
|
|
1342
|
+
return 0
|
|
1343
|
+
return 1 if entry[2].id.startswith(f"{planned_prefix}-") else 2
|
|
1344
|
+
|
|
1345
|
+
groups: dict[tuple[str, tuple[str, ...], str], list] = {}
|
|
1346
|
+
for entry in entries:
|
|
1347
|
+
groups.setdefault(normalized_command(entry[2]), []).append(entry)
|
|
1348
|
+
kept: dict[tuple[int, int], ValidationCommand] = {}
|
|
1349
|
+
covered: list[list[CoveredCommand]] = [[] for _ in lists]
|
|
1350
|
+
for members in groups.values():
|
|
1351
|
+
remaining = list(members)
|
|
1352
|
+
while remaining:
|
|
1353
|
+
keeper = min(remaining, key=rank)
|
|
1354
|
+
covers = [
|
|
1355
|
+
entry
|
|
1356
|
+
for entry in remaining
|
|
1357
|
+
if entry is not keeper and (keeper[2].blocking or not entry[2].blocking)
|
|
1358
|
+
]
|
|
1359
|
+
timeout = max(entry[2].timeout for entry in [keeper, *covers])
|
|
1360
|
+
kept[keeper[:2]] = replace(keeper[2], timeout=timeout)
|
|
1361
|
+
for entry in covers:
|
|
1362
|
+
covered[entry[0]].append(CoveredCommand(entry[2], keeper[2].id))
|
|
1363
|
+
remaining = [
|
|
1364
|
+
entry for entry in remaining if entry is not keeper and entry not in covers
|
|
1365
|
+
]
|
|
1366
|
+
kept_lists = [
|
|
1367
|
+
[
|
|
1368
|
+
kept[(list_index, position)]
|
|
1369
|
+
for position in range(len(items))
|
|
1370
|
+
if (list_index, position) in kept
|
|
1371
|
+
]
|
|
1372
|
+
for list_index, items in enumerate(lists)
|
|
1373
|
+
]
|
|
1374
|
+
return kept_lists, covered
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
def _keeper_results(
|
|
1378
|
+
covered: list[CoveredCommand], results_by_id: dict[str, VerificationResult]
|
|
1379
|
+
) -> list[VerificationResult]:
|
|
1380
|
+
"""Resultat de la commande gardee, porte au caractere bloquant de la commande couverte."""
|
|
1381
|
+
return [
|
|
1382
|
+
replace(results_by_id[item.coveredBy], blocking=item.blocking)
|
|
1383
|
+
for item in covered
|
|
1384
|
+
]
|
|
1385
|
+
|
|
1386
|
+
|
|
1387
|
+
def _with_keepers(
|
|
1388
|
+
results: list[VerificationResult], keepers: list[VerificationResult]
|
|
1389
|
+
) -> list[VerificationResult]:
|
|
1390
|
+
"""Resultats d'une liste completes des commandes gardees qui couvrent ses commandes."""
|
|
1391
|
+
seen = {result.id for result in results}
|
|
1392
|
+
merged = list(results)
|
|
1393
|
+
for result in keepers:
|
|
1394
|
+
if result.id not in seen:
|
|
1395
|
+
seen.add(result.id)
|
|
1396
|
+
merged.append(result)
|
|
1397
|
+
return merged
|
|
1398
|
+
|
|
1399
|
+
|
|
965
1400
|
def _failures(results: list[VerificationResult]) -> tuple[VerificationFailure, ...]:
|
|
966
1401
|
return tuple(
|
|
967
1402
|
VerificationFailure(result.id, result.returncode, result.timed_out)
|
devflow_cli/core/verification.py
CHANGED
|
@@ -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
|
-
|
|
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] = (),
|
devflow_cli/core/worklog.py
CHANGED
|
@@ -335,6 +335,16 @@ def _verification_lines(
|
|
|
335
335
|
lines.append(
|
|
336
336
|
f" - `{rendered}` → code `{command.get('returncode', 'inconnu')}`{qualifier}"
|
|
337
337
|
)
|
|
338
|
+
covered = targeted.get("coveredCommands", []) if targeted else []
|
|
339
|
+
if isinstance(covered, list):
|
|
340
|
+
for item in covered:
|
|
341
|
+
if not isinstance(item, dict):
|
|
342
|
+
continue
|
|
343
|
+
args = item.get("command", [])
|
|
344
|
+
rendered = " ".join(args) if isinstance(args, list) else str(args)
|
|
345
|
+
lines.append(
|
|
346
|
+
f" - `{rendered}` → couverte par `{item.get('coveredBy', 'inconnu')}`"
|
|
347
|
+
)
|
|
338
348
|
findings = inspection.get("findings", []) if inspection else []
|
|
339
349
|
if isinstance(findings, list):
|
|
340
350
|
lines.extend(f" - Constat : {item}" for item in findings if isinstance(item, str))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: devflow-cli
|
|
3
|
-
Version: 11.
|
|
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=
|
|
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=
|
|
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=
|
|
19
|
-
devflow_cli/core/activity_contracts.py,sha256=
|
|
18
|
+
devflow_cli/core/activity_base.py,sha256=2VXq2SkBVhRYyEKAXLLpQQUJn3UygkTiNjzLvHfSI1Y,20495
|
|
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=
|
|
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,9 +41,9 @@ 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=
|
|
44
|
+
devflow_cli/core/verification.py,sha256=hQh3gDnOlKONeCy3pfWo6kBBQpIbZIY0asuikH4sN74,21449
|
|
45
45
|
devflow_cli/core/waivers.py,sha256=0w38Osjr69mDT6Lsn0ljkaq6bbggVejuhqiOnYHabs4,5586
|
|
46
|
-
devflow_cli/core/worklog.py,sha256=
|
|
46
|
+
devflow_cli/core/worklog.py,sha256=WPvK0D8b0DBOmnjEoKVum8_EtYR3DjTz7e2p9bulFzk,17577
|
|
47
47
|
devflow_cli/core/worktree_snapshot.py,sha256=ESNWFJN8fZ7NKeDdEKHZq9f9V_2wv-3Z6dlWusu9oH4,6034
|
|
48
48
|
devflow_cli/schemas/activity-contract-v4.schema.json,sha256=IeduWDiJ5IV6EL7FDZWnHBjzyUt1uwig2rB-SMbcpOU,2006
|
|
49
49
|
devflow_cli/schemas/activity-result-v2.schema.json,sha256=2yDf6S--mlNWMxE8h8ruwTsM3Tnaa96SJDjluc4ePbI,2772
|
|
@@ -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.
|
|
62
|
-
devflow_cli-11.
|
|
63
|
-
devflow_cli-11.
|
|
64
|
-
devflow_cli-11.
|
|
65
|
-
devflow_cli-11.
|
|
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,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|