Skip to content

fix(codeflow): [CI/rebase] Debug Logging in Production - #45

Open
nehraa wants to merge 216 commits into
mainfrom
claude-lane/task_1780281408931_95sihyp7i-20260602150330
Open

nehraa wants to merge 216 commits into
mainfrom
claude-lane/task_1780281408931_95sihyp7i-20260602150330

Conversation

@nehraa

@nehraa nehraa commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Original task: task_1780281408931_95sihyp7i
PR branch: claude-lane/task_1780281408931_95sihyp7i-20260602150330
CI failure: merge-conflict
Strategy: rebase

Hint: PR has merge conflicts with main. Run: git fetch origin && git rebase origin/main && git push --force-with-lease. The watcher's open_pr_for_task will detect the existing PR.

Failure log (last 3000 chars)

X Pull request #32 is not mergeable: the merge commit cannot be cleanly created.
To have the pull request merged after all the requirements have been met, add the `--auto` flag.

Workflow

  1. Read the failure log and the PR's diff (use git log origin/main..claude-lane/task_1780281408931_95sihyp7i-20260602150330)
  2. Apply the fix on top of the SAME branch (claude-lane/task_1780281408931_95sihyp7i-20260602150330) — the worktree is already set up by the dispatcher
  3. Commit with fix(ci): <one-line summary> (single line)
  4. The dispatcher will push your commit to the SAME branch and detect the existing PR
  5. The PR's CI re-runs automatically. Watcher picks it up on the next 5-min cycle.
  6. Report: files changed, commit SHA, what the fix was

Automated by DevPulse dispatcher.

nehraa and others added 30 commits March 14, 2026 19:22
Add architecture analysis suite: cycle detection, smell detection, graph metrics, Mermaid export
- Add GraphBranch, BranchDiff, NodeDiff, EdgeDiff types to schema.ts
- Create branches.ts with createBranch() and diffBranches() logic
- Add branch persistence to store.ts (saveBranch, loadBranches, loadBranch, deleteBranch)
- Add API routes: POST/GET /api/branches, POST /api/branches/diff, GET/DELETE /api/branches/[id]
- Update blueprint-workbench.tsx with full branch panel UI
- Add CSS styles for branch panel and diff visualization
- Add 23 unit/integration tests covering branches.ts and both new API routes

Co-authored-by: nehraa <187715469+nehraa@users.noreply.github.com>
…ntic IDE

Co-authored-by: nehraa <187715469+nehraa@users.noreply.github.com>
…uals

Co-authored-by: nehraa <187715469+nehraa@users.noreply.github.com>
Co-authored-by: nehraa <187715469+nehraa@users.noreply.github.com>
Co-authored-by: nehraa <187715469+nehraa@users.noreply.github.com>
Co-authored-by: nehraa <187715469+nehraa@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…dashboard

feat: Heatmap observability dashboard with live trace visuals and auto-polling
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
nehraa and others added 23 commits April 23, 2026 16:40
Add attachObservabilitySnapshot, attachRiskReport, attachSessionSnapshot
helpers and integrate them into createBranch as attachObservability,
attachRisk, attachSession options. attachRisk requires runPlan.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New @abhinav2203/codeflow-prd package for PRD markdown parsing and
BlueprintGraph building. Includes:

- parsePrd(): converts PRD markdown to BlueprintNode/Edge/Workflow structures
- buildBlueprintGraph(): assembles a full BlueprintGraph from parsed PRD
- Inline utils (slugify, createNode, mergeContracts, dedupeEdges) from core
- withSpecDrafts(): adds scaffold status to code-bearing nodes

Wired src/app/api/blueprint/route.ts and
src/app/api/generate-blueprint/route.ts to import from the package.
Updated imports to use @abhinav2203/codeflow-core/schema and internal/utils.

Note: Repo analysis (analyzeTypeScriptRepo) and CodeRag integration
are deferred to a future version once those dependencies are packaged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Change markCompleted to take explicit success boolean instead of duck-typing
- Add retry logic to executeTask using maxRetries config
- Add tests for getFailedCount(), circular dependency detection, and
  non-existent dependency task ID handling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace placeholder spawnAgent() with opencode run integration using execa
- Add --serve and --acp CLI flags to start opencode headless/ACP servers
- Update coder-prompt.ts for CLI-optimized prompts
- Add execa@^9.0.0 dependency
- Update test to reflect new behavior (returns failure result instead of throwing)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add `src/agent/blueprint.ts` with `blueprintToTasks()` to convert BlueprintGraph to AgentTask[]
- Add `src/store/reasoning.ts` with `saveReasoningTrace()` and `appendReasoningStep()` for reasoning traces
- Update `src/agent/execution-context.ts` with `executeBlueprint()` for blueprint-based orchestration
- Update CLI in `src/cli/index.ts` to support `--blueprint <file>` flag for blueprint execution

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eneration

Add comprehensive AI-powered orchestration for codeflow-agent:

- NVIDIA Llama blueprint generation via `generateBlueprint()`
- Per-node prompt building via `buildNodePrompt()`
- OpenCode HTTP API code generation via `generateNodeCode()`
- Permission system with yolo/always-ask/important modes

New files:
- src/ai/blueprint-generator.ts: Blueprint generation using NVIDIA API
- src/ai/node-prompts.ts: Build implementation prompts for blueprint nodes
- src/ai/code-generator.ts: OpenCode HTTP client for code generation
- src/ai/opencode-client.ts: OpenCode session management and HTTP client
- src/permissions/manager.ts: Permission modes and approval logic
- src/types/blueprint.ts: BlueprintGraph and BlueprintNode types

CLI updates:
- Add --generate "<prompt>" for AI blueprint generation
- Add --permission=yolo|always-ask|important mode selection
- Add --inspect to show prompts before generation
- Add --nvidia-api-key and --opencode-url options

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… from execution

chore(execution): remove codegen, strip utils, update runtime imports
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Delete src/types/blueprint.ts and update all importers to use
@abhinav2203/codeflow-core/schema directly. RiskLevel is now defined
locally in permissions/manager.ts since it doesn't exist in core schema.

Updated files:
- ai/blueprint-generator.ts: import from @abhinav2203/codeflow-core/schema
- ai/node-prompts.ts: import from @abhinav2203/codeflow-core/schema
- ai/index.ts: removed blueprint type re-exports, re-export RiskLevel from permissions/manager
- cli/index.ts: import BlueprintGraph from @abhinav2203/codeflow-core/schema
- permissions/manager.ts: define RiskLevel locally (not in core schema)
- ai/doc-generator.ts, ai/multi-language-codegen.ts: updated imports
- ai/multi-language-codegen.test.ts, ai/test-generator.test.ts: updated imports
- ai/doc-generator.test.ts: fixed import path and removed generateMarkdownDocs alias test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rator

- Add execution-context.ts for agent execution management
- Add blueprint.ts for workflow blueprint definitions
- Add refactor-suggester.ts for code improvement suggestions
- Add test-generator.ts for automated test generation
- Update ai module with minimax-client integration
- Add execution span and runtime contract types
- Add VCR and sandbox execution modules

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Restructure the monorepo to consolidate all 14 packages under
packages/ and add comprehensive per-package documentation.

- Add docs/ folder with architecture docs for every package
  (codeflow-core, analysis, prd, execution, agent, store, canvas,
  versioning, dtwin, evolution, CodeRag, mcp, master)
- Replace the README with a comprehensive monorepo overview
- Update .gitignore to exclude .env, dist/, *.tgz, .DS_Store, and
  other build artifacts and secrets

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bring the source code from the standalone CodeRag and Codeflow_master
repositories into this monorepo under packages/. These packages were
previously developed as separate repos (nehraa/CodeRag and
nehraa/Codeflow_master) but are now first-class packages within
the CodeFlow monorepo.

- packages/CodeRag: local semantic search, vector store, and CodeRag
  pipeline (TypeScript, LanceDB, ONNX embeddings)
- packages/Codeflow_master: the Next.js 15 / React 19 IDE that mounts
  every other package behind a unified canvas

Build artifacts, .env files, node_modules, and editor caches are
excluded via .gitignore.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… .gitignore

Root-level directories AGENTS.md/BACKLOG.md/FEATURES.md/PLAN.md, root
codeflow-core/ (duplicate of packages/codeflow-core), root prd/ (duplicate
of packages/codeflow-prd), root src/ (the IDE's source, now in
packages/Codeflow_master/src), scripts/, e2e/, Codeflow_IDE/, claude-code/,
.playwright-mcp/, .qwen/, .serena/, .github/, plus root package.json,
pnpm-lock.yaml, eslint.config.mjs, next.config.ts, tsconfig.json,
vitest.config.ts, full-demo.mjs, test-npm-packages.mjs, cat-*.png are all
gone.

README quick start now uses pnpm at the workspace root to install every
package in one shot, with a fallback path for working on a single package.

