Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

feat: name the generations a Run declares but will not perform

rpone59c7257e2ead
diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.ts
index b9977000..39a8719e 100644
--- a/packages/cli/src/main.ts
+++ b/packages/cli/src/main.ts
@@ -20,6 +20,7 @@ import {
selectArchivedRecord,
summarizeBuildCatalog,
} from "./archive.js";
+import { unreachedGenerations } from "./reachability.js";
import { checkRunFile, collectRunFrontends, loadRunFile } from "./run-file.js";
import type { CliDistribution } from "./distribution.js";
import type {
@@ -1911,17 +1912,19 @@ export async function runCli(
const preflight = args.runtime === undefined
? undefined
: await preflightPlan(await runtimeHost(args.runtime), result.state);
+ const outputNames = Object.fromEntries(result.compilation.author.exports.flatMap((item) =>
+ item.ref.kind === "logical-output" ? [[item.ref.id, item.name]] : []));
writeCliOutput(io, args, {
kind: "plan",
machine: {
format: "hypit.cli-plan@1",
ok: true,
plan: result.definition.plan,
+ unreached: unreachedGenerations(result.compilation.author.graph, result.state, outputNames),
...(preflight === undefined ? {} : { preflight }),
},
run: loaded.path,
- outputNames: Object.fromEntries(result.compilation.author.exports.flatMap((item) =>
- item.ref.kind === "logical-output" ? [[item.ref.id, item.name]] : [])),
+ outputNames,
satisfactionNames: loaded.run.satisfactionNames,
});
} finally {
diff --git a/packages/cli/src/output.ts b/packages/cli/src/output.ts
index 4e93a0ac..dd733f0a 100644
--- a/packages/cli/src/output.ts
+++ b/packages/cli/src/output.ts
@@ -83,6 +83,8 @@ export type PlanOutput = {
readonly format: "hypit.cli-plan@1";
readonly ok: boolean;
readonly plan: BuildPlan;
+ /** Generations the Source declares that these Targets do not reach and no Record supplies. */
+ readonly unreached?: readonly { readonly name: string; readonly producer: string }[];
readonly preflight?: PlanPreflight;
};
@@ -324,6 +326,15 @@ function renderPlan(
}
lines.push(` ${colors.dim("These Needs may reach the Endpoints selected by the Runtime Profile during build.")}`);
}
+ const unreached = view.machine.unreached ?? [];
+ if (unreached.length > 0) {
+ lines.push("", colors.strong("Declared but not reached"));
+ const width = Math.max(...unreached.map((item) => item.name.length));
+ for (const item of unreached) {
+ lines.push(` ${colors.accent(item.name.padEnd(width))} ${colors.dim(item.producer)}`);
+ }
+ lines.push(` ${colors.dim("This Run will not perform these. Either nothing needs them, a Target is missing, or an accepted Record was never pinned.")}`);
+ }
if (view.machine.preflight !== undefined
&& (view.machine.preflight.capabilities.length > 0 || view.machine.preflight.diagnostics.length > 0)) {
lines.push("", colors.strong("Runtime preflight"));
diff --git a/packages/cli/src/reachability.ts b/packages/cli/src/reachability.ts
index 65b1f64f..2d2f706c 100644
--- a/packages/cli/src/reachability.ts
+++ b/packages/cli/src/reachability.ts
@@ -22,20 +22,69 @@ export type UnreachedGeneration = {
export function unreachedGenerations(
graph: CompiledGraph,
state: BuildState,
- names: Readonly<Record<string, string>> = {},
+ outputNames: Readonly<Record<string, string>> = {},
): readonly UnreachedGeneration[] {
const built = new Set<string>();
for (const step of state.plan.steps) {
for (const record of Object.values(step.outputs)) built.add(record);
+ // A Need's result lands through the binding rather than the step's outputs, so a plan that
+ // performs a generation shows it here and nowhere else.
+ for (const binding of Object.values(step.needs)) built.add(binding.result);
}
// A satisfied output is deliberately not produced again; that is reuse working, not a leftover.
for (const selection of state.plan.selections) built.add(selection.record);
+
+ // The author's name for a generation sits on the Logical Output, which selects a Candidate, which
+ // roots at the Operation. Reporting the Operation's internal name instead would be accurate and
+ // useless: nobody searches a Source for "request-nano-banana-2".
+ const candidateById = new Map(graph.candidates.map((item) => [item.id, item]));
+ const namedOperation = new Map<string, string>();
+ for (const output of graph.outputs) {
+ const name = outputNames[output.id];
+ if (name === undefined) continue;
+ const root = candidateById.get(output.primary)?.root;
+ if (root?.kind === "operation") namedOperation.set(root.result.operation, name);
+ }
+
+ // A package expands one authored element into several Operations, and the author's name usually
+ // sits on the last of them — `gpt:Image` generates, then picks the primary image, and the name is
+ // on the pick. Reporting "generation" would be true and unusable, so follow the chain forward to
+ // the first Operation anyone named.
+ const consumers = new Map<string, string[]>();
+ for (const operation of graph.operations) {
+ for (const input of Object.values(operation.inputs)) {
+ const from = input.kind === "operation-result" ? input.operation : input.id;
+ consumers.set(from, [...consumers.get(from) ?? [], operation.id]);
+ if (operation.result.kind === "output" || operation.result.kind === "need") {
+ consumers.set(operation.result.record, [...consumers.get(operation.result.record) ?? [], operation.id]);
+ }
+ }
+ }
+ const authoredName = (start: string, startRecord: string): string | undefined => {
+ const seen = new Set<string>([start]);
+ let frontier = [...consumers.get(start) ?? [], ...consumers.get(startRecord) ?? []];
+ while (frontier.length > 0) {
+ const next: string[] = [];
+ for (const id of frontier) {
+ if (seen.has(id)) continue;
+ seen.add(id);
+ const name = namedOperation.get(id);
+ if (name !== undefined) return name;
+ next.push(...consumers.get(id) ?? []);
+ }
+ frontier = next;
+ }
+ return undefined;
+ };
+
const found: UnreachedGeneration[] = [];
for (const operation of graph.operations) {
if (operation.result.kind !== "need") continue;
if (built.has(operation.result.record)) continue;
found.push({
- name: names[operation.id] ?? names[operation.result.record] ?? operation.result.name,
+ name: namedOperation.get(operation.id)
+ ?? authoredName(operation.id, operation.result.record)
+ ?? operation.result.name,
producer: `${operation.producer.module.name}@${operation.producer.module.version}/${operation.producer.name}`,
});
}
diff --git a/packages/cli/test/reachability.test.ts b/packages/cli/test/reachability.test.ts
index eaad5c63..4f655386 100644
--- a/packages/cli/test/reachability.test.ts
+++ b/packages/cli/test/reachability.test.ts
@@ -9,8 +9,8 @@ const producer = { module: { name: "@hypit/nano-banana", version: "1" }, name: "
const graph = {
format: "hypit.graph@1",
- outputs: [],
- candidates: [],
+ outputs: [{ id: "output:orphan", type: producer, primary: "candidate:orphan" }],
+ candidates: [{ id: "candidate:orphan", type: producer, root: { kind: "operation", result: { kind: "operation-result", operation: "operation:orphan" } } }],
operations: [
{
id: "operation:used", producer, inputs: {},
@@ -41,7 +41,7 @@ const state = {
} as unknown as BuildState;
test("a generation this Run will not perform is named, and reuse is not mistaken for one", () => {
- const found = unreachedGenerations(graph, state, { "operation:orphan": "paper.image" });
+ const found = unreachedGenerations(graph, state, { "output:orphan": "paper.image" });
assert.deepEqual(found.map((item) => item.name), ["paper.image"],
"the planned generation is performed, and the satisfied one is deliberately reused");
assert.equal(found[0]!.producer, "@hypit/nano-banana@1/request-nano-banana-2");
@@ -55,3 +55,30 @@ test("a computed value nothing builds is not reported, because leaving one costs
assert.deepEqual(unreachedGenerations(onlyComputed, state), [],
"components publish Programs beside the Tracks that carry them; only an external request wastes anything");
});
+
+test("a generation is reported under the name the author wrote, not the step inside its package", () => {
+ // One authored element expands to several Operations. gpt:Image generates, then picks the primary
+ // image, and the author's name is on the pick — so the generation alone is called "generation".
+ const expanded = {
+ format: "hypit.graph@1",
+ outputs: [{ id: "output:picked", type: producer, primary: "candidate:picked" }],
+ candidates: [{
+ id: "candidate:picked", type: producer,
+ root: { kind: "operation", result: { kind: "operation-result", operation: "operation:pick" } },
+ }],
+ operations: [
+ {
+ id: "operation:generate", producer, inputs: {},
+ result: { kind: "need", name: "generation", id: "need:generate", record: "record:generated" },
+ },
+ {
+ id: "operation:pick", producer,
+ inputs: { set: { kind: "operation-result", operation: "operation:generate" } },
+ result: { kind: "output", name: "image", record: "record:picked" },
+ },
+ ],
+ } as unknown as CompiledGraph;
+ const empty = { plan: { format: "hypit.plan@1", steps: [], goals: [], selections: [] } } as unknown as BuildState;
+ assert.deepEqual(unreachedGenerations(expanded, empty, { "output:picked": "orphan.image" })
+ .map((item) => item.name), ["orphan.image"]);
+});