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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/forecast-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Show forecast weather, dated events by horizon, affected locations, and lifecycle data gaps in the terminal forecast.
5 changes: 2 additions & 3 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,15 @@ offing forecast [path] [--months <n>] [--as-of <YYYY-MM-DD>] [--svg [--animate]
offing forecast [path] [--months <n>] [--as-of <YYYY-MM-DD>] [--timeline | --json | --format mermaid]
```

Lists what reaches end of life next, grouped by month, from the current scan.
Lists dated end-of-life events in 3-, 6-, and 12-month ranges, with a weather summary and the affected locations. See [Forecast](forecast.md) for the full contract and runnable examples.

| Flag | What it does |
| --- | --- |
| `--months <n>` | How many months ahead to look. Whole number from `1` to `36`; default `12`. |
| `--as-of <YYYY-MM-DD>` | Treat this date as today. |
| `--timeline` | Draw the forecast as a terminal timeline instead of a list. Cannot be combined with `--json` or `--svg`. |
| `--svg` | Print a self-contained SVG timeline for a README or a slide. Cannot be combined with `--timeline` or `--json`. |
| `--animate` | With `--svg`, grow a bar from today to each event in date order and pulse the today marker twice with CSS. `prefers-reduced-motion: reduce` shows the final frame immediately. |
| `--timeline` | Draw the forecast as a terminal timeline instead of a list. Cannot be combined with `--json` or `--format mermaid`. |
| `--timeline` | Draw the forecast as a terminal timeline instead of a list. Cannot be combined with `--json`, `--svg`, or `--format mermaid`. |
| `--format mermaid` | Print a fenced Mermaid Gantt chart of the dated events, grouped by ecosystem. |
| `--json` | Print the forecast document. |

Expand Down
18 changes: 18 additions & 0 deletions docs/decisions/0038-forecast-v1-coverage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 0038 — Add coverage gaps to forecast v1

Status: proposed

A dated forecast groups events that have evidence. A repository can also contain components
with insufficient lifecycle data. Readers need to see these gaps even when the dated event
count is zero.

Keep `ebb.forecast.v1` and its existing fields, including the month groups, event locations,
and counts. Add a `noData` array to the shared forecast schema. Both `offing forecast --json`
and `forecast_repository` always emit the array, even when empty. The schema accepts earlier
v1 documents that omit it.

Each entry carries a component, reference, reporting detector, reason, and repository-relative
location. The report combines unclassified references from the scan with direct npm
declarations that have no package rule in the active data. Coverage gaps do not contribute
to dated event counts. The terminal report displays them separately and uses `cloudy` for
coverage gaps when the near-term bucket has no high or critical repository event.
1 change: 1 addition & 0 deletions docs/decisions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ otherwise. Records are numbered in the order they were written; this page groups
| [0028](0028-mcp-schema-inlining-fails-closed.md) | Publish a self-contained MCP output schema | Inline every cross-file `$ref` before the MCP server advertises a tool's schema and throw when one cannot resolve; same-document references stay, and sibling keywords win over the inlined target. |
| [0032](0032-split-mcp-tools-into-one-file-per-tool.md) | Split the MCP server into one file per tool | Give each MCP tool its own file under `src/mcp/tools/`, list them in a small registry, and prove with a `tools/list` snapshot that no advertised name, description, input schema, output schema, or annotation changed. |
| [0033](0033-required-source-access-date.md) | Require the retrieval date on every lifecycle source | Make `sources[].accessedAt` required in registry v2, backfill every bundled record, and let the importer runner stamp the run date so every finding shows when its source was read. |
| [0038](0038-forecast-v1-coverage.md) | Add coverage gaps to forecast v1 | Add an optional `noData` field to the CLI and MCP forecast schema. Producers always emit the array. |
| [0037](0037-recommend-version-from-bundled-data.md) | Recommend a release line from bundled data only | Add `recommend_version` and `offing recommend`: the newest unended line whose end date is at least 180 days away, from bundled rules only; `no-data` is explicit and never says "latest". |
| [0036](0036-corpus-schema-deno-elixir.md) | Add Deno and Elixir to the public validation schema | Add `deno` and `elixir` to the published corpus ecosystem enum when those detectors gain a public corpus. The change is additive. |
| [0034](0034-detector-limits-in-the-sdk.md) | Publish the detector limits in the SDK | Export `DETECTOR_LIMITS` and its `DetectorLimits` type so the file-size, depth, and vendored-directory bounds are part of the typed detector contract and conformance reads them from there. |
Expand Down
108 changes: 108 additions & 0 deletions docs/forecast.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
title: Forecast end of life
description: See upcoming end-of-life dates, affected files, and gaps in lifecycle data.
---

# Forecast end of life

`offing forecast [path]` scans the repository and shows what reaches a dated end of life
within the selected window. The path defaults to the current directory.

The terminal report groups events into 0–3, 3–6, and 6–12 month ranges. Each cutoff day
belongs to the range that ends on it. A shorter window ends at the requested month.
A window longer than 12 months adds a final range. Within each range, repository events
appear by date with their repository-relative paths and available line numbers. The count
labelled `elsewhere` covers dated events with zero findings in this repository.

The first line summarizes the nearest range:

- `storm` means at least one repository event is high or critical.
- `cloudy` means the nearest range has a lower-severity repository event or the report has coverage gaps.
- `clear` means the nearest range has zero repository events and the report found zero coverage gaps. Read the later ranges for upcoming work.

The **No data** section lists declarations the scan could not classify and direct npm dependencies
in the root or its workspaces that have no rule in the active data. Each entry gives its reason and
location. The forecast covers dated events and the gaps Offing identified.

| Option | Effect |
| --- | --- |
| `--months <n>` | Set the horizon to a whole number from 1 to 36. Default 12. |
| `--as-of <YYYY-MM-DD>` | Use the specified day at midnight UTC. Default is today's UTC date. `--today` is an alias. |
| `--data-version <version>` | Pin the lifecycle data. Use `bundled` for the data shipped with this build. |
| `--no-cache` | Run a fresh scan. An explicit reference day also uses a fresh scan. |
| `--json` or `--format json` | Print the versioned forecast document. |
| `--format text` | Print the default terminal report. It uses plain labels with or without `NO_COLOR`. |
| `--timeline` | Print a bar chart grouped by calendar month. `NO_COLOR=1` uses ASCII bars. |
| `--svg [--animate]` | Write a self-contained SVG. `--animate` enables CSS animation. |
| `--format mermaid` | Print a Mermaid Gantt chart grouped by ecosystem. |

An invalid horizon or date exits with status 2. A replay uses the files present when you
run the command. To repeat a forecast, use the same checkout, date, and data version.

## JSON contract

The [forecast v1 schema](../schemas/forecast.v1.schema.json) describes the document.
`schemaVersion` is `ebb.forecast.v1`. The document includes `root`, `today`, `until`,
`months`, and `groups` of events by calendar month. Each event carries its date, rule,
severity, source, and finding locations. `affecting` counts events with findings and
`total` counts all dated events in the window. `noData` contains the coverage gaps and is
an empty array when the report finds zero gaps.

## Examples

Run these from an Offing checkout after `npm ci`. The example runner builds the CLI and
restores the fixtures' original filenames in a temporary directory.

### Replay a near-term deadline

```bash
npm run example --silent -- demo forecast --as-of 2025-03-01 --months 3 --data-version bundled
```

```text
Weather: storm
Forecast from 2025-03-01 to 2025-06-01 (3 months)

0-3 months
1 affecting this repository, 2 elsewhere
2025-04-30 Node.js 18 is end-of-life [high] (nodejs.runtime.eol-18)
package.json:5
```

### Read affected locations in plain text

```bash
NO_COLOR=1 npm run example --silent -- drift/nodejs forecast --as-of 2027-02-01 --months 3 --data-version bundled
```

```text
Weather: cloudy
Forecast from 2027-02-01 to 2027-05-01 (3 months)

0-3 months
2 affecting this repository, 0 elsewhere
2027-04-30 Node.js image release line 22 reaches end-of-life on 2027-04-30 [low] (container.node.eol-22-and-older)
Dockerfile:1
2027-04-30 Node.js 22 reaches end-of-life on 2027-04-30 [low] (nodejs.runtime.eol-22)
.github/workflows/ci.yml:10
.nvmrc:1
package.json:8
```

### Read the version and counts from JSON

```bash
npm run example --silent -- drift/nodejs forecast --as-of 2027-02-01 --months 3 --data-version bundled --json |
node -e 'const { schemaVersion, months, affecting, total, noData } = JSON.parse(require("node:fs").readFileSync(0, "utf8"))
console.log(JSON.stringify({ schemaVersion, months, affecting, total, noData }, null, 2))'
```

```json
{
"schemaVersion": "ebb.forecast.v1",
"months": 3,
"affecting": 2,
"total": 2,
"noData": []
}
```
27 changes: 26 additions & 1 deletion schemas/forecast.v1.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,32 @@
}
},
"affecting": { "type": "integer", "minimum": 0 },
"total": { "type": "integer", "minimum": 0 }
"total": { "type": "integer", "minimum": 0 },
"noData": {
"description": "Components without local lifecycle coverage. Current producers always include this array.",
"type": "array",
"items": {
"type": "object",
"required": ["detector", "component", "reference", "reason", "location"],
"additionalProperties": false,
"properties": {
"detector": { "type": "string" },
"component": { "type": "string" },
"reference": { "type": "string" },
"reason": { "type": "string" },
"location": {
"type": "object",
"required": ["path"],
"additionalProperties": false,
"properties": {
"path": { "type": "string" },
"line": { "type": "integer", "minimum": 1 },
"column": { "type": "integer", "minimum": 1 }
}
}
}
}
}
},
"$defs": {
"event": {
Expand Down
13 changes: 13 additions & 0 deletions src/agent-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { resolve } from "node:path";
import { findingFingerprint } from "./baseline.js";
import { bundledRules } from "@velella/ebb/bundled-rules";
import type { DataInfo, Finding, ScanResult, Severity, SourceLocation, VerificationCommand } from "./domain.js";
import { buildRepositoryForecast, replayScanOptions } from "./forecast.js";
import type { RepositoryForecast } from "./forecast.js";
import { createMigrationPacket } from "./migration-packet.js";
import type { Receipt } from "./receipt.js";
import { buildReceipt } from "./receipt.js";
Expand Down Expand Up @@ -91,6 +93,17 @@ export class OffingAgentTools {
return result;
}

/** Scan once and preserve the finding references exposed by the forecast tool. */
async forecast(repositoryPath: string, months: number, asOf: string | undefined): Promise<RepositoryForecast> {
const { result } = await runScanRequest({
root: repositoryPath,
...(asOf === undefined ? {} : { today: asOf, engine: replayScanOptions(asOf) }),
});
const forecast = await buildRepositoryForecast(result, months);
this.remember(result);
return forecast;
}

async list(repositoryPath = "."): Promise<DeprecationList> {
const result = await this.scan(repositoryPath);
return {
Expand Down
29 changes: 15 additions & 14 deletions src/commands/forecast.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import process from "node:process";

import { bundledRules } from "@velella/ebb/bundled-rules";
import { builtInDetectors } from "../detectors/index.js";
import { scanRepository } from "../engine/index.js";
import type { Forecast } from "@velella/ebb/forecast";
import { buildForecast, DEFAULT_FORECAST_MONTHS, MAX_FORECAST_MONTHS, renderForecastText } from "@velella/ebb/forecast";
import { DEFAULT_FORECAST_MONTHS, MAX_FORECAST_MONTHS } from "@velella/ebb/forecast";
import { buildRepositoryForecast, renderForecastText, replayScanOptions } from "../forecast.js";
import type { RepositoryForecast } from "../forecast.js";
import { renderForecastSvg } from "../forecast-svg.js";
import { renderForecastTimeline } from "../forecast-timeline.js";
import { renderForecastMermaid } from "../reporters.js";
import { scanWithBuiltIns } from "../scan-builtins.js";
import type { Gated } from "./runtime.js";
import { afterGates, preScanPhase, repositoryPhase } from "./runtime.js";
import type { CliCommand, CommandContext } from "./types.js";
Expand Down Expand Up @@ -56,7 +55,7 @@ function forecastMonthsFailure(months: number, ctx: CommandContext): number | un
}

/** Prints the forecast in the selected mode: the SVG, the mermaid block, the timeline, JSON, or text. */
function printForecast(forecast: Forecast, modes: ForecastModes): void {
function printForecast(forecast: RepositoryForecast, modes: ForecastModes): void {
if (modes.svg) {
process.stdout.write(`${renderForecastSvg(forecast, { animate: modes.animate })}\n`);
return;
Expand All @@ -79,8 +78,8 @@ export const command: CliCommand = {
flags: ["--months", "--as-of", "--today", "--svg", "--animate", "--timeline", "--json", "--format", "--data-version"],
example: "offing forecast . --months 6",
usage: [
" offing forecast [path] [--months <n>] [--as-of <YYYY-MM-DD>] [--svg [--animate] | --timeline | --json | --format mermaid] # what reaches end of life next, by month",
" offing forecast [path] [--months <n>] [--as-of <YYYY-MM-DD>] [--timeline | --json | --format mermaid] # what reaches end of life next, by month",
" offing forecast [path] [--months <n>] [--as-of <YYYY-MM-DD>] [--svg [--animate] | --timeline | --json | --format mermaid] # what reaches end of life next, by horizon",
" offing forecast [path] [--months <n>] [--as-of <YYYY-MM-DD>] [--timeline | --json | --format mermaid] # what reaches end of life next, by horizon",
],
usageSlots: [13, 14],
run(args, ctx) {
Expand All @@ -99,16 +98,18 @@ export const command: CliCommand = {
const modeFailure = forecastModeFailure(modes, ctx);
if (modeFailure !== undefined) return modeFailure;
const monthsValue = state.optionValue("--months");
const months = monthsValue === undefined ? DEFAULT_FORECAST_MONTHS : Number(monthsValue);
const months = state.args.includes("--months") ? Number(monthsValue) : DEFAULT_FORECAST_MONTHS;
const monthsFailure = forecastMonthsFailure(months, ctx);
if (monthsFailure !== undefined) return monthsFailure;
const asOfValue = state.optionValue("--as-of") ?? state.optionValue("--today");
const forecast = buildForecast(
await scanRepository(state.pathArgument, builtInDetectors, { noCache: state.noCache }),
await bundledRules(),
asOfValue ?? new Date().toISOString().slice(0, 10),
months,
if (asOfValue === undefined && (state.args.includes("--as-of") || state.args.includes("--today"))) {
return ctx.fail("usage", "--as-of (or --today) must be a date (YYYY-MM-DD).");
}
const scan = await scanWithBuiltIns(
state.pathArgument,
asOfValue === undefined ? { noCache: state.noCache } : replayScanOptions(asOfValue),
);
const forecast = await buildRepositoryForecast(scan, months);
printForecast(forecast, modes);
return 0;
});
Expand Down
2 changes: 1 addition & 1 deletion src/engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export async function scanRepository(

// One timestamp for the whole scan: detectors that need "today" (CLE scheduled dates) read it from
// context instead of the clock, so findings stay deterministic for this run.
const scannedAt = new Date();
const scannedAt = new Date(options.scannedAt ?? Date.now());
const contextScannedAt = options.scannedAt ?? scannedAt.toISOString();
const context = { root: resolvedRoot, scannedAt: contextScannedAt };

Expand Down
25 changes: 24 additions & 1 deletion src/forecast-timeline.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
import type { Forecast } from "@velella/ebb/forecast";
import { addMonths } from "@velella/ebb/forecast";
import type { Forecast, ForecastEvent } from "@velella/ebb/forecast";

interface ForecastBucket {
label: string;
events: ForecastEvent[];
}

/** Split the existing events at inclusive calendar-month cutoffs, retaining any longer horizon. */
export function forecastBuckets(forecast: Forecast): ForecastBucket[] {
const cutoffs = [3, 6, 12].filter((months) => months < forecast.months);
const ends = [...cutoffs.map((months) => addMonths(forecast.today, months)), forecast.until];
const buckets: ForecastBucket[] = [...cutoffs, forecast.months].map((end, index) => ({
label: `${cutoffs[index - 1] ?? 0}-${end} months`,
events: [],
}));

const events = forecast.groups.flatMap((group) => group.events);
events.sort((left, right) => left.date.localeCompare(right.date) || left.ruleId.localeCompare(right.ruleId));
for (const event of events) {
buckets[ends.findIndex((until) => event.date <= until)]?.events.push(event);
}
return buckets;
}

export interface ForecastTimelineOptions {
/** Total width in columns. Defaults to 80. */
Expand Down
Loading
Loading