pnpm-workspace.yaml stays because it is what makes packages/ a real
workspace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…on MCP (#34)

Auto-merged by DevPulse PR Watcher (CI green, all checks pass).
…*.loca (#33)

Auto-merged by DevPulse PR Watcher (CI green, all checks pass).
Copilot AI lite review requested due to automatic review settings September 14, 2026 15:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 09fdde54-2aa3-4f53-b1a2-4b2020eb0230


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Decompose CodeFlow into modular workspace packages

✨ Enhancement 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Splits the monolithic application into independently consumable CodeFlow packages.
• Adds graph analysis, execution, versioning, observability, agents, retrieval, and IDE
 capabilities.
• Expands package documentation, tests, fixtures, build outputs, and workspace configuration.
Diagram

graph TD
  PRD["PRD Parser"] --> Core["Core Graph"] --> Analysis["Graph Analysis"] --> IDE["Canvas IDE"]
  Core --> Execution["Execution Engine"] --> Store["State Store"] --> IDE
  Core --> Agent["Agent and MCP"] --> IDE
  Core --> CodeRag["Code Retrieval"] --> Agent
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Split decomposition into package-specific PRs
  • ➕ Makes package boundaries and behavior changes independently reviewable.
  • ➕ Reduces merge-conflict risk and simplifies rollback.
  • ➕ Allows CI validation after each extraction step.
  • ➖ Requires temporary compatibility layers between old and new imports.
  • ➖ Extends the migration timeline and coordination effort.
2. Generate distribution artifacts only in CI
  • ➕ Avoids reviewing duplicated source and compiled output.
  • ➕ Prevents stale JavaScript, declarations, and source maps.
  • ➕ Substantially reduces repository size and conflict frequency.
  • ➖ Consumers cannot use repository snapshots without running builds.
  • ➖ Release automation must reliably package generated artifacts.
3. Retain the monolith with internal modules
  • ➕ Minimizes package-management and release complexity.
  • ➕ Avoids cross-package version and workspace dependency coordination.
  • ➖ Does not provide independently consumable packages.
  • ➖ Preserves tight coupling and limits isolated testing or deployment.

Recommendation: The package decomposition is strategically appropriate, but it should be delivered incrementally and generated dist artifacts should be produced by CI rather than committed. Before merge, reconcile the PR title with the actual repository-wide scope and verify logging policy explicitly: the introduced CodeRag console logger currently emits debug messages without a production-level gate.

Files changed (129) +30050 / -269

Enhancement (65) +15250 / -34
types.tsDefine CodeRag contracts +470/-0

Define CodeRag contracts

• Adds configuration, index, document, graph, retrieval, context, transport, and logger types.

packages/CodeRag/src/types.ts

coderag.tsImplement the CodeRag service +389/-0

Implement the CodeRag service

• Coordinates repository indexing, cached state, semantic retrieval, lookup, explanation, impact analysis, and multi-hop queries.

packages/CodeRag/src/service/coderag.ts

config.tsImplement CodeRag configuration loading +295/-0

Implement CodeRag configuration loading

• Loads, validates, normalizes, and merges file, environment, and runtime configuration.

packages/CodeRag/src/service/config.ts

http.tsExpose CodeRag over HTTP +351/-0

Expose CodeRag over HTTP

• Adds health, indexing, query, lookup, explain, impact, and metrics endpoints.

packages/CodeRag/src/service/http.ts

indexer.tsImplement repository indexing +240/-0

Implement repository indexing

• Builds graph documents, embeddings, manifests, and vector indexes with incremental update support.

packages/CodeRag/src/indexer/indexer.ts

documents.tsCreate retrieval documents from graph nodes +381/-0

Create retrieval documents from graph nodes

• Transforms source and BlueprintGraph metadata into searchable document representations.

packages/CodeRag/src/indexer/documents.ts

gemini-embedder.tsAdd Gemini embedding provider +155/-0

Add Gemini embedding provider

• Implements batched remote embedding requests with dimensionality and error handling.

packages/CodeRag/src/indexer/gemini-embedder.ts

onnx-embedder.tsAdd local ONNX embeddings +147/-0

Add local ONNX embeddings

• Implements local batched embeddings and diagnostic logging through the package logger.

packages/CodeRag/src/indexer/onnx-embedder.ts

search.tsImplement semantic and lexical retrieval +242/-0

Implement semantic and lexical retrieval

• Combines vector search, text matching, filtering, and reranking for graph documents.

packages/CodeRag/src/retrieval/search.ts

multi-hop.tsAdd multi-hop graph retrieval +159/-0

Add multi-hop graph retrieval

• Traverses related nodes across decomposed questions and merges ranked evidence.

packages/CodeRag/src/retrieval/multi-hop.ts

context-builder.tsBuild model-ready code context +194/-0

Build model-ready code context

• Packages primary and related graph documents into bounded LLM context.

packages/CodeRag/src/llm/context-builder.ts

transports.tsAdd LLM transport adapters +340/-0

Add LLM transport adapters

• Provides configurable provider transports and response normalization for generated answers.

packages/CodeRag/src/llm/transports.ts

vector-store.tsImplement vector persistence +220/-0

Implement vector persistence

• Stores embeddings and supports filtered nearest-neighbor retrieval.

packages/CodeRag/src/store/vector-store.ts

server.tsExpose CodeRag MCP tools +126/-0

Expose CodeRag MCP tools

• Adds MCP startup and query tools backed by the CodeRag index.

packages/CodeRag/src/mcp/server.ts

logger.tsAdd structured console logging +23/-0

Add structured console logging

• Adds JSON-formatted debug, info, warning, and error logging. Debug output is currently unconditional and therefore not production-gated.

packages/CodeRag/src/utils/logger.ts

page.tsxAdd the integrated IDE page +63/-0

Add the integrated IDE page

• Composes the header, canvas, sidebars, terminal, orchestration, and VCR controls.

packages/Codeflow_master/src/app/page.tsx

CodeflowCanvas.tsxImplement the master graph canvas +209/-0

Implement the master graph canvas

• Renders typed blueprint, agent, execution, twin, and ghost nodes with interactive graph controls.

packages/Codeflow_master/src/components/canvas/CodeflowCanvas.tsx

AgentOrchestrator.tsxAdd agent orchestration interface +158/-0

Add agent orchestration interface

• Presents agent execution state and coordinates agent-driven work from the IDE.

packages/Codeflow_master/src/components/agent/AgentOrchestrator.tsx

LeftSidebar.tsxAdd IDE navigation sidebar +265/-0

Add IDE navigation sidebar

• Provides package, project, graph, and tool navigation controls.

packages/Codeflow_master/src/components/panels/LeftSidebar.tsx

RightPanel.tsxAdd graph detail panel +244/-0

Add graph detail panel

• Displays selected-node metadata, contracts, analysis, and related controls.

packages/Codeflow_master/src/components/panels/RightPanel.tsx

TerminalPanel.tsxAdd terminal panel +210/-0

Add terminal panel

• Provides terminal-style command output and interaction within the IDE layout.

packages/Codeflow_master/src/components/panels/TerminalPanel.tsx

index.tsWire CodeFlow package adapters +99/-0

Wire CodeFlow package adapters

• Exports the IDE-facing integration surface for graph, agent, analysis, execution, storage, and simulation modules.

packages/Codeflow_master/src/lib/codeflow/index.ts

agent-spawner.tsImplement task agent spawning +185/-0

Implement task agent spawning

• Builds and launches specialized coding agents with execution context and permissions.

packages/codeflow-agent/src/agent/agent-spawner.ts

execution-context.tsBuild agent execution context +200/-0

Build agent execution context

• Combines skills, plugins, MCP tools, session state, and task metadata for agents.

packages/codeflow-agent/src/agent/execution-context.ts

task-queue.tsAdd concurrent task scheduling +105/-0

Add concurrent task scheduling

• Queues dependency-aware tasks and controls concurrent agent execution.

packages/codeflow-agent/src/agent/task-queue.ts

blueprint-generator.tsGenerate blueprints with AI +233/-0

Generate blueprints with AI

• Converts user requirements into validated BlueprintGraph structures through configured model clients.

packages/codeflow-agent/src/ai/blueprint-generator.ts

scaffold-generator.tsImprove generated scaffold semantics +97/-34

Improve generated scaffold semantics

• Uses shared core contracts, marks scaffolds as incomplete, generates typed placeholder returns, and returns HTTP 501 for unimplemented APIs.

packages/codeflow-agent/src/ai/scaffold-generator.ts

refactor-suggester.tsAdd AI refactoring suggestions +438/-0

Add AI refactoring suggestions

• Analyzes source and graph context to propose structured refactoring operations.

packages/codeflow-agent/src/ai/refactor-suggester.ts

manager.tsImplement agent permission policies +166/-0

Implement agent permission policies

• Evaluates operation risk against configurable approval modes before execution.

packages/codeflow-agent/src/permissions/manager.ts

index.tsAdd the agent CLI +459/-0

Add the agent CLI

• Supports plan execution, blueprint execution, code generation, registries, permissions, inspection, and MCP options.

packages/codeflow-agent/src/cli/index.ts

refactor.tsAdd graph refactoring and healing +290/-0

Add graph refactoring and healing

• Detects refactoring candidates and produces graph-healing operations.

packages/codeflow-analysis/src/refactor.ts

invoke.tsAdd analysis invocation dispatcher +179/-0

Add analysis invocation dispatcher

• Normalizes and dispatches analysis, conflict, and refactoring requests for API and CLI consumers.

packages/codeflow-analysis/src/invoke.ts

code-editor.tsxAdd Monaco-based code editing +389/-0

Add Monaco-based code editing

• Provides language-aware editing, completion, diagnostics, file tabs, and change tracking.

packages/codeflow-canvas/src/components/code-editor.tsx

file-tree.tsxAdd repository file navigation +301/-0

Add repository file navigation

• Renders expandable file trees and coordinates file selection with the editor.

packages/codeflow-canvas/src/components/file-tree.tsx

flow-view.tsImplement graph view transformation +1176/-0

Implement graph view transformation

• Transforms BlueprintGraph state into detailed canvas nodes, edges, layouts, styles, and view metadata.

packages/codeflow-canvas/src/lib/flow-view.ts

heatmap.tsAdd graph heatmap calculations +103/-0

Add graph heatmap calculations

• Converts execution and trace measurements into visual node intensity data.

packages/codeflow-canvas/src/lib/heatmap.ts

blueprint-store.tsAdd browser blueprint state +136/-0

Add browser blueprint state

• Implements graph loading, mutation, selection, and persistence for canvas consumers.

packages/codeflow-canvas/src/store/blueprint-store.ts

digital-twin.tsImplement graph digital twins +250/-0

Implement graph digital twins

• Maps traces onto graph nodes, groups user flows, and synthesizes simulation snapshots and spans.

packages/codeflow-dtwin/src/digital-twin.ts

route.tsExpose digital-twin simulation API +70/-0

Expose digital-twin simulation API

• Validates graph and trace input and returns computed simulation output.

packages/codeflow-dtwin/src/api/simulate/route.ts

genetic.tsImplement genetic architecture evolution +851/-0

Implement genetic architecture evolution

• Generates variants and evolves architectures using selection, crossover, mutation, and multidimensional fitness scoring.

packages/codeflow-evolution/src/genetic.ts

index.tsAdd evolution provider selection +27/-0

Add evolution provider selection

• Selects OpenAI, Anthropic, NVIDIA, or Ollama adapters from configuration.

packages/codeflow-evolution/src/providers/index.ts

ghost-nodes.tsAdd predictive ghost nodes +10/-0

Add predictive ghost nodes

• Produces suggested graph nodes representing potential architecture additions.

packages/codeflow-evolution/src/ghost/ghost-nodes.ts

phases.tsImplement execution phase planning +249/-0

Implement execution phase planning

• Builds dependency-aware execution phases and task ownership metadata.

packages/codeflow-execution/src/phases.ts

runtime-workspace.tsImplement isolated runtime execution +1026/-0

Implement isolated runtime execution

• Runs graph tasks in managed workspaces with validation, artifacts, traces, lifecycle state, and cleanup.

packages/codeflow-execution/src/runtime-workspace.ts

runtime-contracts.tsAdd runtime contract validation +475/-0

Add runtime contract validation

• Validates generated artifacts, exports, maturity metadata, and execution evidence.

packages/codeflow-execution/src/runtime-contracts.ts

vcr.tsAdd execution recording and replay +168/-0

Add execution recording and replay

• Records node execution events and reconstructs timelines for replay controls.

packages/codeflow-execution/src/vcr.ts

heatmap.tsAdd execution heatmap aggregation +105/-0

Add execution heatmap aggregation

• Aggregates runtime spans into node-level latency, volume, and failure measurements.

packages/codeflow-execution/src/heatmap.ts

error-localization.tsLocalize execution failures +94/-0

Localize execution failures

• Maps runtime errors and stack evidence back to graph nodes and source locations.

packages/codeflow-execution/src/error-localization.ts

index.tsImplement the MCP server +104/-0

Implement the MCP server

• Creates stdio and HTTP servers and dispatches JSON-RPC lifecycle and tool requests.

packages/codeflow-mcp/src/index.ts

index.tsDispatch MCP blueprint operations +318/-0

Dispatch MCP blueprint operations

• Validates invocation arguments and routes requests to package capabilities.

packages/codeflow-mcp/src/invoke/index.ts

index.tsDeclare MCP tools +22/-0

Declare MCP tools

• Defines the public blueprint tool catalog and input schemas.

packages/codeflow-mcp/src/tools/index.ts

build.tsBuild graphs from parsed requirements +56/-0

Build graphs from parsed requirements

• Creates typed nodes, edges, contracts, and workflows from normalized PRD sections.

packages/codeflow-prd/src/build.ts

index.tsImplement the project store facade +142/-0

Implement the project store facade

• Coordinates filesystem-backed sessions, runs, approvals, checkpoints, branches, and observability state.

packages/codeflow-store/src/store/index.ts

index.tsAdd versioned session persistence +112/-0

Add versioned session persistence

• Saves latest and historical project sessions with normalized project paths.

packages/codeflow-store/src/session/index.ts

index.tsAdd persistent graph branches +149/-0

Add persistent graph branches

• Creates, lists, loads, updates, and removes project-scoped blueprint branches.

packages/codeflow-store/src/branch/index.ts

index.tsAdd filesystem checkpoints +77/-0

Add filesystem checkpoints

• Copies project state into recoverable checkpoint directories with safety validation.

packages/codeflow-store/src/checkpoint/index.ts

index.tsAdd approval persistence +132/-0

Add approval persistence

• Records and resolves risk-aware execution approval requests.

packages/codeflow-store/src/approval/index.ts

index.tsAdd bounded observability storage +83/-0

Add bounded observability storage

• Ingests and retrieves recent spans and logs using configurable ring buffers.

packages/codeflow-store/src/observability/index.ts

index.tsImplement graph risk assessment +212/-0

Implement graph risk assessment

• Scores graph changes and produces approval-oriented risk reports.

packages/codeflow-store/src/risk/index.ts

terminal-sessions.tsManage terminal processes +246/-0

Manage terminal processes

• Creates, tracks, reads, writes, resizes, and terminates local terminal sessions.

packages/codeflow-store/src/shared/terminal-sessions.ts

index.tsImplement structural graph branches +218/-0

Implement structural graph branches

• Creates graph snapshots and computes node and edge changes between branches.

packages/codeflow-versioning/src/branch/index.ts

diff.tsAdd structural graph diffs +44/-0

Add structural graph diffs

• Produces normalized summaries of graph additions, removals, and modifications.

packages/codeflow-versioning/src/diff.ts

index.tsAdd reasoning snapshots +80/-0

Add reasoning snapshots

• Persists and retrieves rationale associated with graph revisions.

packages/codeflow-versioning/src/reasoning/index.ts

search.tsAdd version-aware code retrieval +196/-0

Add version-aware code retrieval

• Searches graph and repository evidence to support versioning explanations and impact analysis.

packages/codeflow-versioning/src/coderag/search.ts

tools.tsExpose versioning tools +297/-0

Expose versioning tools

• Provides high-level branch, diff, reasoning, risk, observability, and retrieval operations.

packages/codeflow-versioning/src/tools.ts

Bug fix (1) +4 / -4
traces.tsAdapt trace overlays to shared schemas +4/-4

Adapt trace overlays to shared schemas

• Imports shared graph types and safely initializes missing trace references while applying spans.

packages/codeflow-canvas/src/lib/traces.ts

Refactor (10) +888 / -137
cycles.tsExtract cycle detection +12/-2

Extract cycle detection

• Moves graph cycle analysis onto shared CodeFlow core types.

packages/codeflow-analysis/src/cycles.ts

metrics.tsExtract structural graph metrics +23/-6

Extract structural graph metrics

• Computes graph-level and node-level architecture measurements using shared schemas.

packages/codeflow-analysis/src/metrics.ts

smells.tsExtract architecture smell detection +36/-9

Extract architecture smell detection

• Detects god nodes, hubs, tight coupling, and related graph smells.

packages/codeflow-analysis/src/smells.ts

conflicts.tsIntegrate repository conflict analysis +40/-10

Integrate repository conflict analysis

• Compares blueprint code-bearing nodes with live repository analysis from 'codeflow-core'.

packages/codeflow-analysis/src/conflicts.ts

blueprint-workbench.tsxExtract the blueprint workbench +305/-0

Extract the blueprint workbench

• Provides the package-level graph workbench and coordinates editing, selection, analysis, and persistence.

packages/codeflow-canvas/src/components/blueprint-workbench.tsx

graph-canvas.tsxExtract the interactive graph canvas +404/-0

Extract the interactive graph canvas

• Implements React Flow rendering, node selection, editing, and graph interactions.

packages/codeflow-canvas/src/components/graph-canvas.tsx

plan.tsAdapt execution planning +3/-3

Adapt execution planning

• Uses the extracted planning implementation and shared BlueprintGraph contracts.

packages/codeflow-execution/src/plan.ts

runner.tsRefactor execution reporting +14/-23

Refactor execution reporting

• Uses shared artifact-path utilities, enriches reports with typed status and validation fields, and re-exports runtime execution.

packages/codeflow-execution/src/runner.ts

prd.tsAdapt PRD parsing to the core package +21/-9

Adapt PRD parsing to the core package

• Moves parsing onto shared schemas and updates inferred graph construction behavior.

packages/codeflow-prd/src/prd.ts

utils.tsRefactor PRD graph utilities +30/-75

Refactor PRD graph utilities

• Imports core schemas and consolidates local node, contract, merge, and edge helpers.

packages/codeflow-prd/src/utils.ts

Tests (10) +2181 / -0
logger.test.tsTest structured console logging +0/-0

Test structured console logging

• Verifies debug, info, and warning output on stdout and error output on stderr.

packages/CodeRag/src/test/logger.test.ts

cycles.test.tsTest graph cycle detection +145/-0

Test graph cycle detection

• Adds coverage for strongly connected components and representative cycle cases.

packages/codeflow-analysis/src/cycles.test.ts

refactor.test.tsTest graph refactoring +362/-0

Test graph refactoring

• Covers candidate detection, healing operations, validation, and error behavior.

packages/codeflow-analysis/src/refactor.test.ts

digital-twin.test.tsTest digital-twin behavior +312/-0

Test digital-twin behavior

• Covers snapshots, active nodes, flow grouping, overlays, simulations, and invalid input.

packages/codeflow-dtwin/src/digital-twin.test.ts

genetic.test.tsTest genetic evolution +188/-0

Test genetic evolution

• Exercises candidate generation, scoring, selection, mutation, and convergence behavior.

packages/codeflow-evolution/src/genetic.test.ts

runner.test.tsTest execution reporting and runs +263/-0

Test execution reporting and runs

• Covers execution results, ownership, failures, artifacts, and runtime behavior.

packages/codeflow-execution/src/runner.test.ts

index.test.tsTest MCP server behavior +149/-0

Test MCP server behavior

• Covers initialization, tool listing, invocation, transports, and errors.

packages/codeflow-mcp/src/index.test.ts

config.test.tsTest observability configuration +49/-0

Test observability configuration

• Verifies defaults, environment overrides, bounds, and invalid settings.

packages/codeflow-store/src/observability/config.test.ts

branch.test.tsTest branch persistence +428/-0

Test branch persistence

• Covers branch lifecycle, isolation, validation, persistence, and failure cases.

packages/codeflow-store/src/branch/branch.test.ts

index.test.tsTest graph branch operations +285/-0

Test graph branch operations

• Covers snapshot creation, structural fingerprints, branch diffs, and edge cases.

packages/codeflow-versioning/src/branch/index.test.ts

Documentation (27) +11015 / -94
README.mdDocument the CodeFlow package platform +181/-94

Document the CodeFlow package platform

• Reframes CodeFlow as a code-as-graph monorepo and describes each package, its architecture, setup, commands, and development model.

README.md

README.mdAdd package documentation index +56/-0

Add package documentation index

• Provides navigation and summaries for the CodeFlow package documentation set.

docs/README.md

PACKAGE_DECOMPOSITION.mdSpecify the monolith decomposition plan +1251/-0

Specify the monolith decomposition plan

• Documents package boundaries, dependency direction, extraction phases, migration risks, and target layouts.

docs/PACKAGE_DECOMPOSITION.md

ai-coding-risk-playbook.mdAdd AI coding risk playbook +140/-0

Add AI coding risk playbook

• Documents safeguards and operational practices for AI-generated software changes.

docs/ai-coding-risk-playbook.md

codeflow-agent.mdDocument the agent package +224/-0

Document the agent package

• Explains agent orchestration, task queues, prompts, permissions, skills, plugins, and MCP integration.

docs/codeflow-agent.md

codeflow-analysis.mdDocument graph analysis capabilities +150/-0

Document graph analysis capabilities

• Describes cycle detection, metrics, smells, conflicts, handlers, and refactoring workflows.

docs/codeflow-analysis.md

codeflow-canvas.mdDocument the canvas package +193/-0

Document the canvas package

• Covers the React Flow workbench, Monaco editors, navigation, heatmaps, traces, and browser storage.

docs/codeflow-canvas.md

codeflow-core.mdDocument the shared graph core +198/-0

Document the shared graph core

• Explains the BlueprintGraph schema, repository analysis, conflicts, exports, and package entry points.

docs/codeflow-core.md

codeflow-dtwin.mdDocument digital-twin simulation +199/-0

Document digital-twin simulation

• Describes span ingestion, active-node calculation, flow grouping, overlays, APIs, and CLI usage.

docs/codeflow-dtwin.md

codeflow-evolution.mdDocument architecture evolution +258/-0

Document architecture evolution

• Explains candidate generation, fitness scoring, providers, genetic operations, and ghost nodes.

docs/codeflow-evolution.md

codeflow-execution.mdDocument blueprint execution +211/-0

Document blueprint execution

• Covers planning, sandboxing, runtime contracts, VCR traces, workspaces, validation, and Mermaid output.

docs/codeflow-execution.md

codeflow-master.mdDocument the integrated IDE +278/-0

Document the integrated IDE

• Describes the Next.js shell, component layout, package adapters, state model, and integration limitations.

docs/codeflow-master.md

codeflow-mcp.mdDocument the MCP package +133/-0

Document the MCP package

• Explains transports, tools, invocation contracts, command-line usage, and server lifecycle.

docs/codeflow-mcp.md

codeflow-prd.mdDocument PRD graph generation +128/-0

Document PRD graph generation

• Describes markdown parsing rules, node inference, edge creation, and build APIs.

docs/codeflow-prd.md

codeflow-store.mdDocument persistent project state +261/-0

Document persistent project state

• Covers sessions, branches, checkpoints, approvals, risk, observability, terminal sessions, and CLI operations.

docs/codeflow-store.md

codeflow-versioning.mdDocument graph versioning +179/-0

Document graph versioning

• Explains structural branches, graph diffs, reasoning snapshots, observability, and CodeRag-backed tools.

docs/codeflow-versioning.md

coderag.mdDocument repository retrieval +376/-0

Document repository retrieval

• Describes indexing, embeddings, vector storage, retrieval, context assembly, transports, HTTP APIs, and MCP tools.

docs/coderag.md

execution-validation-contract.mdDefine execution validation contracts +193/-0

Define execution validation contracts

• Specifies maturity, validation, runtime evidence, and failure semantics for generated artifacts.

docs/execution-validation-contract.md

file-api-design.mdSpecify file API design +557/-0

Specify file API design

• Documents proposed file operations, request contracts, security constraints, and integration behavior.

docs/file-api-design.md

2026-04-21-codeflow-mcp-decomposition.mdPlan MCP package extraction +281/-0

Plan MCP package extraction

• Records the implementation sequence for separating MCP behavior from the application.

docs/superpowers/plans/2026-04-21-codeflow-mcp-decomposition.md

2026-04-23-codeflow-versioning-0.1.0.mdPlan initial versioning package +422/-0

Plan initial versioning package

• Defines the first versioning extraction milestone and validation steps.

docs/superpowers/plans/2026-04-23-codeflow-versioning-0.1.0.md

2026-04-23-codeflow-versioning-0.2.0.mdPlan versioning 0.2 capabilities +854/-0

Plan versioning 0.2 capabilities

• Details expanded branch, retrieval, reasoning, and observability work.

docs/superpowers/plans/2026-04-23-codeflow-versioning-0.2.0.md

2026-04-23-codeflow-versioning-0.3.0.mdPlan versioning 0.3 capabilities +718/-0

Plan versioning 0.3 capabilities

• Describes subsequent versioning integrations, tools, and test requirements.

docs/superpowers/plans/2026-04-23-codeflow-versioning-0.3.0.md

2026-04-23-codeflow-versioning-developer-prompt.mdAdd versioning implementation prompt +1154/-0

Add versioning implementation prompt

• Provides detailed implementation guidance for the versioning package.

docs/superpowers/plans/2026-04-23-codeflow-versioning-developer-prompt.md

2026-04-28-codeflow-agent-implementation.mdPlan agent implementation +1682/-0

Plan agent implementation

• Defines agent architecture, prompts, orchestration, permissions, stores, CLI behavior, and tests.

docs/superpowers/plans/2026-04-28-codeflow-agent-implementation.md

2026-05-13-codeflow-evolution.mdPlan architecture evolution package +462/-0

Plan architecture evolution package

• Documents genetic evolution, provider integration, APIs, CLI behavior, and testing phases.

docs/superpowers/plans/2026-05-13-codeflow-evolution.md

2026-05-16-codeflow-phase2-decomposition.mdPlan second decomposition phase +276/-0

Plan second decomposition phase

• Defines later package extractions and cross-package migration tasks.

docs/superpowers/plans/2026-05-16-codeflow-phase2-decomposition.md

Other (16) +712 / -0
.gitignoreIgnore workspace build and tool artifacts +26/-0

Ignore workspace build and tool artifacts

• Adds exclusions for package builds, archives, CodeRag indexes, environment files, worktrees, and AI-tool working directories.

.gitignore

pnpm-workspace.yamlDefine the package workspace +2/-0

Define the package workspace

• Registers every directory under 'packages/' as a pnpm workspace package.

pnpm-workspace.yaml

package.jsonConfigure the CodeRag package +79/-0

Configure the CodeRag package

• Defines CodeRag entry points, commands, dependencies, and build/test scripts.

packages/CodeRag/package.json

coderag.config.jsonAdd default CodeRag configuration +24/-0

Add default CodeRag configuration

• Provides repository, storage, embedding, retrieval, and transport defaults.

packages/CodeRag/coderag.config.json

package.jsonConfigure the integrated Next.js IDE +49/-0

Configure the integrated Next.js IDE

• Defines the standalone IDE package and its React, Next.js, testing, and styling dependencies.

packages/Codeflow_master/package.json

package.jsonConfigure the agent package +36/-0

Configure the agent package

• Defines agent exports, CLI entry points, dependencies, and test/build commands.

packages/codeflow-agent/package.json

package.jsonConfigure the analysis package +33/-0

Configure the analysis package

• Defines package exports, CLI behavior, core dependency, and Vitest build configuration.

packages/codeflow-analysis/package.json

package.jsonConfigure the canvas package +52/-0

Configure the canvas package

• Defines React component exports, CLI wrapping, peer dependencies, and package build scripts.

packages/codeflow-canvas/package.json

package.jsonPublish shared core entry points +33/-0

Publish shared core entry points

• Defines exports for schema, analyzer, conflicts, artifact export, and storage modules.

packages/codeflow-core/package.json

package.jsonConfigure digital-twin simulation +39/-0

Configure digital-twin simulation

• Defines simulation exports, CLI entry points, dependencies, and package build settings.

packages/codeflow-dtwin/package.json

package.jsonConfigure architecture evolution +41/-0

Configure architecture evolution

• Defines evolution APIs, providers, CLI, core dependencies, and package tooling.

packages/codeflow-evolution/package.json

package.jsonConfigure the execution package +116/-0

Configure the execution package

• Defines execution exports, CLI commands, dependencies, validation scripts, and package build settings.

packages/codeflow-execution/package.json

package.jsonConfigure the MCP package +40/-0

Configure the MCP package

• Defines MCP exports, CLI commands, package files, dependencies, and build tooling.

packages/codeflow-mcp/package.json

package.jsonConfigure the PRD package +26/-0

Configure the PRD package

• Defines PRD parser exports, dependencies, and package build/test scripts.

packages/codeflow-prd/package.json

package.jsonConfigure the storage package +79/-0

Configure the storage package

• Defines storage submodules, CLI entry points, dependencies, and extensive test scripts.

packages/codeflow-store/package.json

package.jsonConfigure graph versioning +37/-0

Configure graph versioning

• Defines branch, diff, reasoning, risk, observability, retrieval, and tool exports.

packages/codeflow-versioning/package.json

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0efd3be168

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"name": "@abhinav2203/codeflow-core",
"version": "1.1.5",
"type": "module",
"main": "./dist/index.js",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore the codeflow-core package contents

This package now contains only package.json; it has no src/, dist/, or build script, while this entry point and every declared subpath point into dist/. npm pack --dry-run therefore produces a tarball containing only package.json, so installing or linking the workspace's @abhinav2203/codeflow-core@1.1.5 makes every import from it fail with ERR_MODULE_NOT_FOUND. Restore the implementation/artifacts (and a build path) before publishing or using this workspace package.

Useful? React with 👍 / 👎.

"types": "./dist/index.d.ts",
"exports": {
".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
"./build": { "types": "./dist/build/index.d.ts", "default": "./dist/build/index.js" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Point the build export to its emitted file

tsc --outDir dist emits src/build.ts as dist/build.js, but this export resolves @abhinav2203/codeflow-prd/build to the nonexistent dist/build/index.js. That deep import is documented as part of the public API, and importing it currently throws ERR_MODULE_NOT_FOUND; point it at the flat emitted file or add the matching barrel.

Useful? React with 👍 / 👎.

"types": "./dist/index.d.ts",
"exports": {
".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
"./agent": { "types": "./dist/agent/index.d.ts", "default": "./dist/agent/index.js" },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add the documented agent barrel

The advertised @abhinav2203/codeflow-agent/agent entry resolves to dist/agent/index.js, but there is no src/agent/index.ts and the committed build output likewise has no such file. The package documentation imports TaskQueue and AgentSpawner through this path, so those documented consumer examples always fail with ERR_MODULE_NOT_FOUND; add an agent barrel or expose the actual module paths.

Useful? React with 👍 / 👎.

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (18) 📘 Rule violations (2) 📜 Skill insights (0)

⚠️ 16 lower-priority findings omitted to fit the comment size limit; re-run the review or view the findings in the Qodo portal.

Grey Divider


Action required

1. The core package cannot be consumed 🐞 Bug ≡ Correctness
Description
packages/codeflow-core/package.json points every public export at dist files even though the
package has no source, build configuration, script, or generated modules capable of creating them. A
normal workspace installation links this local package for compatible sibling dependencies such as
codeflow-agent, while runtime consumers such as codeflow-prd reach the missing schema entry
point.
Code

packages/codeflow-core/package.json[R12-15]

+    "./schema": {
+      "types": "./dist/schema/index.d.ts",
+      "default": "./dist/schema/index.js"
+    },
Evidence
The workspace includes all packages/* directories, so the newly introduced core package is
registered locally; its manifest maps the root and other public exports to nonexistent dist files,
while codeflow-agent declares a compatible dependency on the same package version and
codeflow-prd imports the schema subpath at runtime. Together, these citations show that workspace
resolution selects the incomplete local package and consumers attempt to load entry files it does
not provide.

pnpm-workspace.yaml[1-2]
packages/codeflow-core/package.json[5-32]
packages/codeflow-prd/src/prd.ts[6-7]
packages/codeflow-core/package.json[5-22]
packages/codeflow-agent/package.json[25-29]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The local `@abhinav2203/codeflow-core` workspace package declares root and schema entry points under `dist`, but this PR supplies neither those artifacts nor source and build configuration capable of producing them, while sibling workspaces resolve and import the matching local package.

## Fix Focus Areas
- packages/codeflow-core/package.json[5-32]
- packages/codeflow-prd/src/prd.ts[6-7]
- packages/codeflow-agent/package.json[25-29]

## Recommended Fix
Restore or add the core package source, TypeScript build configuration, and build scripts or generated artifacts as appropriate for this repository, ensuring every declared export exists after a clean build. Alternatively, remove the manifest-only package from the workspace and update consumers to resolve the published dependency deliberately; verify that a clean workspace install can import both the package root and `./schema`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Crafted graphs write outside sandboxes 🐞 Bug ⛨ Security
Description
getNodeDocPath inserts an unchecked node identifier into a relative path that workspace
preparation joins to its temporary directory. A graph containing traversal components in a node
identifier can create directories and overwrite documentation outside the execution workspace.
Code

packages/codeflow-execution/src/internal/typescript-workspace.ts[R150-153]

+  for (const node of graph.nodes) {
+    const docPath = getNodeDocPath(node);
+    const fullDocPath = path.join(workspaceDir, "src", docPath);
+    await fs.mkdir(path.dirname(fullDocPath), { recursive: true });
Evidence
The documentation helper returns docs/${node.id}.md, and the workspace writer joins that value to
the workspace without a resolved-path containment check.

packages/codeflow-execution/src/utils.ts[36-36]
packages/codeflow-execution/src/internal/typescript-workspace.ts[149-159]
packages/codeflow-execution/src/runtime-workspace.ts[612-617]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Graph-controlled node identifiers can escape the temporary runtime workspace when documentation files are generated.

## Fix Focus Areas
- packages/codeflow-execution/src/utils.ts[36-36]
- packages/codeflow-execution/src/internal/typescript-workspace.ts[149-159]

## Recommended Fix
Reject path separators and special path components in node identifiers used as filenames, then resolve the destination and verify it remains beneath the workspace documentation directory before creating or writing it.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Checkpoint writes escape the store 🐞 Bug ⛨ Security
Description
checkpointPath accepts the special identifiers . and .. because its basename comparison treats
them as valid components. Checkpoint creation then recursively copies the target into the store root
or another unintended directory instead of an isolated checkpoint directory.
Code

packages/codeflow-store/src/checkpoint/index.ts[R35-38]

+  // checkpointId is optional - generate one if not provided
+  const effectiveCheckpointId = checkpointId ?? `checkpoint-${Date.now()}`;
+
+  const checkpointDir = checkpointPath(effectiveCheckpointId);
Evidence
The helper's basename check allows .., and checkpoint creation uses the resulting destination in a
recursive forced copy without checking containment under the checkpoint root.

packages/codeflow-store/src/shared/utils.ts[57-64]
packages/codeflow-store/src/checkpoint/index.ts[35-38]
packages/codeflow-store/src/checkpoint/index.ts[45-67]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Special checkpoint identifiers resolve outside the checkpoint namespace and redirect recursive copy operations.

## Fix Focus Areas
- packages/codeflow-store/src/shared/utils.ts[57-64]
- packages/codeflow-store/src/checkpoint/index.ts[35-67]

## Recommended Fix
Reject empty, dot, dot-dot, absolute, and separator-containing checkpoint identifiers. Resolve the destination and require it to be a strict descendant of the configured checkpoint root before copying.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View high (15)
4. Session saves can overwrite other files 🐞 Bug ⛨ Security
Description
saveSession validates only that sessionId is a string before using it as a history filename.
Identifiers containing traversal segments can redirect the history write outside the project's
session-history directory.
Code

packages/codeflow-store/src/session/index.ts[R42-45]

+  if (typeof session.sessionId !== "string") {
+    throw new Error("session.sessionId must be a string");
+  }
+  await ensureDir(sessionDirForProject(session.projectName));
Evidence
The save path accepts any string identifier, while sessionHistoryPath directly interpolates that
value into ${sessionId}.json without sanitization or containment validation.

packages/codeflow-store/src/session/index.ts[42-54]
packages/codeflow-store/src/shared/utils.ts[28-35]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Caller-controlled session identifiers are used as filenames and can traverse outside the session history directory.

## Fix Focus Areas
- packages/codeflow-store/src/session/index.ts[42-54]
- packages/codeflow-store/src/shared/utils.ts[28-35]

## Recommended Fix
Require session identifiers to be safe single path components, then resolve each history destination and verify that it remains beneath the expected project history directory before writing.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. The canvas package exports dead paths 🐞 Bug ≡ Correctness
Description
The canvas manifest maps public subpaths such as flow view and edit to dist/<name>/index.js. Its
build preserves the actual src/lib/*.ts layout as dist/lib/*.js, so installed consumers cannot
resolve those advertised exports.
Code

packages/codeflow-canvas/package.json[R9-12]

+  "exports": {
+    ".": {
+      "types": "./dist/index.d.ts",
+      "default": "./dist/index.js"
Evidence
The manifest expects nested entry directories, while TypeScript emits paths relative to src and
the root module itself imports these implementations from src/lib.

packages/codeflow-canvas/package.json[9-18]
packages/codeflow-canvas/tsconfig.json[7-8]
packages/codeflow-canvas/src/index.ts[20-34]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Canvas subpath exports point to files that its TypeScript build does not produce.

## Fix Focus Areas
- packages/codeflow-canvas/package.json[9-18]
- packages/codeflow-canvas/tsconfig.json[7-8]
- packages/codeflow-canvas/src/index.ts[20-34]

## Recommended Fix
Map each subpath export to its actual `dist/lib/*.js` and declaration file, or change the source/build layout to produce the currently declared targets. Verify all exports against a clean package build.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. The simulation export cannot resolve 🐞 Bug ≡ Correctness
Description
The digital-twin manifest publishes a ./simulate target under dist/simulate/index.js, but no
corresponding source module exists. Consumers using that documented package subpath receive a
module-not-found failure after build or installation.
Code

packages/codeflow-dtwin/package.json[R14-16]

+    "./simulate": {
+      "types": "./dist/simulate/index.d.ts",
+      "default": "./dist/simulate/index.js"
Evidence
The manifest declares a nested simulation module, while the package implementation and root exports
are located in digital-twin.ts and no src/simulate module exists.

packages/codeflow-dtwin/package.json[14-16]
packages/codeflow-dtwin/tsconfig.json[7-9]
packages/codeflow-dtwin/src/index.ts[1-2]
packages/codeflow-dtwin/src/digital-twin.ts[1-1]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The digital-twin simulation subpath references an output for which there is no source module.

## Fix Focus Areas
- packages/codeflow-dtwin/package.json[14-16]
- packages/codeflow-dtwin/src/index.ts[1-2]
- packages/codeflow-dtwin/src/digital-twin.ts[1-1]

## Recommended Fix
Either add `src/simulate/index.ts` and export the intended simulation API, or map `./simulate` to the actual emitted digital-twin module and declaration. Test the subpath from the packed artifact.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Provided implementations never execute 🐞 Bug ≡ Correctness
Description
writeBlueprintGraphToWorkspace() accepts _codeDrafts without reading it and unconditionally
writes generated scaffold modules whose executable functions throw. runBlueprint() forwards
supplied function, API, and class drafts through workspace preparation before invoking the compiled
modules, so the caller’s implementations are replaced by scaffolds.
Code

packages/codeflow-execution/src/internal/typescript-workspace.ts[R120-123]

+export const writeBlueprintGraphToWorkspace = async (
+  workspaceDir: string,
+  graph: BlueprintGraph,
+  _codeDrafts?: Record<string, string>
Evidence
The request passes code drafts through runtime workspace preparation, but the final workspace writer
never reads that argument and unconditionally serializes getStubContent, whose generated body
throws; the runtime then compiles and invokes those workspace modules.

packages/codeflow-execution/src/internal/typescript-workspace.ts[107-146]
packages/codeflow-execution/src/runtime-workspace-local.ts[198-243]
packages/codeflow-execution/src/runtime-workspace.ts[612-616]
packages/codeflow-execution/src/runtime-workspace-local.ts[195-200]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Runtime workspace preparation ignores caller-provided function, API, and class implementation drafts and always writes throwing scaffold functions.

## Fix Focus Areas
- packages/codeflow-execution/src/internal/typescript-workspace.ts[120-146]
- packages/codeflow-execution/src/runtime-workspace-local.ts[195-243]

## Recommended Fix
Map each code draft to its owning code-bearing node and output path, then write the matching supplied draft when present and fall back to the scaffold only when no implementation was provided. Validate the node-to-draft key mapping through `runBlueprint`, and add an integration test that executes a supplied non-throwing implementation.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. The documented replay command fails 🐞 Bug ≡ Correctness
Description
The CLI parser treats bare vcr as if it takes a positional value and consumes the next --graph
flag into opts.vcr. cmdVcr() prefers that malformed value over opts.spans, so the documented
vcr --graph ... --spans ... form tries to read a file named --graph.
Code

packages/codeflow-execution/src/bin/cli.ts[R239-242]

+    else if (arg === "run") { /* default command */ }
+    else if (arg === "plan") opts.plan = true;
+    else if (arg === "vcr") opts.vcr = args[++i] || opts.vcr;
+    else if (arg === "mermaid") opts.mermaid = true;
Evidence
The usage documents option-only syntax, whereas the parser advances past the token after vcr and
the command selects that resulting value as the span path.

packages/codeflow-execution/src/bin/cli.ts[70-74]
packages/codeflow-execution/src/bin/cli.ts[170-177]
packages/codeflow-execution/src/bin/cli.ts[239-242]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `vcr` command consumes its first option flag as a trace-file path.

## Fix Focus Areas
- packages/codeflow-execution/src/bin/cli.ts[70-74]
- packages/codeflow-execution/src/bin/cli.ts[170-177]
- packages/codeflow-execution/src/bin/cli.ts[239-242]

## Recommended Fix
Treat `vcr` as a command without a positional value and obtain the span path exclusively from the parsed `--spans` option, or add an explicit positional syntax that cannot consume flags. Add a CLI test for the documented option-only invocation.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


9. Checkpoint creation ignores the requested name 🐞 Bug ≡ Correctness
Description
The checkpoint CLI parses checkpointId but passes runId as the second argument to
createCheckpointIfNeeded(). Because that API uses its second argument as the directory name,
checkpoint create cp-1 output run-1 writes checkpoints/run-1 rather than the requested
checkpoint.
Code

packages/codeflow-store/src/bin/cli.ts[R80-85]

+    case "checkpoint create": {
+      const checkpointId = rest[0] ?? fail("checkpointId required");
+      const outputDir = rest[1] ?? fail("outputDir required");
+      const runId = rest[2] ?? fail("runId required");
+      const dir = await createCheckpointIfNeeded(outputDir, runId);
+      console.log(JSON.stringify({ checkpointDir: dir }, null, 2));
Evidence
The CLI parses both values but supplies the run ID, and the checkpoint API uses its second argument
as the path component.

packages/codeflow-store/src/bin/cli.ts[80-85]
packages/codeflow-store/src/checkpoint/index.ts[35-38]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The checkpoint CLI sends the run identifier where the storage API expects the checkpoint identifier.

## Fix Focus Areas
- packages/codeflow-store/src/bin/cli.ts[80-85]
- packages/codeflow-store/src/checkpoint/index.ts[35-38]

## Recommended Fix
Pass `checkpointId` as the second argument to `createCheckpointIfNeeded`, retaining `runId` only if it is separately needed for metadata. Add a CLI integration test verifying the requested checkpoint directory.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


10. Reasoning checkpoints can escape the store 🐞 Bug ⛨ Security
Description
Reasoning checkpoint APIs validate runId and taskId only as non-empty strings, then interpolate
both identifiers into filesystem paths without restricting them to safe components or checking
containment. Separator-bearing, traversal, or absolute-path values can redirect save, load, and
clear operations outside the configured project checkpoint hierarchy and storage root.
Code

packages/codeflow-store/src/checkpoint/reasoning.ts[R46-55]

+  const dir = path.join(reasoningCheckpointDir(runId), slugify(projectName));
+  await ensureDir(dir);
+  const cp: ReasoningCheckpoint = {
+    runId,
+    projectName,
+    taskId,
+    content,
+    savedAt: new Date().toISOString()
+  };
+  await fs.writeFile(path.join(dir, `${taskId}.json`), JSON.stringify(cp, null, 2), "utf8");
Evidence
The cited code performs only non-empty-string validation before path construction: runId is joined
directly into the checkpoint directory, while taskId directly forms the JSON filename used by
save, load, and deletion operations. Because those paths are neither constrained to safe components
nor resolved and checked for containment, all three operation types can be redirected beyond their
expected directories.

packages/codeflow-store/src/checkpoint/reasoning.ts[34-55]
packages/codeflow-store/src/checkpoint/reasoning.ts[64-81]
packages/codeflow-store/src/checkpoint/reasoning.ts[119-143]
packages/codeflow-store/src/shared/utils.ts[70-71]
packages/codeflow-store/src/checkpoint/reasoning.ts[53-76]
packages/codeflow-store/src/checkpoint/reasoning.ts[138-150]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Untrusted `runId` and `taskId` values can traverse outside the configured reasoning checkpoint store, allowing reads, writes, and deletions beyond the expected project/run hierarchy.

## Fix Focus Areas
- packages/codeflow-store/src/checkpoint/reasoning.ts[34-81]
- packages/codeflow-store/src/checkpoint/reasoning.ts[119-150]
- packages/codeflow-store/src/shared/utils.ts[70-71]

## Recommended Fix
Validate both identifiers with a shared helper that rejects separators, traversal segments, and absolute paths. Resolve each constructed checkpoint filename against the expected reasoning project/run directory, then verify that the resolved destination is strictly contained within that directory before every read, write, or deletion.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


11. Versioning subpath imports fail at runtime 🐞 Bug ≡ Correctness
Description
The versioning manifest exports observability, risk, and session from nested dist/<name>/index.js
paths even though their implementations are top-level source files. TypeScript emits those files as
top-level dist/<name>.js, so consumers of each advertised subpath receive a module-not-found
error.
Code

packages/codeflow-versioning/package.json[R20-22]

+    "test": "vitest run",
+    "build": "tsc --outDir dist --declaration --declarationMap --noEmit false",
+    "clean": "rm -rf dist"
Evidence
The manifest targets nested paths while all three corresponding implementations are introduced as
top-level source files.

packages/codeflow-versioning/package.json[13-16]
packages/codeflow-versioning/src/observability.ts[1-46]
packages/codeflow-versioning/src/risk.ts[1-43]
packages/codeflow-versioning/src/session.ts[1-36]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Several package export paths point to nested artifacts that this source layout does not build.

## Fix Focus Areas
- packages/codeflow-versioning/package.json[13-15]
- packages/codeflow-versioning/src/observability.ts[1-46]
- packages/codeflow-versioning/src/risk.ts[1-43]
- packages/codeflow-versioning/src/session.ts[1-36]

## Recommended Fix
Point the three subpath exports and declaration targets at `dist/observability.js`, `dist/risk.js`, and `dist/session.js`, or move the sources into matching directory index files. Add package-resolution tests for every exported subpath.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


12. The versioning package root cannot import 🐞 Bug ≡ Correctness
Description
The root entry point loads invoke.js, whose source imports ./branch/index and ./store/index
without ESM file extensions. The package declares type: module, so Node does not perform extension
resolution and fails before consumers can use the root API.
Code

packages/codeflow-versioning/src/invoke.ts[R2-3]

+import { createBranchId, createBranch as createBranchGraph, diffBranches } from "./branch/index";
+import { saveBranch, loadBranch, loadBranches, deleteBranch } from "./store/index";
Evidence
The root re-exports the invoke module, the invoke module has extensionless relative imports, and the
package explicitly opts into Node ESM.

packages/codeflow-versioning/src/index.ts[16-17]
packages/codeflow-versioning/src/invoke.ts[2-3]
packages/codeflow-versioning/package.json[4-7]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The versioning root import reaches extensionless relative imports that Node ESM cannot resolve.

## Fix Focus Areas
- packages/codeflow-versioning/src/invoke.ts[2-3]
- packages/codeflow-versioning/src/index.ts[16-17]
- packages/codeflow-versioning/package.json[4-7]

## Recommended Fix
Change the relative imports in `invoke.ts` to their emitted `.js` specifiers and check all source imports for the same ESM requirement. Add a test that imports the built package root under Node ESM.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


13. The advertised PRD build import fails 🐞 Bug ≡ Correctness
Description
@abhinav2203/codeflow-prd/build is exported as dist/build/index.js, but buildBlueprintGraph is
implemented in the flat source module src/build.ts. With rootDir set to src, compilation emits
dist/build.js and its declaration instead of the nested targets, leaving the advertised subpath
unresolved for installed consumers.
Code

packages/codeflow-prd/package.json[R7-9]

+  "exports": {
+    ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
+    "./build": { "types": "./dist/build/index.d.ts", "default": "./dist/build/index.js" }
Evidence
The package export expects a nested dist/build/index.js artifact, while the implementation is in
the top-level src/build.ts; with TypeScript's rootDir set to src, that source layout emits
dist/build.js and its declaration rather than files under dist/build/index.

packages/codeflow-prd/package.json[7-9]
packages/codeflow-prd/src/build.ts[1-23]
packages/codeflow-prd/package.json[8-9]
packages/codeflow-prd/tsconfig.json[7-8]
packages/codeflow-prd/src/build.ts[1-1]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PRD package advertises a `./build` subpath whose nested targets do not match the flat source and emitted artifact layout.

## Fix Focus Areas
- packages/codeflow-prd/package.json[7-9]
- packages/codeflow-prd/tsconfig.json[7-8]
- packages/codeflow-prd/src/build.ts[1-23]

## Recommended Fix
Update the `./build` export targets to `dist/build.js` and `dist/build.d.ts`, or move the source to `src/build/index.ts` to match the existing manifest. Add a built or packed-package import test for `@abhinav2203/codeflow-prd/build` to validate the published subpath.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


14. Analysis CLI commands run twice 🐞 Bug ≡ Correctness
Description
invoke.ts calls runCLI() at module scope, while the package bin imports runCLI and calls it
again. Every executable invocation consequently duplicates output and starts duplicate asynchronous
conflict analysis work.
Code

packages/codeflow-analysis/src/invoke.ts[R176-179]

+};
+
+// Run when executed directly
+runCLI();
Evidence
The invoke module ends with an unconditional CLI call, and the compiled bin separately imports and
invokes the same function.

packages/codeflow-analysis/src/invoke.ts[176-179]
packages/codeflow-analysis/dist/bin/cli.js[1-6]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Importing the analysis CLI implementation executes it before the bin wrapper invokes it again.

## Fix Focus Areas
- packages/codeflow-analysis/src/invoke.ts[176-179]
- packages/codeflow-analysis/dist/bin/cli.js[1-6]

## Recommended Fix
Remove the module-scope `runCLI()` call and let the bin wrapper be the sole executable entry point, or use a robust direct-execution guard. Add an integration test asserting a command emits one result.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


15. Analysis API endpoints disappear 🐞 Bug ≡ Correctness
Description
The PR deletes the Next route modules for the cycles and smells endpoints and replaces them only
with package-internal handlers. The package does not export or mount those handlers in the
application route tree, so Next cannot discover /api/analysis/cycles or /api/analysis/smells.
Code

src/app/api/analysis/cycles/route.ts[L1-4]

-import { NextResponse } from "next/server";
-
-import { detectCycles } from "@/lib/blueprint/cycles";
-import { blueprintGraphSchema } from "@/lib/blueprint/schema";
Evidence
The removed files were the discoverable application route modules, whereas the replacements live
only in package handler files and are absent from the package export map.

packages/codeflow-analysis/src/handlers/cycles.ts[15-29]
packages/codeflow-analysis/src/handlers/smells.ts[15-29]
packages/codeflow-analysis/package.json[7-13]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The public analysis routes were removed without replacement route modules that Next can discover.

## Fix Focus Areas
- src/app/api/analysis/cycles/route.ts[1-20]
- src/app/api/analysis/smells/route.ts[1-20]
- packages/codeflow-analysis/src/handlers/cycles.ts[15-29]
- packages/codeflow-analysis/src/handlers/smells.ts[15-29]

## Recommended Fix
Keep thin Next route adapters in the application that delegate to the package handlers, or move the handlers into the active Next app route tree. Exercise both endpoints through application-level route tests.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


16. The canvas client bundle imports Node code 🐞 Bug ≡ Correctness
Description
file-tree.tsx declares itself as a client component but imports node:path to compute the
displayed repository name. Browser builds cannot rely on this Node builtin, so rendering the file
tree can fail client compilation or bundling.
Code

packages/codeflow-canvas/src/components/file-tree.tsx[R1-4]

+"use client";
+
+import path from "node:path";
+
Evidence
The module is explicitly client-side, imports node:path, and uses that import from the
client-rendered root-node initializer.

packages/codeflow-canvas/src/components/file-tree.tsx[1-4]
packages/codeflow-canvas/src/components/file-tree.tsx[58-68]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A browser client component imports Node's path module.

## Fix Focus Areas
- packages/codeflow-canvas/src/components/file-tree.tsx[1-4]
- packages/codeflow-canvas/src/components/file-tree.tsx[58-68]

## Recommended Fix
Replace `path.basename` with a small browser-safe pathname splitter, or pass the display name from a server boundary. Ensure the client-component build has no `node:` runtime imports.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


17. Digital twin simulations report no flows 🐞 Bug ≡ Correctness
Description
simulateAction() creates spans but hard-codes both the snapshot and returned flow arrays to empty
values. The generated spans share a trace ID and buildUserFlows() groups them into flows, so
successful simulations incorrectly report zero flows.
Code

packages/codeflow-dtwin/src/api/simulate/route.ts[R50-60]

+  const computedSnapshot: DigitalTwinSnapshot = {
+    projectName: session.graph.projectName,
+    computedAt: new Date().toISOString(),
+    maturity: "preview",
+    activeNodeIds: request.nodeIds,
+    flows: [],
+    observedSpanCount: snapshot.spans.filter(s => s.provenance === "observed").length,
+    simulatedSpanCount: snapshot.spans.filter(s => s.provenance === "simulated").length,
+    observedFlowCount: 0,
+    simulatedFlowCount: 1,
+    activeWindowSecs: 60
Evidence
The simulator hard-codes empty flows even though its span builder assigns a common trace ID and the
flow builder groups spans by that ID.

packages/codeflow-dtwin/src/api/simulate/route.ts[50-68]
packages/codeflow-dtwin/src/digital-twin.ts[76-87]
packages/codeflow-dtwin/src/digital-twin.ts[197-205]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Simulation responses discard flows that can be derived from their generated trace spans.

## Fix Focus Areas
- packages/codeflow-dtwin/src/api/simulate/route.ts[50-68]
- packages/codeflow-dtwin/src/digital-twin.ts[76-87]
- packages/codeflow-dtwin/src/digital-twin.ts[197-205]

## Recommended Fix
Build flows from the generated spans, preferably by using the package's snapshot computation helper, and return the same computed flows in both the snapshot and response. Add a simulation test that expects a non-empty flow for valid node IDs.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


18. MCP initialization sends an invalid response 🐞 Bug ≡ Correctness
Description
startStdioServer() writes the proper initialization response and then writes `jsonRpcResult(null,
{})` as a second message. That helper creates a JSON-RPC response object rather than a notification,
so MCP clients receive an unsolicited response with no matching request ID.
Code

packages/codeflow-mcp/src/invoke/index.ts[R149-154]

+        if (request.method === "initialize") {
+          const response = await handleJsonRpc(request);
+          process.stdout.write(JSON.stringify(response) + "\n");
+          // Send notification that we're ready
+          process.stdout.write(JSON.stringify(jsonRpcResult(null, {})) + "\n");
+          continue;
Evidence
The initialization branch writes two lines, and the second is produced by a helper that always
includes a JSON-RPC response ID.

packages/codeflow-mcp/src/invoke/index.ts[149-154]
packages/codeflow-mcp/src/invoke/index.ts[75-77]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The stdio MCP server emits an extra JSON-RPC response after initialization.

## Fix Focus Areas
- packages/codeflow-mcp/src/invoke/index.ts[149-154]
- packages/codeflow-mcp/src/invoke/index.ts[75-77]

## Recommended Fix
Write only the response returned for the `initialize` request, and emit a protocol-valid notification only when one is required by MCP. Add a protocol test asserting exactly one response per request.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

19. Queries can use stale repository data 📘 Rule violation ≡ Correctness
Description
CodeRag.ensureLoadedState() unconditionally reuses its first in-memory state or hydrates persisted
documents and graph data without comparing manifest hashes, repository revision, or the on-disk
index with the current repository. When files change or a post-commit hook reindexes in another
process, the process-lifetime HTTP service keeps serving the pre-commit state through lookup,
query, explain, and impact until an explicit local reindex occurs.
Code

packages/CodeRag/src/service/coderag.ts[R89-91]

+    const state = await this.indexer.loadState();
+    if (isStateLoaded(state.snapshot, state.documents)) {
+      return this.hydrateState(state.snapshot, state.documents);
Evidence
The cited service code shows that the cache short-circuit is unconditional and that query operations
obtain state through this method, while the indexer hydrates persisted state based only on snapshot
and document presence without checking live file hashes or repository revision. The git-hook
citation shows that post-commit reindexing runs in a separate process, so it cannot replace the HTTP
server's process-lifetime CodeRag instance or its cached state.

Rule 878243: Use caches only as non-authoritative mirrors of the live repository state
packages/CodeRag/src/service/coderag.ts[84-100]
packages/CodeRag/src/indexer/indexer.ts[108-123]
packages/CodeRag/src/service/coderag.ts[84-87]
packages/CodeRag/src/service/coderag.ts[231-232]
packages/CodeRag/src/indexer/git-hook.ts[83-85]
packages/CodeRag/src/service/http.ts[293-317]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
CodeRag serves cached repository state without validating it against the live repository or observing indexes rebuilt by another process, causing long-running servers to retain stale documents, vectors, and graph data after repository changes.

## Fix Focus Areas
- packages/CodeRag/src/service/coderag.ts[84-100]
- packages/CodeRag/src/indexer/indexer.ts[108-123]
- packages/CodeRag/src/indexer/git-hook.ts[83-85]

## Recommended Fix
Track a persisted manifest revision, file hashes, or index modification time when loading state, and compare that marker with the live repository and on-disk index before reusing or hydrating cached state. If it differs, reload or reindex the documents, vectors, and graph data; synchronize reloads so queries cannot observe partially loaded state, and replace the cache only after the authoritative read succeeds.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


20. Retrieval-only mode looks normal 📘 Rule violation ◔ Observability
Description
query() uses the same context-only value for an explicit caller request and for unavailable
answer generation, without recording whether or why degradation occurred. When the language model is
disabled or no transport exists, the command-line path prints only the fallback answer and no
retrieval-only warning.
Code

packages/CodeRag/src/service/coderag.ts[R239-240]

+    const answerMode: QueryResult["answerMode"] =
+      options.includeAnswer === false || !this.config.llm.enabled || !this.config.llmTransport ? "context-only" : "llm";
Evidence
Rule 878246 requires machine-readable degradation metadata and an explicit CLI indicator. The result
records only answerMode: context-only, conflating intentional and unavailable-LLM paths, and the
CLI prints the fallback answer without a banner.

Rule 878246: Explicitly signal retrieval-only degradation in metadata and CLI output
packages/CodeRag/src/service/coderag.ts[239-240]
packages/CodeRag/src/service/coderag.ts[284-291]
packages/CodeRag/src/cli.ts[181-187]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Retrieval-only fallback caused by unavailable answer generation is indistinguishable from an intentionally requested context-only response and has no CLI warning.

## Fix Focus Areas
- packages/CodeRag/src/service/coderag.ts[239-240]
- packages/CodeRag/src/service/coderag.ts[284-291]
- packages/CodeRag/src/cli.ts[181-187]

## Recommended Fix
Add explicit degradation and reason fields for involuntary retrieval-only operation, keep them unset for caller-requested context-only mode, and print a clear retrieval-only degradation banner before CLI fallback output.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 10 rules
Review mode: 🧠 Deep: This is an exceptionally dense, broad cross-cutting change spanning 1,192 files and 1,253 independent hunks, with substantial new logic across multiple packages and production paths, making multiple independent review passes materially valuable.

Grey Divider

Tip of the day
💡 Did you know, you can ask Qodo to dismiss a finding you disagree with, with your reason on record

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +89 to +91
const state = await this.indexer.loadState();
if (isStateLoaded(state.snapshot, state.documents)) {
return this.hydrateState(state.snapshot, state.documents);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

19. Queries can use stale repository data 📘 Rule violation ≡ Correctness

CodeRag.ensureLoadedState() unconditionally reuses its first in-memory state or hydrates persisted
documents and graph data without comparing manifest hashes, repository revision, or the on-disk
index with the current repository. When files change or a post-commit hook reindexes in another
process, the process-lifetime HTTP service keeps serving the pre-commit state through lookup,
query, explain, and impact until an explicit local reindex occurs.
Agent Prompt
## Issue description
CodeRag serves cached repository state without validating it against the live repository or observing indexes rebuilt by another process, causing long-running servers to retain stale documents, vectors, and graph data after repository changes.

## Fix Focus Areas
- packages/CodeRag/src/service/coderag.ts[84-100]
- packages/CodeRag/src/indexer/indexer.ts[108-123]
- packages/CodeRag/src/indexer/git-hook.ts[83-85]

## Recommended Fix
Track a persisted manifest revision, file hashes, or index modification time when loading state, and compare that marker with the live repository and on-disk index before reusing or hydrating cached state. If it differs, reload or reindex the documents, vectors, and graph data; synchronize reloads so queries cannot observe partially loaded state, and replace the cache only after the authoritative read succeeds.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +239 to +240
const answerMode: QueryResult["answerMode"] =
options.includeAnswer === false || !this.config.llm.enabled || !this.config.llmTransport ? "context-only" : "llm";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

20. Retrieval-only mode looks normal 📘 Rule violation ◔ Observability

query() uses the same context-only value for an explicit caller request and for unavailable
answer generation, without recording whether or why degradation occurred. When the language model is
disabled or no transport exists, the command-line path prints only the fallback answer and no
retrieval-only warning.
Agent Prompt
## Issue description
Retrieval-only fallback caused by unavailable answer generation is indistinguishable from an intentionally requested context-only response and has no CLI warning.

## Fix Focus Areas
- packages/CodeRag/src/service/coderag.ts[239-240]
- packages/CodeRag/src/service/coderag.ts[284-291]
- packages/CodeRag/src/cli.ts[181-187]

## Recommended Fix
Add explicit degradation and reason fields for involuntary retrieval-only operation, keep them unset for caller-requested context-only mode, and print a clear retrieval-only degradation banner before CLI fallback output.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +138 to +140
for (const event of events) {
for (const payload of parseSseEvent(event)) {
const token = extractAnswerToken(JSON.parse(payload) as Record<string, unknown>);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

21. Model streams bypass validation 📘 Rule violation ≡ Correctness

readSseResponse() and readNdjsonResponse() cast parsed server payloads to `Record<string,
unknown>` rather than validating a supported response schema. Invalid stream frames can therefore be
silently ignored or surface raw parsing errors across every streaming language-model transport.
Agent Prompt
## Issue description
Streaming LLM responses are parsed and cast without schema validation or deterministic handling of malformed frames.

## Fix Focus Areas
- packages/CodeRag/src/llm/transports.ts[138-153]
- packages/CodeRag/src/llm/transports.ts[191-203]

## Recommended Fix
Define schemas for supported SSE and NDJSON payload variants, validate every parsed frame before extracting tokens, and convert malformed JSON or invalid shapes into controlled transport errors.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +36 to +40
const data = await response.json() as { message?: { content?: string } };
const content = data.message?.content ?? "[]";

const jsonMatch = content.match(/```(?:json)?\n?([\s\S]*?)\n?```/)?.[1] ?? content;
return JSON.parse(jsonMatch) as GhostNode[];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

22. Invalid suggestions enter the graph 📘 Rule violation ≡ Correctness

suggestGhostNodes() casts the Ollama response and its embedded JSON directly to GhostNode[]
without validating required fields, enums, or relationships. A malformed or adversarial local-model
response reaches architecture evolution as trusted graph suggestions.
Agent Prompt
## Issue description
Ollama response data is trusted as graph suggestions without validating its HTTP response shape or generated node array.

## Fix Focus Areas
- packages/codeflow-evolution/src/providers/ollama.ts[36-40]

## Recommended Fix
Create schemas for the Ollama envelope and `GhostNode` array, validate both stages before returning suggestions, and produce a controlled provider error when either payload is invalid.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +66 to +69
constructor(private readonly config: CodeRagConfig, configPath?: string) {
this.manifestStore = new ManifestStore(config.storageRoot);
this.indexLock = new IndexLock(config.storageRoot, config.locking, config.logger);
this.configPath = configPath ?? null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

23. Indexing is tied to disk persistence 📘 Rule violation ⌂ Architecture

RepoIndexer constructs ManifestStore and IndexLock directly instead of accepting persistence
and locking ports from composition code. Alternative hosts must modify indexing business logic to
replace JSON-file storage or filesystem locking.
Agent Prompt
## Issue description
Repository indexing directly constructs concrete filesystem persistence and locking implementations instead of depending on adapter interfaces.

## Fix Focus Areas
- packages/CodeRag/src/indexer/indexer.ts[61-69]
- packages/CodeRag/src/types.ts[428-475]

## Recommended Fix
Define manifest persistence and index-lock interfaces in the ports/types module, inject them into `RepoIndexer`, and move construction of the filesystem implementations to configuration or bootstrap wiring.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread src/app/api/analysis/cycles/route.ts Outdated
Comment on lines -1 to -4
import { NextResponse } from "next/server";

import { detectCycles } from "@/lib/blueprint/cycles";
import { blueprintGraphSchema } from "@/lib/blueprint/schema";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

15. Analysis api endpoints disappear 🐞 Bug ≡ Correctness

The PR deletes the Next route modules for the cycles and smells endpoints and replaces them only
with package-internal handlers. The package does not export or mount those handlers in the
application route tree, so Next cannot discover /api/analysis/cycles or /api/analysis/smells.
Agent Prompt
## Issue description
The public analysis routes were removed without replacement route modules that Next can discover.

## Fix Focus Areas
- src/app/api/analysis/cycles/route.ts[1-20]
- src/app/api/analysis/smells/route.ts[1-20]
- packages/codeflow-analysis/src/handlers/cycles.ts[15-29]
- packages/codeflow-analysis/src/handlers/smells.ts[15-29]

## Recommended Fix
Keep thin Next route adapters in the application that delegate to the package handlers, or move the handlers into the active Next app route tree. Exercise both endpoints through application-level route tests.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +1 to +4
"use client";

import path from "node:path";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

16. The canvas client bundle imports node code 🐞 Bug ≡ Correctness

file-tree.tsx declares itself as a client component but imports node:path to compute the
displayed repository name. Browser builds cannot rely on this Node builtin, so rendering the file
tree can fail client compilation or bundling.
Agent Prompt
## Issue description
A browser client component imports Node's path module.

## Fix Focus Areas
- packages/codeflow-canvas/src/components/file-tree.tsx[1-4]
- packages/codeflow-canvas/src/components/file-tree.tsx[58-68]

## Recommended Fix
Replace `path.basename` with a small browser-safe pathname splitter, or pass the display name from a server boundary. Ensure the client-component build has no `node:` runtime imports.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +50 to +60
const computedSnapshot: DigitalTwinSnapshot = {
projectName: session.graph.projectName,
computedAt: new Date().toISOString(),
maturity: "preview",
activeNodeIds: request.nodeIds,
flows: [],
observedSpanCount: snapshot.spans.filter(s => s.provenance === "observed").length,
simulatedSpanCount: snapshot.spans.filter(s => s.provenance === "simulated").length,
observedFlowCount: 0,
simulatedFlowCount: 1,
activeWindowSecs: 60

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

17. Digital twin simulations report no flows 🐞 Bug ≡ Correctness

simulateAction() creates spans but hard-codes both the snapshot and returned flow arrays to empty
values. The generated spans share a trace ID and buildUserFlows() groups them into flows, so
successful simulations incorrectly report zero flows.
Agent Prompt
## Issue description
Simulation responses discard flows that can be derived from their generated trace spans.

## Fix Focus Areas
- packages/codeflow-dtwin/src/api/simulate/route.ts[50-68]
- packages/codeflow-dtwin/src/digital-twin.ts[76-87]
- packages/codeflow-dtwin/src/digital-twin.ts[197-205]

## Recommended Fix
Build flows from the generated spans, preferably by using the package's snapshot computation helper, and return the same computed flows in both the snapshot and response. Add a simulation test that expects a non-empty flow for valid node IDs.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +149 to +154
if (request.method === "initialize") {
const response = await handleJsonRpc(request);
process.stdout.write(JSON.stringify(response) + "\n");
// Send notification that we're ready
process.stdout.write(JSON.stringify(jsonRpcResult(null, {})) + "\n");
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

18. Mcp initialization sends an invalid response 🐞 Bug ≡ Correctness

startStdioServer() writes the proper initialization response and then writes `jsonRpcResult(null,
{})` as a second message. That helper creates a JSON-RPC response object rather than a notification,
so MCP clients receive an unsolicited response with no matching request ID.
Agent Prompt
## Issue description
The stdio MCP server emits an extra JSON-RPC response after initialization.

## Fix Focus Areas
- packages/codeflow-mcp/src/invoke/index.ts[149-154]
- packages/codeflow-mcp/src/invoke/index.ts[75-77]

## Recommended Fix
Write only the response returned for the `initialize` request, and emit a protocol-valid notification only when one is required by MCP. Add a protocol test asserting exactly one response per request.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +268 to +281
let request: JsonRpcRequest;
try {
request = JSON.parse(body);
} catch {
sendJson(res, {
jsonrpc: "2.0",
id: null,
error: { code: -32700, message: "Parse error" },
});
return;
}

const response = await handleJsonRpc(request);
sendJson(res, response);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

36. Malformed mcp requests receive no response 🐞 Bug ☼ Reliability

The HTTP route passes any JSON value directly to handleJsonRpc(), which immediately destructures
its request argument. A valid body containing null therefore throws before an error response is
formed, leaving the request to fail outside the route's protocol error handling.
Agent Prompt
## Issue description
A syntactically valid but non-object HTTP JSON body can throw before producing a JSON-RPC error.

## Fix Focus Areas
- packages/codeflow-mcp/src/invoke/index.ts[81-82]
- packages/codeflow-mcp/src/invoke/index.ts[268-281]

## Recommended Fix
Validate that parsed JSON is a non-null request object before dispatching, and wrap dispatch in a route-level error handler that returns a JSON-RPC invalid-request response. Add tests for `null`, arrays, and malformed request objects.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants