-
Notifications
You must be signed in to change notification settings - Fork 0
fix(ops): stop tracked live metrics surface from silently reporting a zero pipeline #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c767851
fa9ddc5
3d9545b
5f70db5
d673181
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| #!/usr/bin/env node | ||
| import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
| import { isAbsolute, join, resolve } from "node:path"; | ||
| import { localIsoDate } from "./date-utils.mjs"; | ||
| import { checkProspectReadiness } from "./lib/prospect-readiness.mjs"; | ||
| import { isValidLoomUrl } from "./lib/loom-url.mjs"; | ||
|
|
@@ -14,6 +14,35 @@ const plain = process.argv.includes("--plain"); | |
| const today = localIsoDate(); | ||
| const repoRoot = process.env.SERVICE_REPO_ROOT || process.cwd(); | ||
|
|
||
| // Every read and write is anchored to the service root (SERVICE_REPO_ROOT or | ||
| // the invocation directory) so live metrics regenerated from any working | ||
| // directory report the same pipeline state the rest of the operator surfaces | ||
| // read. | ||
| const resolvedOutputPath = isAbsolute(outputPath) ? outputPath : join(repoRoot, outputPath); | ||
| const prospectRoot = join(repoRoot, "prospects"); | ||
| const trackedMetricsPath = join(repoRoot, "growth-brain/ops/live-metrics.md"); | ||
|
Comment on lines
+21
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When this script is invoked directly from a lane/code checkout with Useful? React with 👍 / 👎. |
||
|
|
||
| // Outbound pipeline state exists only when at least one real prospect folder | ||
| // carries a pipeline record. An absent prospects/ directory AND an empty one | ||
| // (for example one left behind by a private zero-state run) both mean the | ||
| // pipeline is unavailable, never empty. | ||
| const hasProspectPipelineState = existsSync(prospectRoot) | ||
| && listFolders(prospectRoot).some((path) => existsSync(join(path, "pipeline.json"))); | ||
|
|
||
| // The default output is a git-tracked operator surface. When the service root | ||
| // holds no outbound prospect pipeline state, regeneration cannot tell an empty | ||
| // pipeline from an unavailable one, so it refuses instead of silently | ||
| // clobbering the tracked surface with a zero pipeline. Explicit private | ||
| // outputs under runs/ keep generating zero-state reports on purpose. | ||
| const regeneratesTrackedMetrics = resolve(resolvedOutputPath) === resolve(trackedMetricsPath); | ||
| if (regeneratesTrackedMetrics && !hasProspectPipelineState) { | ||
| console.error(`Refusing to regenerate the tracked live metrics with a zero pipeline: no outbound prospect pipeline state found at ${prospectRoot}. Run this command from the service root that holds prospects/, or set SERVICE_REPO_ROOT to it, or pass an explicit --output= under runs/ for a private zero-state report.`); | ||
| process.exit(1); | ||
| } | ||
| if (!hasProspectPipelineState) { | ||
| console.warn(`Warning: no outbound prospect pipeline state found at ${prospectRoot}; pipeline counts in ${outputPath} will be zero.`); | ||
| } | ||
|
|
||
| function listFolders(root) { | ||
| if (root === "prospects" || root.endsWith("/prospects")) return listOutboundProspectFolders(root).filter((path) => !/(^|\/)(?:kit|import)-smoke/.test(path)); | ||
| if (!existsSync(root)) return []; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
npm run growth:cockpitis run after the pipeline changes, this child call now refreshesruns/live-metrics.md, but the generated cockpit still links its “Live Metrics” button to../growth-brain/ops/live-metrics.md(line 207). Because this change deliberately stops nested calls from refreshing that tracked file, the button presents the commit-time snapshot while the cockpit itself uses current counts; update the link and reportedlinksentry to target the private report generated here.Useful? React with 👍 / 👎.