multi-agent-platform 0.1.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.
Files changed (144) hide show
  1. cli/__init__.py +0 -0
  2. cli/action_item_escalation.py +177 -0
  3. cli/agent_client.py +554 -0
  4. cli/bridge_state.py +43 -0
  5. cli/commands/__init__.py +13 -0
  6. cli/commands/action.py +142 -0
  7. cli/commands/agent.py +117 -0
  8. cli/commands/audit.py +68 -0
  9. cli/commands/docs.py +179 -0
  10. cli/commands/experiment.py +755 -0
  11. cli/commands/feedback.py +106 -0
  12. cli/commands/notification.py +213 -0
  13. cli/commands/persona.py +63 -0
  14. cli/commands/project.py +87 -0
  15. cli/commands/runtime.py +105 -0
  16. cli/commands/topic.py +361 -0
  17. cli/e2e_collab.py +602 -0
  18. cli/git_checkpoint.py +68 -0
  19. cli/host_worker_types.py +151 -0
  20. cli/main.py +1553 -0
  21. cli/map_command_client.py +497 -0
  22. cli/participant_worker.py +255 -0
  23. cli/reviewer_worker.py +263 -0
  24. cli/runtime/__init__.py +5 -0
  25. cli/runtime/run_lock.py +497 -0
  26. cli/runtime_chat.py +317 -0
  27. cli/session_wake_log.py +235 -0
  28. cli/simple_waker.py +950 -0
  29. cli/table_render.py +113 -0
  30. cli/wake_backend.py +236 -0
  31. cli/worker_cycle_log.py +36 -0
  32. map_client/__init__.py +37 -0
  33. map_client/bootstrap.py +193 -0
  34. map_client/client.py +1045 -0
  35. map_client/config.py +21 -0
  36. map_client/errors.py +283 -0
  37. map_client/exceptions.py +130 -0
  38. map_client/plan_evidence.py +159 -0
  39. map_client/project_config.py +153 -0
  40. map_client/result_template.py +167 -0
  41. map_client/testing.py +27 -0
  42. map_mcp/__init__.py +4 -0
  43. map_mcp/_utils.py +28 -0
  44. map_mcp/auth.py +34 -0
  45. map_mcp/config.py +50 -0
  46. map_mcp/context.py +39 -0
  47. map_mcp/main.py +75 -0
  48. map_mcp/server.py +573 -0
  49. map_mcp/session.py +79 -0
  50. map_sdk/__init__.py +29 -0
  51. map_sdk/evidence.py +68 -0
  52. map_types/__init__.py +203 -0
  53. map_types/enums.py +199 -0
  54. map_types/schemas.py +1351 -0
  55. multi_agent_platform-0.1.0.dist-info/METADATA +298 -0
  56. multi_agent_platform-0.1.0.dist-info/RECORD +144 -0
  57. multi_agent_platform-0.1.0.dist-info/WHEEL +5 -0
  58. multi_agent_platform-0.1.0.dist-info/entry_points.txt +6 -0
  59. multi_agent_platform-0.1.0.dist-info/licenses/LICENSE +21 -0
  60. multi_agent_platform-0.1.0.dist-info/top_level.txt +6 -0
  61. server/__init__.py +0 -0
  62. server/__version__.py +14 -0
  63. server/api/__init__.py +0 -0
  64. server/api/action_items.py +138 -0
  65. server/api/agents.py +412 -0
  66. server/api/audit.py +54 -0
  67. server/api/background_tasks.py +18 -0
  68. server/api/common.py +117 -0
  69. server/api/deps.py +30 -0
  70. server/api/experiments.py +858 -0
  71. server/api/feedback.py +75 -0
  72. server/api/notifications.py +22 -0
  73. server/api/projects.py +209 -0
  74. server/api/router.py +25 -0
  75. server/api/status.py +33 -0
  76. server/api/topics.py +302 -0
  77. server/api/webhooks.py +74 -0
  78. server/auth/__init__.py +8 -0
  79. server/auth/experiment_access.py +66 -0
  80. server/config.py +38 -0
  81. server/db/__init__.py +3 -0
  82. server/db/base.py +5 -0
  83. server/db/deadlock_retry.py +146 -0
  84. server/db/session.py +41 -0
  85. server/domain/__init__.py +3 -0
  86. server/domain/encrypted_types.py +63 -0
  87. server/domain/models.py +713 -0
  88. server/domain/schemas.py +3 -0
  89. server/domain/state_machine.py +79 -0
  90. server/domain/topic_ack_constants.py +9 -0
  91. server/main.py +148 -0
  92. server/scripts/__init__.py +0 -0
  93. server/scripts/migrate_notification_unique.py +231 -0
  94. server/scripts/purge_audit_pollution.py +116 -0
  95. server/services/__init__.py +0 -0
  96. server/services/_lookups.py +26 -0
  97. server/services/acceptance_service.py +90 -0
  98. server/services/action_item_migration_service.py +190 -0
  99. server/services/action_item_service.py +200 -0
  100. server/services/agent_work_service.py +405 -0
  101. server/services/archive_lint_service.py +156 -0
  102. server/services/audit_service.py +457 -0
  103. server/services/auth.py +66 -0
  104. server/services/comment_service.py +173 -0
  105. server/services/errors.py +65 -0
  106. server/services/escalation_resolver.py +248 -0
  107. server/services/evidence_service.py +88 -0
  108. server/services/experiment_capabilities_service.py +277 -0
  109. server/services/inbound_event_service.py +111 -0
  110. server/services/lock_service.py +273 -0
  111. server/services/log_service.py +202 -0
  112. server/services/mention_service.py +730 -0
  113. server/services/notification_service.py +939 -0
  114. server/services/notification_stream.py +138 -0
  115. server/services/permissions.py +147 -0
  116. server/services/persona_activity_service.py +108 -0
  117. server/services/phase_owner_resolver.py +95 -0
  118. server/services/phase_service.py +381 -0
  119. server/services/plan_marker_service.py +235 -0
  120. server/services/plan_service.py +186 -0
  121. server/services/platform_feedback_service.py +114 -0
  122. server/services/project_service.py +534 -0
  123. server/services/project_status_service.py +132 -0
  124. server/services/review_service.py +707 -0
  125. server/services/secret_encryption.py +97 -0
  126. server/services/similarity_service.py +119 -0
  127. server/services/sse_event_schemas.py +17 -0
  128. server/services/status_service.py +68 -0
  129. server/services/template_service.py +134 -0
  130. server/services/text_utils.py +19 -0
  131. server/services/thread_activity.py +180 -0
  132. server/services/todo_persona_filter.py +73 -0
  133. server/services/todo_service.py +604 -0
  134. server/services/topic_ack_service.py +312 -0
  135. server/services/topic_action_item_ops.py +538 -0
  136. server/services/topic_comment_kind.py +14 -0
  137. server/services/topic_comment_service.py +237 -0
  138. server/services/topic_helpers.py +32 -0
  139. server/services/topic_lifecycle_service.py +478 -0
  140. server/services/topic_progress_service.py +40 -0
  141. server/services/topic_resolve_service.py +234 -0
  142. server/services/topic_service.py +102 -0
  143. server/services/topic_work_item_service.py +570 -0
  144. server/services/webhook_service.py +273 -0
