foundry-mcp 0.3.3__py3-none-any.whl → 0.7.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.
- foundry_mcp/__init__.py +7 -1
- foundry_mcp/cli/commands/plan.py +10 -3
- foundry_mcp/cli/commands/review.py +19 -4
- foundry_mcp/cli/commands/specs.py +38 -208
- foundry_mcp/cli/output.py +3 -3
- foundry_mcp/config.py +235 -5
- foundry_mcp/core/ai_consultation.py +146 -9
- foundry_mcp/core/discovery.py +6 -6
- foundry_mcp/core/error_store.py +2 -2
- foundry_mcp/core/intake.py +933 -0
- foundry_mcp/core/llm_config.py +20 -2
- foundry_mcp/core/metrics_store.py +2 -2
- foundry_mcp/core/progress.py +70 -0
- foundry_mcp/core/prompts/fidelity_review.py +149 -4
- foundry_mcp/core/prompts/markdown_plan_review.py +5 -1
- foundry_mcp/core/prompts/plan_review.py +5 -1
- foundry_mcp/core/providers/claude.py +6 -47
- foundry_mcp/core/providers/codex.py +6 -57
- foundry_mcp/core/providers/cursor_agent.py +3 -44
- foundry_mcp/core/providers/gemini.py +6 -57
- foundry_mcp/core/providers/opencode.py +35 -5
- foundry_mcp/core/research/__init__.py +68 -0
- foundry_mcp/core/research/memory.py +425 -0
- foundry_mcp/core/research/models.py +437 -0
- foundry_mcp/core/research/workflows/__init__.py +22 -0
- foundry_mcp/core/research/workflows/base.py +204 -0
- foundry_mcp/core/research/workflows/chat.py +271 -0
- foundry_mcp/core/research/workflows/consensus.py +396 -0
- foundry_mcp/core/research/workflows/ideate.py +682 -0
- foundry_mcp/core/research/workflows/thinkdeep.py +405 -0
- foundry_mcp/core/responses.py +450 -0
- foundry_mcp/core/spec.py +2438 -236
- foundry_mcp/core/task.py +1064 -19
- foundry_mcp/core/testing.py +512 -123
- foundry_mcp/core/validation.py +313 -42
- foundry_mcp/dashboard/components/charts.py +0 -57
- foundry_mcp/dashboard/launcher.py +11 -0
- foundry_mcp/dashboard/views/metrics.py +25 -35
- foundry_mcp/dashboard/views/overview.py +1 -65
- foundry_mcp/resources/specs.py +25 -25
- foundry_mcp/schemas/intake-schema.json +89 -0
- foundry_mcp/schemas/sdd-spec-schema.json +33 -5
- foundry_mcp/server.py +38 -0
- foundry_mcp/tools/unified/__init__.py +4 -2
- foundry_mcp/tools/unified/authoring.py +2423 -267
- foundry_mcp/tools/unified/documentation_helpers.py +69 -6
- foundry_mcp/tools/unified/environment.py +235 -6
- foundry_mcp/tools/unified/error.py +18 -1
- foundry_mcp/tools/unified/lifecycle.py +8 -0
- foundry_mcp/tools/unified/plan.py +113 -1
- foundry_mcp/tools/unified/research.py +658 -0
- foundry_mcp/tools/unified/review.py +370 -16
- foundry_mcp/tools/unified/spec.py +367 -0
- foundry_mcp/tools/unified/task.py +1163 -48
- foundry_mcp/tools/unified/test.py +69 -8
- {foundry_mcp-0.3.3.dist-info → foundry_mcp-0.7.0.dist-info}/METADATA +7 -1
- {foundry_mcp-0.3.3.dist-info → foundry_mcp-0.7.0.dist-info}/RECORD +60 -48
- {foundry_mcp-0.3.3.dist-info → foundry_mcp-0.7.0.dist-info}/WHEEL +0 -0
- {foundry_mcp-0.3.3.dist-info → foundry_mcp-0.7.0.dist-info}/entry_points.txt +0 -0
- {foundry_mcp-0.3.3.dist-info → foundry_mcp-0.7.0.dist-info}/licenses/LICENSE +0 -0
foundry_mcp/core/responses.py
CHANGED
|
@@ -113,14 +113,23 @@ class ErrorCode(str, Enum):
|
|
|
113
113
|
VALIDATION_ERROR = "VALIDATION_ERROR"
|
|
114
114
|
INVALID_FORMAT = "INVALID_FORMAT"
|
|
115
115
|
MISSING_REQUIRED = "MISSING_REQUIRED"
|
|
116
|
+
INVALID_PARENT = "INVALID_PARENT"
|
|
117
|
+
INVALID_POSITION = "INVALID_POSITION"
|
|
118
|
+
INVALID_REGEX_PATTERN = "INVALID_REGEX_PATTERN"
|
|
119
|
+
PATTERN_TOO_BROAD = "PATTERN_TOO_BROAD"
|
|
116
120
|
|
|
117
121
|
# Resource errors
|
|
118
122
|
NOT_FOUND = "NOT_FOUND"
|
|
119
123
|
SPEC_NOT_FOUND = "SPEC_NOT_FOUND"
|
|
120
124
|
TASK_NOT_FOUND = "TASK_NOT_FOUND"
|
|
121
125
|
PHASE_NOT_FOUND = "PHASE_NOT_FOUND"
|
|
126
|
+
DEPENDENCY_NOT_FOUND = "DEPENDENCY_NOT_FOUND"
|
|
127
|
+
BACKUP_NOT_FOUND = "BACKUP_NOT_FOUND"
|
|
128
|
+
NO_MATCHES_FOUND = "NO_MATCHES_FOUND"
|
|
122
129
|
DUPLICATE_ENTRY = "DUPLICATE_ENTRY"
|
|
123
130
|
CONFLICT = "CONFLICT"
|
|
131
|
+
CIRCULAR_DEPENDENCY = "CIRCULAR_DEPENDENCY"
|
|
132
|
+
SELF_REFERENCE = "SELF_REFERENCE"
|
|
124
133
|
|
|
125
134
|
# Access errors
|
|
126
135
|
UNAUTHORIZED = "UNAUTHORIZED"
|
|
@@ -131,6 +140,10 @@ class ErrorCode(str, Enum):
|
|
|
131
140
|
# System errors
|
|
132
141
|
INTERNAL_ERROR = "INTERNAL_ERROR"
|
|
133
142
|
UNAVAILABLE = "UNAVAILABLE"
|
|
143
|
+
RESOURCE_BUSY = "RESOURCE_BUSY"
|
|
144
|
+
BACKUP_CORRUPTED = "BACKUP_CORRUPTED"
|
|
145
|
+
ROLLBACK_FAILED = "ROLLBACK_FAILED"
|
|
146
|
+
COMPARISON_FAILED = "COMPARISON_FAILED"
|
|
134
147
|
|
|
135
148
|
# AI/LLM Provider errors
|
|
136
149
|
AI_NO_PROVIDER = "AI_NO_PROVIDER"
|
|
@@ -604,6 +617,443 @@ def unavailable_error(
|
|
|
604
617
|
)
|
|
605
618
|
|
|
606
619
|
|
|
620
|
+
# ---------------------------------------------------------------------------
|
|
621
|
+
# Spec Modification Error Helpers
|
|
622
|
+
# ---------------------------------------------------------------------------
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
def circular_dependency_error(
|
|
626
|
+
task_id: str,
|
|
627
|
+
target_id: str,
|
|
628
|
+
*,
|
|
629
|
+
cycle_path: Optional[Sequence[str]] = None,
|
|
630
|
+
remediation: Optional[str] = None,
|
|
631
|
+
request_id: Optional[str] = None,
|
|
632
|
+
) -> ToolResponse:
|
|
633
|
+
"""Create an error response for circular dependency detection.
|
|
634
|
+
|
|
635
|
+
Use when a move or dependency operation would create a cycle.
|
|
636
|
+
|
|
637
|
+
Args:
|
|
638
|
+
task_id: The task being moved or modified.
|
|
639
|
+
target_id: The target parent or dependency that would create a cycle.
|
|
640
|
+
cycle_path: Optional sequence showing the dependency cycle path.
|
|
641
|
+
remediation: Guidance on how to resolve.
|
|
642
|
+
request_id: Correlation identifier.
|
|
643
|
+
|
|
644
|
+
Example:
|
|
645
|
+
>>> circular_dependency_error("task-3", "task-1", cycle_path=["task-1", "task-2", "task-3"])
|
|
646
|
+
"""
|
|
647
|
+
data: Dict[str, Any] = {
|
|
648
|
+
"task_id": task_id,
|
|
649
|
+
"target_id": target_id,
|
|
650
|
+
}
|
|
651
|
+
if cycle_path:
|
|
652
|
+
data["cycle_path"] = list(cycle_path)
|
|
653
|
+
|
|
654
|
+
return error_response(
|
|
655
|
+
f"Circular dependency detected: {task_id} cannot depend on {target_id}",
|
|
656
|
+
error_code=ErrorCode.CIRCULAR_DEPENDENCY,
|
|
657
|
+
error_type=ErrorType.CONFLICT,
|
|
658
|
+
data=data,
|
|
659
|
+
remediation=remediation
|
|
660
|
+
or "Remove an existing dependency to break the cycle before adding this one.",
|
|
661
|
+
request_id=request_id,
|
|
662
|
+
)
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
def invalid_parent_error(
|
|
666
|
+
task_id: str,
|
|
667
|
+
target_parent: str,
|
|
668
|
+
reason: str,
|
|
669
|
+
*,
|
|
670
|
+
valid_parents: Optional[Sequence[str]] = None,
|
|
671
|
+
remediation: Optional[str] = None,
|
|
672
|
+
request_id: Optional[str] = None,
|
|
673
|
+
) -> ToolResponse:
|
|
674
|
+
"""Create an error response for invalid parent in move operation.
|
|
675
|
+
|
|
676
|
+
Use when a task cannot be moved to the specified parent.
|
|
677
|
+
|
|
678
|
+
Args:
|
|
679
|
+
task_id: The task being moved.
|
|
680
|
+
target_parent: The invalid target parent.
|
|
681
|
+
reason: Why the parent is invalid (e.g., "is a task, not a phase").
|
|
682
|
+
valid_parents: Optional list of valid parent IDs.
|
|
683
|
+
remediation: Guidance on how to resolve.
|
|
684
|
+
request_id: Correlation identifier.
|
|
685
|
+
|
|
686
|
+
Example:
|
|
687
|
+
>>> invalid_parent_error("task-3-1", "task-2-1", "target is a task, not a phase")
|
|
688
|
+
"""
|
|
689
|
+
data: Dict[str, Any] = {
|
|
690
|
+
"task_id": task_id,
|
|
691
|
+
"target_parent": target_parent,
|
|
692
|
+
"reason": reason,
|
|
693
|
+
}
|
|
694
|
+
if valid_parents:
|
|
695
|
+
data["valid_parents"] = list(valid_parents)
|
|
696
|
+
|
|
697
|
+
return error_response(
|
|
698
|
+
f"Invalid parent '{target_parent}' for task '{task_id}': {reason}",
|
|
699
|
+
error_code=ErrorCode.INVALID_PARENT,
|
|
700
|
+
error_type=ErrorType.VALIDATION,
|
|
701
|
+
data=data,
|
|
702
|
+
remediation=remediation or "Specify a valid phase or parent task as the target.",
|
|
703
|
+
request_id=request_id,
|
|
704
|
+
)
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
def self_reference_error(
|
|
708
|
+
task_id: str,
|
|
709
|
+
operation: str,
|
|
710
|
+
*,
|
|
711
|
+
remediation: Optional[str] = None,
|
|
712
|
+
request_id: Optional[str] = None,
|
|
713
|
+
) -> ToolResponse:
|
|
714
|
+
"""Create an error response for self-referencing operations.
|
|
715
|
+
|
|
716
|
+
Use when a task references itself in dependencies or move operations.
|
|
717
|
+
|
|
718
|
+
Args:
|
|
719
|
+
task_id: The task that references itself.
|
|
720
|
+
operation: The operation attempted (e.g., "add-dependency", "move").
|
|
721
|
+
remediation: Guidance on how to resolve.
|
|
722
|
+
request_id: Correlation identifier.
|
|
723
|
+
|
|
724
|
+
Example:
|
|
725
|
+
>>> self_reference_error("task-1-1", "add-dependency")
|
|
726
|
+
"""
|
|
727
|
+
return error_response(
|
|
728
|
+
f"Task '{task_id}' cannot reference itself in {operation}",
|
|
729
|
+
error_code=ErrorCode.SELF_REFERENCE,
|
|
730
|
+
error_type=ErrorType.VALIDATION,
|
|
731
|
+
data={"task_id": task_id, "operation": operation},
|
|
732
|
+
remediation=remediation or "Specify a different task ID as the target.",
|
|
733
|
+
request_id=request_id,
|
|
734
|
+
)
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
def dependency_not_found_error(
|
|
738
|
+
task_id: str,
|
|
739
|
+
dependency_id: str,
|
|
740
|
+
*,
|
|
741
|
+
remediation: Optional[str] = None,
|
|
742
|
+
request_id: Optional[str] = None,
|
|
743
|
+
) -> ToolResponse:
|
|
744
|
+
"""Create an error response for missing dependency in remove operation.
|
|
745
|
+
|
|
746
|
+
Use when trying to remove a dependency that doesn't exist.
|
|
747
|
+
|
|
748
|
+
Args:
|
|
749
|
+
task_id: The task being modified.
|
|
750
|
+
dependency_id: The dependency that wasn't found.
|
|
751
|
+
remediation: Guidance on how to resolve.
|
|
752
|
+
request_id: Correlation identifier.
|
|
753
|
+
|
|
754
|
+
Example:
|
|
755
|
+
>>> dependency_not_found_error("task-1-1", "task-2-1")
|
|
756
|
+
"""
|
|
757
|
+
return error_response(
|
|
758
|
+
f"Dependency '{dependency_id}' not found on task '{task_id}'",
|
|
759
|
+
error_code=ErrorCode.DEPENDENCY_NOT_FOUND,
|
|
760
|
+
error_type=ErrorType.NOT_FOUND,
|
|
761
|
+
data={"task_id": task_id, "dependency_id": dependency_id},
|
|
762
|
+
remediation=remediation
|
|
763
|
+
or "Check existing dependencies using task info before removing.",
|
|
764
|
+
request_id=request_id,
|
|
765
|
+
)
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
def invalid_position_error(
|
|
769
|
+
item_id: str,
|
|
770
|
+
position: int,
|
|
771
|
+
max_position: int,
|
|
772
|
+
*,
|
|
773
|
+
remediation: Optional[str] = None,
|
|
774
|
+
request_id: Optional[str] = None,
|
|
775
|
+
) -> ToolResponse:
|
|
776
|
+
"""Create an error response for invalid position in move/reorder operation.
|
|
777
|
+
|
|
778
|
+
Use when the specified position is out of valid range.
|
|
779
|
+
|
|
780
|
+
Args:
|
|
781
|
+
item_id: The item being moved (phase or task ID).
|
|
782
|
+
position: The invalid position specified.
|
|
783
|
+
max_position: The maximum valid position.
|
|
784
|
+
remediation: Guidance on how to resolve.
|
|
785
|
+
request_id: Correlation identifier.
|
|
786
|
+
|
|
787
|
+
Example:
|
|
788
|
+
>>> invalid_position_error("phase-3", 10, 5)
|
|
789
|
+
"""
|
|
790
|
+
return error_response(
|
|
791
|
+
f"Invalid position {position} for '{item_id}': must be 1-{max_position}",
|
|
792
|
+
error_code=ErrorCode.INVALID_POSITION,
|
|
793
|
+
error_type=ErrorType.VALIDATION,
|
|
794
|
+
data={
|
|
795
|
+
"item_id": item_id,
|
|
796
|
+
"position": position,
|
|
797
|
+
"max_position": max_position,
|
|
798
|
+
"valid_range": f"1-{max_position}",
|
|
799
|
+
},
|
|
800
|
+
remediation=remediation or f"Specify a position between 1 and {max_position}.",
|
|
801
|
+
request_id=request_id,
|
|
802
|
+
)
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
def invalid_regex_error(
|
|
806
|
+
pattern: str,
|
|
807
|
+
error_detail: str,
|
|
808
|
+
*,
|
|
809
|
+
remediation: Optional[str] = None,
|
|
810
|
+
request_id: Optional[str] = None,
|
|
811
|
+
) -> ToolResponse:
|
|
812
|
+
"""Create an error response for invalid regex pattern.
|
|
813
|
+
|
|
814
|
+
Use when a find/replace pattern is not valid regex.
|
|
815
|
+
|
|
816
|
+
Args:
|
|
817
|
+
pattern: The invalid regex pattern.
|
|
818
|
+
error_detail: The regex error message.
|
|
819
|
+
remediation: Guidance on how to fix the pattern.
|
|
820
|
+
request_id: Correlation identifier.
|
|
821
|
+
|
|
822
|
+
Example:
|
|
823
|
+
>>> invalid_regex_error("[unclosed", "unterminated character set")
|
|
824
|
+
"""
|
|
825
|
+
return error_response(
|
|
826
|
+
f"Invalid regex pattern: {error_detail}",
|
|
827
|
+
error_code=ErrorCode.INVALID_REGEX_PATTERN,
|
|
828
|
+
error_type=ErrorType.VALIDATION,
|
|
829
|
+
data={"pattern": pattern, "error_detail": error_detail},
|
|
830
|
+
remediation=remediation
|
|
831
|
+
or "Check regex syntax. Use raw strings and escape special characters.",
|
|
832
|
+
request_id=request_id,
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
def pattern_too_broad_error(
|
|
837
|
+
pattern: str,
|
|
838
|
+
match_count: int,
|
|
839
|
+
max_matches: int,
|
|
840
|
+
*,
|
|
841
|
+
remediation: Optional[str] = None,
|
|
842
|
+
request_id: Optional[str] = None,
|
|
843
|
+
) -> ToolResponse:
|
|
844
|
+
"""Create an error response for overly broad patterns.
|
|
845
|
+
|
|
846
|
+
Use when a find/replace pattern matches too many items.
|
|
847
|
+
|
|
848
|
+
Args:
|
|
849
|
+
pattern: The pattern that matched too broadly.
|
|
850
|
+
match_count: Number of matches found.
|
|
851
|
+
max_matches: Maximum allowed matches.
|
|
852
|
+
remediation: Guidance on how to narrow the pattern.
|
|
853
|
+
request_id: Correlation identifier.
|
|
854
|
+
|
|
855
|
+
Example:
|
|
856
|
+
>>> pattern_too_broad_error(".*", 500, 100)
|
|
857
|
+
"""
|
|
858
|
+
return error_response(
|
|
859
|
+
f"Pattern too broad: {match_count} matches exceeds limit of {max_matches}",
|
|
860
|
+
error_code=ErrorCode.PATTERN_TOO_BROAD,
|
|
861
|
+
error_type=ErrorType.VALIDATION,
|
|
862
|
+
data={
|
|
863
|
+
"pattern": pattern,
|
|
864
|
+
"match_count": match_count,
|
|
865
|
+
"max_matches": max_matches,
|
|
866
|
+
},
|
|
867
|
+
remediation=remediation
|
|
868
|
+
or "Use a more specific pattern or apply to a narrower scope.",
|
|
869
|
+
request_id=request_id,
|
|
870
|
+
)
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
def no_matches_error(
|
|
874
|
+
pattern: str,
|
|
875
|
+
scope: str,
|
|
876
|
+
*,
|
|
877
|
+
remediation: Optional[str] = None,
|
|
878
|
+
request_id: Optional[str] = None,
|
|
879
|
+
) -> ToolResponse:
|
|
880
|
+
"""Create an error response for patterns with no matches.
|
|
881
|
+
|
|
882
|
+
Use when a find/replace pattern matches nothing.
|
|
883
|
+
|
|
884
|
+
Args:
|
|
885
|
+
pattern: The pattern that found no matches.
|
|
886
|
+
scope: Where the search was performed (e.g., "spec", "phase-1").
|
|
887
|
+
remediation: Guidance on what to check.
|
|
888
|
+
request_id: Correlation identifier.
|
|
889
|
+
|
|
890
|
+
Example:
|
|
891
|
+
>>> no_matches_error("deprecated_function", "spec my-spec-001")
|
|
892
|
+
"""
|
|
893
|
+
return error_response(
|
|
894
|
+
f"No matches found for pattern '{pattern}' in {scope}",
|
|
895
|
+
error_code=ErrorCode.NO_MATCHES_FOUND,
|
|
896
|
+
error_type=ErrorType.NOT_FOUND,
|
|
897
|
+
data={"pattern": pattern, "scope": scope},
|
|
898
|
+
remediation=remediation
|
|
899
|
+
or "Verify the pattern and scope. Use dry-run to preview matches.",
|
|
900
|
+
request_id=request_id,
|
|
901
|
+
)
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
def backup_not_found_error(
|
|
905
|
+
spec_id: str,
|
|
906
|
+
backup_id: Optional[str] = None,
|
|
907
|
+
*,
|
|
908
|
+
available_backups: Optional[Sequence[str]] = None,
|
|
909
|
+
remediation: Optional[str] = None,
|
|
910
|
+
request_id: Optional[str] = None,
|
|
911
|
+
) -> ToolResponse:
|
|
912
|
+
"""Create an error response for missing backup.
|
|
913
|
+
|
|
914
|
+
Use when a rollback or diff references a non-existent backup.
|
|
915
|
+
|
|
916
|
+
Args:
|
|
917
|
+
spec_id: The spec whose backup is missing.
|
|
918
|
+
backup_id: The specific backup ID that wasn't found.
|
|
919
|
+
available_backups: Optional list of available backup IDs.
|
|
920
|
+
remediation: Guidance on how to resolve.
|
|
921
|
+
request_id: Correlation identifier.
|
|
922
|
+
|
|
923
|
+
Example:
|
|
924
|
+
>>> backup_not_found_error("my-spec-001", "backup-2024-01-15")
|
|
925
|
+
"""
|
|
926
|
+
data: Dict[str, Any] = {"spec_id": spec_id}
|
|
927
|
+
if backup_id:
|
|
928
|
+
data["backup_id"] = backup_id
|
|
929
|
+
if available_backups:
|
|
930
|
+
data["available_backups"] = list(available_backups)
|
|
931
|
+
|
|
932
|
+
message = f"Backup not found for spec '{spec_id}'"
|
|
933
|
+
if backup_id:
|
|
934
|
+
message = f"Backup '{backup_id}' not found for spec '{spec_id}'"
|
|
935
|
+
|
|
936
|
+
return error_response(
|
|
937
|
+
message,
|
|
938
|
+
error_code=ErrorCode.BACKUP_NOT_FOUND,
|
|
939
|
+
error_type=ErrorType.NOT_FOUND,
|
|
940
|
+
data=data,
|
|
941
|
+
remediation=remediation or "List available backups using spec action='history'.",
|
|
942
|
+
request_id=request_id,
|
|
943
|
+
)
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
def backup_corrupted_error(
|
|
947
|
+
spec_id: str,
|
|
948
|
+
backup_id: str,
|
|
949
|
+
error_detail: str,
|
|
950
|
+
*,
|
|
951
|
+
remediation: Optional[str] = None,
|
|
952
|
+
request_id: Optional[str] = None,
|
|
953
|
+
) -> ToolResponse:
|
|
954
|
+
"""Create an error response for corrupted backup.
|
|
955
|
+
|
|
956
|
+
Use when a backup file exists but cannot be loaded.
|
|
957
|
+
|
|
958
|
+
Args:
|
|
959
|
+
spec_id: The spec whose backup is corrupted.
|
|
960
|
+
backup_id: The corrupted backup identifier.
|
|
961
|
+
error_detail: Description of the corruption.
|
|
962
|
+
remediation: Guidance on how to recover.
|
|
963
|
+
request_id: Correlation identifier.
|
|
964
|
+
|
|
965
|
+
Example:
|
|
966
|
+
>>> backup_corrupted_error("my-spec", "backup-001", "Invalid JSON structure")
|
|
967
|
+
"""
|
|
968
|
+
return error_response(
|
|
969
|
+
f"Backup '{backup_id}' for spec '{spec_id}' is corrupted: {error_detail}",
|
|
970
|
+
error_code=ErrorCode.BACKUP_CORRUPTED,
|
|
971
|
+
error_type=ErrorType.INTERNAL,
|
|
972
|
+
data={
|
|
973
|
+
"spec_id": spec_id,
|
|
974
|
+
"backup_id": backup_id,
|
|
975
|
+
"error_detail": error_detail,
|
|
976
|
+
},
|
|
977
|
+
remediation=remediation
|
|
978
|
+
or "Try an earlier backup or restore from version control.",
|
|
979
|
+
request_id=request_id,
|
|
980
|
+
)
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
def rollback_failed_error(
|
|
984
|
+
spec_id: str,
|
|
985
|
+
backup_id: str,
|
|
986
|
+
error_detail: str,
|
|
987
|
+
*,
|
|
988
|
+
remediation: Optional[str] = None,
|
|
989
|
+
request_id: Optional[str] = None,
|
|
990
|
+
) -> ToolResponse:
|
|
991
|
+
"""Create an error response for failed rollback operation.
|
|
992
|
+
|
|
993
|
+
Use when a rollback operation fails after starting.
|
|
994
|
+
|
|
995
|
+
Args:
|
|
996
|
+
spec_id: The spec being rolled back.
|
|
997
|
+
backup_id: The backup being restored from.
|
|
998
|
+
error_detail: What went wrong during rollback.
|
|
999
|
+
remediation: Guidance on how to recover.
|
|
1000
|
+
request_id: Correlation identifier.
|
|
1001
|
+
|
|
1002
|
+
Example:
|
|
1003
|
+
>>> rollback_failed_error("my-spec", "backup-001", "Write permission denied")
|
|
1004
|
+
"""
|
|
1005
|
+
return error_response(
|
|
1006
|
+
f"Rollback failed for spec '{spec_id}' from backup '{backup_id}': {error_detail}",
|
|
1007
|
+
error_code=ErrorCode.ROLLBACK_FAILED,
|
|
1008
|
+
error_type=ErrorType.INTERNAL,
|
|
1009
|
+
data={
|
|
1010
|
+
"spec_id": spec_id,
|
|
1011
|
+
"backup_id": backup_id,
|
|
1012
|
+
"error_detail": error_detail,
|
|
1013
|
+
},
|
|
1014
|
+
remediation=remediation
|
|
1015
|
+
or "Check file permissions. A safety backup was created before rollback attempt.",
|
|
1016
|
+
request_id=request_id,
|
|
1017
|
+
)
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
def comparison_failed_error(
|
|
1021
|
+
source: str,
|
|
1022
|
+
target: str,
|
|
1023
|
+
error_detail: str,
|
|
1024
|
+
*,
|
|
1025
|
+
remediation: Optional[str] = None,
|
|
1026
|
+
request_id: Optional[str] = None,
|
|
1027
|
+
) -> ToolResponse:
|
|
1028
|
+
"""Create an error response for failed diff/comparison operation.
|
|
1029
|
+
|
|
1030
|
+
Use when a spec comparison operation fails.
|
|
1031
|
+
|
|
1032
|
+
Args:
|
|
1033
|
+
source: The source spec or backup being compared.
|
|
1034
|
+
target: The target spec or backup being compared.
|
|
1035
|
+
error_detail: What went wrong during comparison.
|
|
1036
|
+
remediation: Guidance on how to resolve.
|
|
1037
|
+
request_id: Correlation identifier.
|
|
1038
|
+
|
|
1039
|
+
Example:
|
|
1040
|
+
>>> comparison_failed_error("my-spec-v1", "my-spec-v2", "Schema version mismatch")
|
|
1041
|
+
"""
|
|
1042
|
+
return error_response(
|
|
1043
|
+
f"Comparison failed between '{source}' and '{target}': {error_detail}",
|
|
1044
|
+
error_code=ErrorCode.COMPARISON_FAILED,
|
|
1045
|
+
error_type=ErrorType.INTERNAL,
|
|
1046
|
+
data={
|
|
1047
|
+
"source": source,
|
|
1048
|
+
"target": target,
|
|
1049
|
+
"error_detail": error_detail,
|
|
1050
|
+
},
|
|
1051
|
+
remediation=remediation
|
|
1052
|
+
or "Ensure both specs are valid and use compatible schema versions.",
|
|
1053
|
+
request_id=request_id,
|
|
1054
|
+
)
|
|
1055
|
+
|
|
1056
|
+
|
|
607
1057
|
# ---------------------------------------------------------------------------
|
|
608
1058
|
# AI/LLM Provider Error Helpers
|
|
609
1059
|
# ---------------------------------------------------------------------------
|