Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: >-
status: Done
assignee: []
created_date: '2026-02-25 06:16'
updated_date: '2026-03-04 11:24'
updated_date: '2026-03-10 09:31'
labels:
- typescript
- schema
Expand All @@ -28,7 +28,7 @@ documentation:
- >-
https://tree-sitter.github.io/py-tree-sitter/classes/tree_sitter.QueryCursor.html
priority: high
ordinal: 6000
ordinal: 7000
---

## Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: >-
status: Done
assignee: []
created_date: '2026-02-26 10:41'
updated_date: '2026-03-04 11:24'
updated_date: '2026-03-10 09:31'
labels:
- query-engine
- validator
Expand Down Expand Up @@ -46,7 +46,7 @@ documentation:
- 'backlog://workflow/overview'
parent_task_id: TASK-1
priority: high
ordinal: 4000
ordinal: 5000
---

## Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: >-
status: Done
assignee: []
created_date: '2026-02-27 13:12'
updated_date: '2026-03-04 11:24'
updated_date: '2026-03-10 09:31'
labels:
- query-engine
- validator
Expand All @@ -32,7 +32,7 @@ documentation:
CallExpression-Confidence-Scoring-and-Validation-Agent.md
parent_task_id: TASK-1.2
priority: high
ordinal: 5000
ordinal: 6000
---

## Description
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
id: TASK-10
title: Re-architect agent events for scalable history and virtualized viewing
status: In Progress
status: Done
assignee:
- codex
created_date: '2026-03-08 08:43'
updated_date: '2026-03-08 11:05'
updated_date: '2026-03-10 09:31'
labels:
- backend
- frontend
Expand All @@ -30,6 +30,7 @@ documentation:
- 'https://tanstack.com/virtual/latest/docs/introduction'
- 'https://electric-sql.com/docs/guides/shapes'
priority: high
ordinal: 25000
---

## Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ id: TASK-10.1
title: >-
Backend: persist agent events in normalized history for Electric-backed
frontend sync
status: In Progress
status: Done
assignee:
- codex
created_date: '2026-03-08 08:43'
updated_date: '2026-03-08 11:50'
updated_date: '2026-03-10 09:31'
labels:
- backend
- performance
Expand All @@ -25,6 +25,7 @@ references:
/Users/jayghiya/.superset/worktrees/unoplat-code-confluence/update-commons-testing/unoplat-code-confluence-commons/src/unoplat_code_confluence_commons/repo_models.py
parent_task_id: TASK-10
priority: high
ordinal: 24000
---

## Description
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
id: TASK-10.2
title: 'Frontend: replace agent events accordion body with a virtualized flat timeline'
status: In Progress
status: Done
assignee:
- codex
created_date: '2026-03-08 08:43'
updated_date: '2026-03-08 12:22'
updated_date: '2026-03-10 09:31'
labels:
- frontend
- performance
Expand All @@ -26,6 +26,7 @@ references:
/Users/jayghiya/.superset/worktrees/unoplat-code-confluence/update-commons-testing/unoplat-code-confluence-frontend/src/types/agent-events.ts
parent_task_id: TASK-10
priority: high
ordinal: 22000
---

## Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ id: TASK-10.3
title: >-
Frontend: sync agent event history through Electric collection and merge with
live updates
status: In Progress
status: Done
assignee:
- codex
created_date: '2026-03-08 08:43'
updated_date: '2026-03-08 13:11'
updated_date: '2026-03-10 09:31'
labels:
- frontend
- performance
Expand All @@ -28,6 +28,7 @@ references:
/Users/jayghiya/.superset/worktrees/unoplat-code-confluence/update-commons-testing/unoplat-code-confluence-frontend/src/components/custom/GenerateAgentsDialog.tsx
parent_task_id: TASK-10
priority: high
ordinal: 21000
---