map_sdk/evidence.py ADDED
@@ -0,0 +1,68 @@
1
+ """map_sdk.evidence — completion evidence detection.
2
+
3
+ arch experiment (0519e2a3) PR2: move ``metadata_has_completion_evidence``
4
+ + its constants from ``server/services/evidence_service`` here so the
5
+ CLI can ``from map_sdk.evidence import ...`` without dragging the
6
+ server package on its import path.
7
+
8
+ Pure stdlib + dataclass — no SQLAlchemy / FastAPI / server imports.
9
+ CI grep gate asserts ``grep -r "from server" map_sdk/`` is empty.
10
+
11
+ Note: ``validate_log_evidence`` / ``EvidenceValidationResult`` /
12
+ ``EvidenceWarning`` stay in ``server.services.evidence_service`` for
13
+ now — they depend on ``map_client.plan_evidence`` and are only used
14
+ server-side. Moving them is a follow-up PR.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ EVIDENCE_METADATA_KEYS: frozenset[str] = frozenset(
20
+ {
21
+ "alembic_revision",
22
+ "alembic_current",
23
+ "api_health",
24
+ "health",
25
+ "smoke",
26
+ "smoke_result",
27
+ "pytest_summary",
28
+ "test_summary",
29
+ "image_digest",
30
+ "acceptance",
31
+ }
32
+ )
33
+
34
+
35
+ def metadata_has_completion_evidence(metadata: object) -> bool:
36
+ """Return True if ``metadata`` carries any completion evidence.
37
+
38
+ The original lives in ``server.services.evidence_service`` and was
39
+ duplicated as-is in the CLI (``cli/main.py``) and the server
40
+ (``phase_service``, ``acceptance_service``). The semantics:
41
+
42
+ * non-dict → False
43
+ * ``allow_missing_evidence`` True → True (operator override)
44
+ * any EVIDENCE_METADATA_KEYS with non-empty value → True
45
+ * metadata["evidence"] dict with at least one non-empty value → True
46
+ * metadata["evidence"] list with at least one entry → True
47
+ """
48
+ if not isinstance(metadata, dict):
49
+ return False
50
+ if metadata.get("allow_missing_evidence") is True:
51
+ return True
52
+ if any(
53
+ key in metadata and metadata[key] not in (None, "", [], {})
54
+ for key in EVIDENCE_METADATA_KEYS
55
+ ):
56
+ return True
57
+ evidence = metadata.get("evidence")
58
+ if isinstance(evidence, dict):
59
+ return any(value not in (None, "", [], {}) for value in evidence.values())
60
+ if isinstance(evidence, list):
61
+ return bool(evidence)
62
+ return False
63
+
64
+
65
+ __all__ = [
66
+ "EVIDENCE_METADATA_KEYS",
67
+ "metadata_has_completion_evidence",
68
+ ]
map_types/__init__.py ADDED
@@ -0,0 +1,203 @@
1
+ """Shared API types for MAP server, SDK, and MCP."""
2
+
3
+ from map_types.enums import (
4
+ AcceptanceType,
5
+ ActionItemCategory,
6
+ AgentRole,
7
+ CommentAnchorType,
8
+ ExperimentPhase,
9
+ FeedbackCategory,
10
+ FeedbackStatus,
11
+ InboundEventSource,
12
+ NotificationCategory,
13
+ NotificationFingerprintVersion,
14
+ PhaseOwner,
15
+ ReviewArchivedReason,
16
+ ReviewItemKind,
17
+ ReviewItemStatus,
18
+ ReviewSubstituteKind,
19
+ TopicActionItemStatus,
20
+ TopicDiscussionRound,
21
+ TopicStatus,
22
+ )
23
+ from map_types.schemas import (
24
+ AcceptanceStatusRead,
25
+ ActionItemCancel,
26
+ AgentCreateResponse,
27
+ AgentRead,
28
+ AgentWorkRead,
29
+ AgentWorkSummaryRead,
30
+ AuditLogRead,
31
+ CommentCreate,
32
+ CommentRead,
33
+ CommentTreeNode,
34
+ CrossPersonaCallRecord,
35
+ DismissAllMentionsResultRead,
36
+ DismissMentionResultRead,
37
+ EscalationTargetRead,
38
+ EvidenceValidationSchema,
39
+ EvidenceWarningSchema,
40
+ ExperimentBundleRead,
41
+ ExperimentComplete,
42
+ ExperimentCreate,
43
+ ExperimentDetailRead,
44
+ ExperimentLockRead,
45
+ ExperimentLockStalledScanRead,
46
+ ExperimentLogCreate,
47
+ ExperimentLogRead,
48
+ ExperimentResultDecision,
49
+ ExperimentSummaryRead,
50
+ ExperimentUpdate,
51
+ GlobalStatusRead,
52
+ InboundEventCreate,
53
+ InboundEventRead,
54
+ InboundEventRecordResult,
55
+ LogCreateResponse,
56
+ NotificationListRead,
57
+ NotificationRead,
58
+ PendingReplyRead,
59
+ PlanInput,
60
+ PlanRevise,
61
+ PlanVersionRead,
62
+ PlatformFeedbackCreate,
63
+ PlatformFeedbackRead,
64
+ PlatformFeedbackUpdate,
65
+ ProjectCreate,
66
+ ProjectRead,
67
+ ProjectStatusRead,
68
+ ProjectStatusRevise,
69
+ ProjectStatusVersionRead,
70
+ ProjectUpdate,
71
+ ReviewCreate,
72
+ ReviewItemRead,
73
+ ReviewItemUpdate,
74
+ ReviewRead,
75
+ SimilarityWarningSchema,
76
+ StaleOpenTopicTodoRead,
77
+ TemplateValidationSchema,
78
+ TemplateWarningSchema,
79
+ TodoRead,
80
+ TopicActionItemCreate,
81
+ TopicActionItemRead,
82
+ TopicActionItemTodoRead,
83
+ TopicAdvanceRound,
84
+ TopicCommentCreate,
85
+ TopicCommentRead,
86
+ TopicCommentTreeNode,
87
+ TopicCreate,
88
+ TopicDecisionRead,
89
+ TopicProgressCommentRead,
90
+ TopicProgressItemRead,
91
+ TopicProgressListRead,
92
+ TopicRead,
93
+ TopicReadCursorRead,
94
+ TopicResolve,
95
+ TopicSummaryRead,
96
+ TopicUpdate,
97
+ TopicWorkItemRead,
98
+ WebhookCreate,
99
+ WebhookCreateResponse,
100
+ WebhookDeliveryRead,
101
+ WebhookRead,
102
+ WebhookUpdate,
103
+ )
104
+
105
+ __all__ = [
106
+ "ActionItemCancel",
107
+ "AcceptanceStatusRead",
108
+ "ActionItemCategory",
109
+ "AgentRole",
110
+ "AcceptanceType",
111
+ "CommentAnchorType",
112
+ "ExperimentPhase",
113
+ "FeedbackCategory",
114
+ "FeedbackStatus",
115
+ "InboundEventSource",
116
+ "NotificationCategory",
117
+ "NotificationFingerprintVersion",
118
+ "PhaseOwner",
119
+ "ReviewArchivedReason",
120
+ "ReviewItemKind",
121
+ "ReviewItemStatus",
122
+ "ReviewSubstituteKind",
123
+ "TopicActionItemStatus",
124
+ "TopicDiscussionRound",
125
+ "TopicStatus",
126
+ "AgentCreateResponse",
127
+ "AgentRead",
128
+ "AgentWorkRead",
129
+ "AgentWorkSummaryRead",
130
+ "AuditLogRead",
131
+ "CommentCreate",
132
+ "CommentRead",
133
+ "CommentTreeNode",
134
+ "CrossPersonaCallRecord",
135
+ "DismissAllMentionsResultRead",
136
+ "DismissMentionResultRead",
137
+ "EscalationTargetRead",
138
+ "EvidenceValidationSchema",
139
+ "EvidenceWarningSchema",
140
+ "ExperimentComplete",
141
+ "ExperimentCreate",
142
+ "ExperimentDetailRead",
143
+ "ExperimentBundleRead",
144
+ "ExperimentLockRead",
145
+ "ExperimentLockStalledScanRead",
146
+ "ExperimentLogCreate",
147
+ "ExperimentLogRead",
148
+ "ExperimentResultDecision",
149
+ "LogCreateResponse",
150
+ "ExperimentSummaryRead",
151
+ "ExperimentUpdate",
152
+ "GlobalStatusRead",
153
+ "InboundEventCreate",
154
+ "InboundEventRead",
155
+ "InboundEventRecordResult",
156
+ "NotificationListRead",
157
+ "NotificationRead",
158
+ "PendingReplyRead",
159
+ "PlanInput",
160
+ "PlanRevise",
161
+ "PlanVersionRead",
162
+ "PlatformFeedbackCreate",
163
+ "PlatformFeedbackRead",
164
+ "PlatformFeedbackUpdate",
165
+ "ProjectCreate",
166
+ "ProjectRead",
167
+ "ProjectStatusRead",
168
+ "ProjectStatusRevise",
169
+ "ProjectStatusVersionRead",
170
+ "ProjectUpdate",
171
+ "ReviewCreate",
172
+ "ReviewItemRead",
173
+ "ReviewItemUpdate",
174
+ "ReviewRead",
175
+ "SimilarityWarningSchema",
176
+ "StaleOpenTopicTodoRead",
177
+ "TodoRead",
178
+ "TemplateValidationSchema",
179
+ "TemplateWarningSchema",
180
+ "TopicActionItemCreate",
181
+ "TopicActionItemRead",
182
+ "TopicActionItemTodoRead",
183
+ "TopicCommentCreate",
184
+ "TopicCommentRead",
185
+ "TopicCommentTreeNode",
186
+ "TopicAdvanceRound",
187
+ "TopicCreate",
188
+ "TopicDecisionRead",
189
+ "TopicProgressCommentRead",
190
+ "TopicProgressItemRead",
191
+ "TopicProgressListRead",
192
+ "TopicWorkItemRead",
193
+ "TopicRead",
194
+ "TopicReadCursorRead",
195
+ "TopicResolve",
196
+ "TopicSummaryRead",
197
+ "TopicUpdate",
198
+ "WebhookCreate",
199
+ "WebhookCreateResponse",
200
+ "WebhookDeliveryRead",
201
+ "WebhookRead",
202
+ "WebhookUpdate",
203
+ ]
map_types/enums.py ADDED
@@ -0,0 +1,199 @@
1
+ import enum
2
+
3
+
4
+ class AgentRole(str, enum.Enum):
5
+ agent = "agent"
6
+ admin = "admin"
7
+
8
+
9
+ class ExperimentPhase(str, enum.Enum):
10
+ draft = "draft"
11
+ review = "review"
12
+ approved = "approved"
13
+ running = "running"
14
+ result_review = "result_review"
15
+ done = "done"
16
+ cancelled = "cancelled"
17
+
18
+
19
+ class PhaseOwner(str, enum.Enum):
20
+ """Decision-owner role for each ``ExperimentPhase`` (experiment f873c287 I1(b)).
21
+
22
+ Maps which persona holds the decision authority to *advance* a given
23
+ phase — used by ``informational_only`` auto-classification
24
+ (I1(a): ``actions=[] AND blocked_on AND phase_owner != host``) and by
25
+ the UI "host blocked, waiting on {phase_owner}" copy (I1(d)).
26
+
27
+ Semantics — "decision owner", not "executor":
28
+ - ``draft`` → host (creator drafts the plan)
29
+ - ``review`` → reviewer (non-creator reviews & submits verdict)
30
+ - ``revise`` → host (revising is a host decision during review)
31
+ - ``approved`` → host (host decides to start)
32
+ - ``running`` → host (host owns execution)
33
+ - ``result_review`` → reviewer (non-creator reviews result)
34
+ - ``done`` → host (host owns archival / follow-ups)
35
+ - ``cancelled`` → host (host decides to cancel; admin can override)
36
+ """
37
+
38
+ host = "host"
39
+ reviewer = "reviewer"
40
+ participant = "participant"
41
+ admin = "admin"
42
+
43
+
44
+ class AcceptanceType(str, enum.Enum):
45
+ migration = "migration"
46
+ smoke = "smoke"
47
+ unit_test = "unit_test"
48
+ integration = "integration"
49
+ manual = "manual"
50
+
51
+
52
+ class ReviewItemKind(str, enum.Enum):
53
+ reasonable = "reasonable"
54
+ unreasonable = "unreasonable"
55
+
56
+
57
+ class ReviewVerdict(str, enum.Enum):
58
+ """Reviewer's per-item verdict on experiment acceptance.
59
+
60
+ Drives ``experiment.result_review`` structured verdict files and the
61
+ R6 verdict breakdown in ``experiment_logs.metadata_json``. Parallel
62
+ pattern to ``31793f90`` ``pre_schema_log``.
63
+ """
64
+
65
+ passed = "passed"
66
+ failed = "failed"
67
+ waived = "waived"
68
+
69
+
70
+ class ReviewSubstituteKind(str, enum.Enum):
71
+ none = "none"
72
+ admin_for_others = "admin_for_others"
73
+ admin_self_substitute = "admin_self_substitute"
74
+
75
+
76
+ class ReviewArchivedReason(str, enum.Enum):
77
+ """Reason a ``Review`` row was archived.
78
+
79
+ ``auto`` — archived automatically by ``plan_revise`` because the host
80
+ bumped ``current_plan_version`` and this row is no longer canonical.
81
+ Also used as the historical backfill marker for rows that predate
82
+ the archive feature (the UI renders those with a
83
+ ``(pre-archive, all reviews shown)`` hint).
84
+ ``manual`` — archived explicitly by an admin or host (e.g. duplicate
85
+ review row, withdrawn reviewer).
86
+ ``superseded`` — the review's plan_version was explicitly superseded
87
+ by a later authoritative review at the same plan_version (rare;
88
+ reserved for the future review-amendment flow).
89
+ """
90
+
91
+ auto = "auto"
92
+ manual = "manual"
93
+ superseded = "superseded"
94
+
95
+
96
+ class ReviewItemStatus(str, enum.Enum):
97
+ open = "open"
98
+ addressed = "addressed"
99
+ rebutted = "rebutted"
100
+ resolved = "resolved"
101
+ withdrawn = "withdrawn"
102
+ escalated = "escalated"
103
+ closed = "closed"
104
+
105
+
106
+ class ResolutionReason(str, enum.Enum):
107
+ resolved = "resolved"
108
+ rebutted = "rebutted"
109
+ superseded = "superseded"
110
+
111
+
112
+ class CommentAnchorType(str, enum.Enum):
113
+ plan = "plan"
114
+ review = "review"
115
+ review_item = "review_item"
116
+ comment = "comment"
117
+
118
+
119
+ class TopicStatus(str, enum.Enum):
120
+ open = "open"
121
+ closed = "closed"
122
+
123
+
124
+ class TopicDiscussionRound(str, enum.Enum):
125
+ round1 = "round1"
126
+ round2 = "round2"
127
+ ready = "ready"
128
+
129
+
130
+ class TopicActionItemStatus(str, enum.Enum):
131
+ open = "open"
132
+ done = "done"
133
+ cancelled = "cancelled"
134
+
135
+
136
+ class ActionItemCategory(str, enum.Enum):
137
+ """Drives the cancel-reason minimum-length threshold (see ActionItemCancel)."""
138
+
139
+ implementation = "implementation"
140
+ decision = "decision"
141
+ unspecified = "unspecified"
142
+
143
+
144
+ class MentionSourceType(str, enum.Enum):
145
+ experiment_comment = "experiment_comment"
146
+ topic = "topic"
147
+ topic_comment = "topic_comment"
148
+
149
+
150
+ class TopicCommentKind(str, enum.Enum):
151
+ user = "user"
152
+ system = "system"
153
+
154
+
155
+ class NotificationCategory(str, enum.Enum):
156
+ wakeable = "wakeable"
157
+ digest = "digest"
158
+
159
+
160
+ class NotificationFingerprintVersion(str, enum.Enum):
161
+ """Marker for which fingerprint dialect a Notification row carries.
162
+
163
+ v0.9 (this version) marks every freshly-written notification with ``v2`` so
164
+ the runtime-waker can reject legacy ``v1`` fingerprints (``inbound:<event_id>``)
165
+ at the ingest gate and record ``rejection_count`` instead of resuming. The
166
+ version lives on the Notification row itself — classification does not look
167
+ at it, but the audit / three-layer join does (see PRD §5.1 + topic
168
+ d0df651c Round 1 Summary).
169
+ """
170
+
171
+ v1 = "v1"
172
+ v2 = "v2"
173
+
174
+
175
+ class FeedbackCategory(str, enum.Enum):
176
+ bug = "bug"
177
+ suggestion = "suggestion"
178
+ question = "question"
179
+ other = "other"
180
+
181
+
182
+ class FeedbackStatus(str, enum.Enum):
183
+ new = "new"
184
+ triaged = "triaged"
185
+ in_progress = "in_progress"
186
+ resolved = "resolved"
187
+
188
+
189
+ class InboundEventSource(str, enum.Enum):
190
+ """Origin channel through which the runtime-waker received a notification.
191
+
192
+ Phase 1 only writes ``polling``. ``sse`` and ``replay`` are reserved for
193
+ Phase 2 (SSE overlay + reconnect compensation) so the enum is forward-compat
194
+ and DB migrations don't need to widen the column later.
195
+ """
196
+
197
+ polling = "polling"
198
+ sse = "sse"
199
+ replay = "replay"