sflow Code Review
Structured review of sflow changes against four aspects: functional defects, modular structure, duplication, and test coverage. Findings are advisory — report them, do not silently rewrite the author's code unless asked.
When to use
- The user asks to review a diff, branch, PR, staged changes, or "my sflow changes".
- Before committing or opening a PR in this repo.
- After finishing a feature/fix and you want a self-check.
Review workflow
Copy this checklist into TodoWrite and work through it in order:
- [ ] Step 0: Scope the change (collect the diff + changed symbols)
- [ ] Aspect 1: Functional defects in the changed lines
- [ ] Aspect 2: Modular / by-purpose structure
- [ ] Aspect 3: Redundant logic that should be consolidated
- [ ] Aspect 4: Test coverage + test-integrity policy
- [ ] Verify: run focused tests / coverage / dry-run
- [ ] Report findings grouped by aspect and severity
Do not skip Step 0 — every later aspect needs the exact set of changed files and symbols.
Step 0: Scope the change
Activate the venv first (project rule), then collect the diff. Pick the base ref that
matches what is being reviewed (main, a PR base, --staged, or HEAD~1).
source .venv/bin/activate # Windows: .venv\Scripts\activate
git status
git diff --stat main...HEAD # files touched
git diff main...HEAD # full change (or --staged for staged review)
Then, for each non-trivial changed function/class/method, find its callers (the blast
radius) with a quick search — e.g. grep -rn "changed_symbol" src tests — so you know
what an incompatible change would break. Confirm the change set only touches what the
author intended, and that every direct caller of a changed signature/default was updated.
Note the area each file belongs to (see reference.md layer map) — this drives Aspects 2–4.
Aspect 1 — Functional defects
Read every changed hunk and ask "what input makes this wrong?" Prioritize the changed lines and their direct callers (found in Step 0).
General checks:
- Edge cases:
None/empty/missing keys, empty lists, zero/negative counts, off-by-one. - Mutable default args, shared mutable state, accidental aliasing of dicts/lists.
- Error handling: swallowed exceptions, wrong exception type, missing
sflowexceptions.pyusage, unclear messages. - Control flow: inverted conditions, early
return/continueskipping cleanup. - Backward compatibility: changed function signatures, renamed YAML keys, changed defaults — confirm all direct callers were updated.
sflow-specific defect hotspots (verify the behavior end to end, not just locally):
- CLI flag threading (
cli/run.py,cli/batch.py): a new flag must flow CLI →app/sflow.py→ assembly → backend/operator. A flag parsed but never passed down is a classic silent defect — confirm it reaches the backend and shows in--dry-run. - Expression/variable resolution (
config/resolver.py,resolution.py):${...}expansion, variable precedence,--set/ CSV overrides. - Task graph / DAG (
app/assembly.py,core/): dependencies,missable_tasks, replicas, resource placement. - Backends (
plugins/backends/):salloc/srun/#SBATCHflag construction,extra_argsmerge/de-dup, container mounts. - Probes (
plugins/probes/): readiness/failure conditions, timeouts, log-watch regex. - Artifacts (
plugins/artifacts/):file://content, same-path auto-mount across backends. - Results & uploads (
core/results.py,core/uploads.py,plugins/storage/):result:parsing (regex map /patterns/ JSONfile:—patternsandfileare mutually exclusive) writingresult.json+results.json;uploads:/upload_allfire at task finalize beforeCOMPLETED; the S3 credential chain (boto3) must never be hard-coded in YAML. - Hardware monitor (
app/monitor_planner.py,monitoring/):monitor:scopes / interval / report; monitors are passive (never reserve nodes/GPUs); backendcapabilities.supports_host_monitoringgates it (kubernetes = unsupported); a new--enable-workflow-monitor/--enable-task-monitorpath must thread into a planned monitor. - Dry-run vs real-run parity: logic gated only on
dry_runcan hide real-run bugs.
See reference.md for the full hotspot list.