## Description
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
---
id: TASK-12
title: Add cancel action for agent workflows in Operations Management
status: In Progress
assignee: []
created_date: '2026-03-10 09:28'
updated_date: '2026-03-12 10:40'
labels:
- operations-management
- agent-md
- cancellation
- frontend
- query-engine
- ingestion
dependencies: []
references:
- >-
unoplat-code-confluence-frontend/src/components/custom/SubmittedJobsDataTable.tsx
- >-
unoplat-code-confluence-frontend/src/components/custom/GenerateAgentsDialog.tsx
- unoplat-code-confluence-frontend/src/components/custom/JobStatusDialog.tsx
- >-
unoplat-code-confluence-frontend/src/components/custom/submitted-jobs-data-table-columns.tsx
- unoplat-code-confluence-frontend/src/lib/api.ts
- >-
unoplat-code-confluence-ingestion/code-confluence-flow-bridge/src/code_confluence_flow_bridge/main.py
- >-
unoplat-code-confluence-ingestion/code-confluence-flow-bridge/src/code_confluence_flow_bridge/models/github/github_repo.py
- >-
unoplat-code-confluence-query-engine/src/unoplat_code_confluence_query_engine/api/v1/endpoints/codebase_agent_rules.py
- >-
unoplat-code-confluence-query-engine/src/unoplat_code_confluence_query_engine/services/temporal/workflow_service.py
- >-
unoplat-code-confluence-commons/src/unoplat_code_confluence_commons/repo_models.py
- >-
unoplat-code-confluence-commons/src/unoplat_code_confluence_commons/workflow_models.py
documentation:
- 'https://python.temporal.io/temporalio.client.WorkflowHandle.html'
- 'https://docs.temporal.io/develop/python'
priority: high
ordinal: 3000
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Users need a way to stop a running AGENTS.md workflow from Operations Management. The cancel control must be available only for AGENTS_GENERATION and AGENT_MD_UPDATE runs, and must never be shown for INGESTION runs. This spans query-engine (cancel API + Temporal workflow cancellation), ingestion (job-list contract support for cancellability gating), and frontend (Operations Management action wiring and UX states).
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Operations Management allows user-initiated cancellation for in-flight AGENTS_GENERATION and AGENT_MD_UPDATE runs.
- [ ] #2 Operations Management never displays a cancel action for INGESTION runs.
- [ ] #3 Query-engine provides a cancel endpoint that accepts repository owner/name/run identifier and returns deterministic responses for success, non-cancellable operation, not-found run, and already-terminal run.
- [ ] #4 Query-engine uses Temporal Python async cancellation (`await handle.cancel()`) for workflow cancellation.
- [ ] #5 Cancellation behavior does not require introducing a new workflow status enum value; existing status model remains valid and cancellation context is preserved in error/report metadata.
- [ ] #6 Frontend shows pending/disabled state during cancel request, then refreshes operations data and shows success or error feedback.
- [ ] #7 Ingestion job-list API provides enough data to gate cancel visibility safely in UI (existing operation/status fields or explicit cancellable flag).
- [ ] #8 Relevant API/docs/tests are updated to reflect the cancel workflow behavior and ingestion exclusion rule.
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
## Scope
Enable Operations Management users to stop a running AGENTS.md workflow while guaranteeing that ingestion workflows never expose or accept cancellation.

## Implementation Plan
1. Query-engine cancellation API
- Add a dedicated endpoint in `unoplat-code-confluence-query-engine/src/unoplat_code_confluence_query_engine/api/v1/endpoints/codebase_agent_rules.py` for repository agent run cancellation.
- Request contract: repository owner, repository name, repository workflow run id.
- Validate target run from `RepositoryWorkflowRun` (owner/name/run tuple).
- Enforce operation guardrail: reject `INGESTION` at API layer even if called directly.
- Enforce state guardrail: reject already-terminal runs (COMPLETED/FAILED/TIMED_OUT/ERROR) with deterministic response.
- Use Temporal async handle cancellation (`client.get_workflow_handle(...); await handle.cancel()`).
- Normalize Temporal RPC failures into stable API responses (not found, invalid state, generic failure).

2. Cancellation status behavior
- Keep current `JobStatus` enum unchanged (no new `CANCELLED` status in this increment).
- Persist cancellation context via error metadata/report path (e.g., source=user_action, reason=cancel_requested) so UI and diagnostics can distinguish manual stop from runtime failures.
- Ensure eventual status transition after cancel request remains compatible with existing interceptors and terminal-state handling.

3. Ingestion job-list contract alignment
- Update ingestion `/parent-workflow-jobs` response model and mapper to include explicit cancellability signal derived from operation + status (or formally document operation/status gating if explicit field is skipped).
- Rule: only AGENTS_GENERATION / AGENT_MD_UPDATE can be cancellable; INGESTION is always false.

4. Frontend Operations Management wiring
- Add query-engine API client method for cancel action in `unoplat-code-confluence-frontend/src/lib/api.ts`.
- Extend job typing to carry cancellability signal in `unoplat-code-confluence-frontend/src/types.ts`.
- Add cancel CTA to AGENTS dialog flow in `unoplat-code-confluence-frontend/src/components/custom/GenerateAgentsDialog.tsx` only when run is cancellable and in-flight.
- Do not add cancel CTA in ingestion details dialog (`JobStatusDialog`).
- Add loading/disabled UX, success/failure toast, and query invalidation (`parentWorkflowJobs`, and any active run detail queries) after action.

