import type { FeatureFile, ScenarioSlice, TestRun } from "./types.js"; /** * Trunk-based development: the working tree integrates onto main at every * point where it is PROVABLY pipeline-safe, not just at slice end. Inside * a slice those points are the deterministic barriers (contract * regenerated, join green, real API wired) plus the freshly authored * acceptance spec (committed immediately, carrying a @wip marker the CI * acceptance jobs exclude) — each lands as a CHECKPOINT commit that * pushes without blocking. The slice's FINAL commit (markers stripped, * spec armed in CI) is the one whose pipeline the run awaits as the * final arbiter. All mid-slice test execution still happens locally or * directly on the runner hardware — git carries only green states. */ export interface Trunk { /** * A mid-slice integration point: commit everything and push, without * awaiting the pipeline (a checkpoint that goes red asynchronously is * still caught by the final slice commit's awaited pipeline, on the * same sha lineage). A clean tree makes this a no-op — resumed runs * and empty phases must not manufacture commits. */ commitCheckpoint(slice: ScenarioSlice, label: string): Promise; /** * True when the working tree has changes OUTSIDE the run's own bookkeeping * (the .farketari/ journal, ledger and memory). A pipeline-repair session * that touched only bookkeeping did not change the code, so committing it * cannot fix a red pipeline — it would only re-trigger CI and risk a false * green. keepPipelineGreen uses this to refuse a no-op "repair". */ hasSubstantiveChanges(): Promise; /** * Work-preservation commit for ONE lane of the parallel fan-out: * stages ONLY the given repo-relative paths, so another lane's * mid-TDD red state never rides along; commits --no-verify (a * mid-work commit by the hook's own contract) and does NOT push — * the barrier checkpoints push. No-op when the paths hold nothing * new. Lanes share one process and one index, so implementations * serialize these internally. */ commitLaneProgress(slice: ScenarioSlice, label: string, paths: string[]): Promise; commitAndPushSlice(slice: ScenarioSlice): Promise; /** * Wait for the slice commit's real pipeline. Every suite already ran * green locally or on the runner, so red here means environment drift * or infrastructure trouble — the caller runs budgeted repairs armed * with failedPipelineReport(), and reverts the slice when they run * dry: THE TRUNK IS NEVER LEFT RED awaiting a human. */ awaitSlicePipeline(slice: ScenarioSlice): Promise; /** * Fail FAST when the pipeline cannot be observed: resolves the GitLab * coordinates and token (env or the sops secrets tree) and pings the * project API. Called at run start — a missing or powerless token must * surface in the first second, not after the first slice is pushed. */ verifyPipelineAccess(): Promise; /** * Record the trunk sha the slice starts from — the base of a * revertSliceWork rollback. Called once at slice start, before the * slice's first commit; recording twice keeps the first value. */ rememberSliceBase(slice: ScenarioSlice): Promise; /** * The failed jobs of the last red awaited pipeline: job names plus * their log tails, fetched from GitLab — the repair session's evidence. */ failedPipelineReport(): Promise; /** * Roll the trunk back to green: a forward `git revert` of everything * the slice pushed since rememberSliceBase (never a force-push — * history keeps the reverted work for inspection), committed with the * mid-work subject so the version-bump guard defers, and pushed. */ revertSliceWork(slice: ScenarioSlice): Promise; } /** Hand-off — the user closes the outer loop. */ export interface HandOff { /** * Do NOT run the acceptance tests; report readiness, give the three * commands (containers up, frontend dev server, dev acceptance tests), * and list, per slice, the scenarios the tests should now cover. */ reportReadyToRunAcceptanceTests(feature: FeatureFile, slices: ScenarioSlice[]): Promise; /** * Bootstrap hand-off: report the new project's location, what of the * template survived (architecture, harnesses, infra) and what was * stripped, and that every verification gate ran green on the empty * skeleton. The first feature is implemented with `implement`. */ reportProjectBootstrapped(targetDir: string, projectName: string): Promise; }