Skip to content

fix(topology): read block dependencies from local pipeline YAML#52

Open
loadez wants to merge 1 commit into
mainfrom
fix/critical-path-local-yaml-deps
Open

fix(topology): read block dependencies from local pipeline YAML#52
loadez wants to merge 1 commit into
mainfrom
fix/critical-path-local-yaml-deps

Conversation

@loadez

@loadez loadez commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Problem

sem-ai critical-path and sem-ai pipeline topology reported every block with no dependencies, so the critical path was always a single block (depth 1) regardless of the real DAG.

Root cause is in fetchTopology: it only tries to obtain the pipeline YAML by fetching it as a workflow artifact (.semaphore/semaphore.yml). But the pipeline definition isn't a job artifact, so that fetch always misses — and the v1alpha pipeline-describe response carries block name/state/result but no dependency info. With no YAML, every block fell back to dependencies: [].

Fix

  • cmd/topology_commands.go — add a local fallback (localPipelineDeps): when the artifact fetch yields nothing, read the pipeline YAML from the working tree (<working_dir>/<yaml_file>, default .semaphore/semaphore.yml) and parse block dependencies. This is the common case — you run critical-path from the repo, where the YAML lives. The result's source field now reports v1alpha+artifact / v1alpha+local / v1alpha+none for transparency.
  • cmd/topology_test.go — regression test (TestLocalPipelineDeps): writes a .semaphore/semaphore.yml with a Build→Test→Deploy chain, asserts deps parse and computeCriticalPath returns the full 3-block chain; missing file → nil.

The existing parseYAMLDependencies / computeCriticalPath units were already correct and tested — the gap was purely that the YAML was never read.

Verification

Against a real 6-block pipeline (Build → {Unit, Race, Vet} → Integration → Package):

before: { "critical_path": ["Build"], "depth": 1 }
after:  { "critical_path": ["Build","Unit tests","Integration","Package"], "depth": 4, "total_blocks": 6 }

go test ./..., go vet ./... pass.

Tracking

renderedtext/project-tasks#3414

critical-path and pipeline topology returned every block with empty
dependencies, so the critical path was always a single block (depth 1).
fetchTopology only tried to fetch the pipeline YAML as a workflow artifact,
but the pipeline definition isn't a job artifact — that fetch always misses,
and the v1alpha pipeline API doesn't carry per-block dependencies.

Add a local fallback: when the artifact fetch comes up empty, read the
pipeline YAML from the working tree (.semaphore/semaphore.yml) — where the
block dependencies actually live — and parse them. Surface which source was
used via the result's "source" field. Adds a regression test.
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.

1 participant