5. Verification and docs
- Add/adjust backend tests for cancel endpoint guards and success path.
- Add/adjust ingestion API tests for cancellability field derivation.
- Add/adjust frontend tests (or documented manual validation) for agent-only cancel visibility.
- Update interface docs where applicable (`app_interfaces.md` in touched services).

## Delivery Notes
- Cancellation request acknowledgement does not guarantee immediate workflow termination; UI should reflect "cancel requested" semantics until a terminal status is observed.
- Backend enforcement is mandatory so ingestion cannot be cancelled even if a client bypasses UI controls.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
## Design Decisions Captured
- FastAPI endpoint is async; Temporal cancellation must use async call with `await handle.cancel()`.
- No new workflow status enum is introduced in this increment to avoid cross-service schema/constraint migration blast radius.
- Ingestion exclusion is enforced in both layers: UI visibility rules and backend API validation.

## Files and Surfaces to Touch
- Query-engine endpoint and Temporal interaction: `unoplat-code-confluence-query-engine/src/unoplat_code_confluence_query_engine/api/v1/endpoints/codebase_agent_rules.py`
- Ingestion operations list contract: `unoplat-code-confluence-ingestion/code-confluence-flow-bridge/src/code_confluence_flow_bridge/main.py`, `unoplat-code-confluence-ingestion/code-confluence-flow-bridge/src/code_confluence_flow_bridge/models/github/github_repo.py`
- Frontend operation UX/API/types: `unoplat-code-confluence-frontend/src/components/custom/GenerateAgentsDialog.tsx`, `unoplat-code-confluence-frontend/src/components/custom/JobStatusDialog.tsx`, `unoplat-code-confluence-frontend/src/components/custom/SubmittedJobsDataTable.tsx`, `unoplat-code-confluence-frontend/src/lib/api.ts`, `unoplat-code-confluence-frontend/src/types.ts`

## Operational Guardrails
- Reject cancel attempts when operation is `INGESTION`.
- Reject cancel attempts for terminal statuses.
- Return deterministic API messages for: run not found, already terminal, non-cancellable operation, cancel accepted, and backend failure.

Implementation started in this session.

Implemented query-engine cancel endpoint `POST /v1/repository-agent-run/cancel` with operation guardrails (agent-only), terminal-state guardrails, async Temporal cancel (`await handle.cancel()`), and deterministic HTTP responses for not found/non-cancellable/already-terminal/runtime unavailable.

Implemented ingestion operations-list cancellability contract by adding `is_cancellable` to `ParentWorkflowJobResponse` and deriving it in `/parent-workflow-jobs` from operation + status.

Implemented frontend wiring: added `cancelRepositoryAgentRun()` API client, added `is_cancellable` in `ParentWorkflowJobResponse` type, and added Cancel Run action in `GenerateAgentsDialog` for in-flight agent workflows only (not ingestion dialog).

Updated interface documentation in query-engine and ingestion `app_interfaces.md`.

Verification run: frontend `bun run build` passed. Targeted query-engine typecheck for modified endpoint passed. Targeted ingestion typecheck for modified model passed. Full-repo Python typechecks in query-engine/ingestion still report many pre-existing unrelated issues.

Created child task `TASK-12.1` to address UX guardrail for preventing concurrent AGENTS.md run starts for the same repository.

Simplified cancellation implementation per alpha scope: removed legacy/backward-compatibility recovery path and enforced strict workflow-id semantics. `repository_workflow_id` is now required at workflow-run initialization and DB activity raises if workflow_id is missing.

Manual retest still resulted in `COMPLETED` after cancel. Continuing investigation into workflow cancellation propagation paths inside query-engine Temporal workflows.

Used Temporal CLI on workflow `agent-fastapi-full-stack-fastapi-template-62517836` / run `019ce18e-5464-747b-a3a7-50aaa7fc8175` to confirm exact propagation bug: Temporal history ends in `WORKFLOW_EXECUTION_CANCELED`, but our interceptor scheduled parent DB status `COMPLETED` just before close. Root cause was repository interceptor not catching `asyncio.CancelledError` (inherits `BaseException`, not `Exception` in Python 3.13).

Implemented precise fix: cancellation helpers now recognize both Temporal `CancelledError` and `asyncio.CancelledError`, and repository/codebase interceptor execute-workflow wrappers now explicitly catch `asyncio.CancelledError` so final DB status is written as `CANCELLED` instead of defaulting to `COMPLETED`.

Refactored cancellation propagation logic to shared helper module `services/temporal/cancellation_helpers.py` to remove duplicated cause-chain parsing across workflow/interceptor.

`temporal_workflows.py` now imports shared `is_temporal_cancellation_exception` and keeps only `_raise_if_temporal_cancellation` wrapper for workflow-local logging.

`agent_workflow_interceptor.py` now imports the shared helper and uses `WORKFLOW_EXECUTION_EXCEPTIONS` constant to avoid duplicated except tuples.

Added targeted tests `tests/services/test_cancellation_helpers.py` for direct Temporal cancel, direct asyncio cancel, wrapped cancel chain, and non-cancel exception.

Verification: basedpyright (targeted files) passed; ruff check passed; pytest `tests/services/test_cancellation_helpers.py` passed (4 tests).
<!-- SECTION:NOTES:END -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
id: TASK-12.1
title: Prevent duplicate AGENTS.md run starts for same repository
status: To Do
assignee: []
created_date: '2026-03-10 11:03'
labels:
- frontend
- ux
- operations-management
- agent-md
- workflow-concurrency
dependencies: []
references:
- >-
unoplat-code-confluence-frontend/src/components/custom/IngestedRepositoriesDataTable.tsx
- >-
unoplat-code-confluence-frontend/src/components/custom/GenerateAgentsDialog.tsx
- unoplat-code-confluence-frontend/src/lib/api.ts
- >-
unoplat-code-confluence-query-engine/src/unoplat_code_confluence_query_engine/api/v1/endpoints/codebase_agent_rules.py
parent_task_id: TASK-12
priority: high
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Operations UX should prevent users from starting multiple AGENTS.md generation/update runs for the same repository at the same time. Current behavior can trigger multiple concurrent repository agent workflows, which creates ambiguity for cancellation/status targeting and noisy operations history.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 When a repository already has an in-flight AGENTS_GENERATION or AGENT_MD_UPDATE run, UI blocks starting another run for that same repository.
- [ ] #2 Start/Generate CTA shows clear disabled state and explanatory copy while a run is active.
- [ ] #3 Operations and repository status views stay consistent after refresh; no duplicate in-flight starts can be initiated via normal UI flow.
- [ ] #4 User can start a new AGENTS.md run again once previous run reaches terminal status.
- [ ] #5 Manual QA steps are documented for active-run, terminal-run, and refresh/navigation scenarios.
<!-- AC:END -->

## Definition of Done
<!-- DOD:BEGIN -->
- [ ] #1 Frontend behavior includes optimistic guard + server state recheck before start action
- [ ] #2 No regression for ingestion operation flows
<!-- DOD:END -->
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: >-
status: Done
assignee: []
created_date: '2026-03-05 09:56'
updated_date: '2026-03-05 10:17'
updated_date: '2026-03-10 09:31'
labels:
- typescript
- framework-detection
Expand All @@ -20,6 +20,7 @@ references:
unoplat-code-confluence-ingestion/code-confluence-flow-bridge/tests/engine/programming_language/typescript/test_typescript_additional_concept_extraction.py
parent_task_id: TASK-3.2
priority: high
ordinal: 18000
---

## Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: >-
status: Done
assignee: []
created_date: '2026-03-05 09:56'
updated_date: '2026-03-05 10:09'
updated_date: '2026-03-10 09:31'
labels:
- python
- framework-detection
Expand All @@ -20,6 +20,7 @@ references:
unoplat-code-confluence-ingestion/code-confluence-flow-bridge/tests/parser/test_framework_detection_tree_sitter.py
parent_task_id: TASK-3.2
priority: high
ordinal: 19000
---

## Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Implement deterministic CallExpression scoring + enriched metadata emissi
status: Done
assignee: []
created_date: '2026-03-05 09:56'
updated_date: '2026-03-05 10:27'
updated_date: '2026-03-10 09:31'
labels:
- confidence-scoring
- framework-detection
Expand All @@ -24,6 +24,7 @@ references:
unoplat-code-confluence-ingestion/code-confluence-flow-bridge/src/code_confluence_flow_bridge/processor/db/postgres/code_confluence_relational_ingestion.py
parent_task_id: TASK-3.2
priority: high
ordinal: 16000
---

## Description
Expand Down
Loading
Loading