Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
cfddc1d
docs(spec): .devloop-Config aus der Basis, Review-Pflicht für Config-…
TMogdans Nov 27, 2026
3fc6a64
feat(#13): .devloop-Config aus der Basis lesen, Config-Änderungen bra…
TMogdans Nov 27, 2026
086e5a0
test(#13): Detektoren für Config aus der Basis (CLI, Action im checko…
TMogdans Nov 27, 2026
7bdbf45
Merge Tests REQ-CFGBASE
TMogdans Nov 27, 2026
a2e1927
Merge Implementierung REQ-CFGBASE
TMogdans Nov 27, 2026
105b820
Merge branch 'test/config-aus-basis' into impl/config-aus-basis
TMogdans Nov 27, 2026
bbb8373
fix(#13): init meldet ungedeckte tier-map außerhalb von .devloop/ in …
TMogdans Nov 27, 2026
97ce711
test(#13): Action-Schritte mit GitHubs bash-Semantik (-eo pipefail) a…
TMogdans Nov 27, 2026
75adeb4
Merge branch 'impl/config-aus-basis' into test/config-aus-basis
TMogdans Nov 27, 2026
dba2d05
fix(#13): Tier-Schritt der Action bricht bei derive-tier-Fehler ab, a…
TMogdans Nov 27, 2026
4c4eabc
Merge Tests REQ-CFGBASE (bash-Semantik wie GitHub)
TMogdans Nov 27, 2026
aacab97
Merge Implementierung REQ-CFGBASE (init-Hinweis, Tier-Schritt)
TMogdans Nov 27, 2026
c19fff1
fix(#13): init bildet relative Pfade mit path.relative (Schrägstrich …
TMogdans Nov 27, 2026
a40f6b2
test(#13): Symlink in der Basis (config-invalid), Tier-Schritt ohne -e
TMogdans Nov 27, 2026
938d28c
Merge Detektoren Symlink-Basis und Tier-Schritt ohne -e
TMogdans Nov 27, 2026
00b2ba8
Merge init-Pfade per path.relative
TMogdans Nov 27, 2026
b1c4e5a
docs(#13): Symlink auf .devloop als bekannte Grenze (F3)
TMogdans Nov 27, 2026
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
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "devloop",
"version": "0.10.3",
"version": "0.11.0",
"description": "Generische agentische Dev-Loop-Kette: /devloop:specify|spec-to-tests|implement|critic|loop + Bindungs-Anker (Wächter-Vorbedingung, content-gebundene Stopps, CI-Required-Check). Projektübergreifend.",
"author": { "name": "Tobias Mogdans" }
}
10 changes: 5 additions & 5 deletions .github/actions/precondition-check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ runs:
run: |
set -o pipefail
DIFF=$(git diff --no-renames -z --name-only "origin/$BASE"...HEAD | jq -Rs 'split("\u0000") | map(select(length>0))')
jq -n --argjson touched "$DIFF" '{touched:$touched, repo:"."}' \
| node "$GITHUB_ACTION_PATH/../../../dist/cli/derive-tier.js" > tier.json
jq -n --argjson touched "$DIFF" --arg baseRef "origin/$BASE" '{touched:$touched, repo:".", baseRef:$baseRef}' \
| node "$GITHUB_ACTION_PATH/../../../dist/cli/derive-tier.js" > tier.json || exit 1
cat tier.json

- name: Drift guard — tier-map T2/T3 paths covered by CODEOWNERS (§9)
shell: bash
run: node "$GITHUB_ACTION_PATH/../../../dist/cli/check-codeowners.js" .

# protected-globs.json und bot-logins.json liest verify-review selbst aus der Basis (baseRef);
# ein PR kann sich die Regeln, nach denen er geprueft wird, nicht selbst setzen (#13).
- name: Verify HUMAN approval on HEAD + no gate-tamper (fail-closed)
shell: bash
env:
Expand All @@ -62,10 +64,8 @@ runs:
--arg headRef "$HEAD_REF" \
--arg baseRef "origin/$BASE" \
--arg tier "$(jq -r .tier tier.json)" \
--argjson bots "$(cat .devloop/bot-logins.json)" \
--argjson diff "$DIFF" \
--argjson protected "$(cat .devloop/protected-globs.json)" \
'{reviews:$reviews, prAuthor:$prAuthor, headSha:$headSha, tier:$tier, botLogins:$bots, diffPaths:$diff, protectedGlobs:$protected, headRef:$headRef, baseRef:$baseRef, repo:"."}' \
'{reviews:$reviews, prAuthor:$prAuthor, headSha:$headSha, tier:$tier, diffPaths:$diff, headRef:$headRef, baseRef:$baseRef, repo:"."}' \
| node "$GITHUB_ACTION_PATH/../../../dist/cli/verify-review.js"

- name: Verify implement only un-skipped tests (test<->code seam, §11 #3)
Expand Down
12 changes: 12 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ Danach **von Hand** (das ist der Anker, der Selbst-Freigabe verhindert):
ungültige (Bot, Autor, veraltet) → `ok:false`. Ein `devloop/spec/*`-PR ohne erkennbaren Spec-Pfad
(z.B. nur Tests) schlägt ebenfalls mit `spec-unguarded` fehl. **Bestehende Ziel-Repos ohne
Spec-Deckung werden bei Spec-PRs rot** — vor dem Upgrade CODEOWNERS ergänzen;
- **`/.devloop/`** (und eine tier-map außerhalb davon, z.B. `/tools/tier-map.json`) → Config-Änderungen
brauchen ein Review. **Pflicht seit v0.11.0 und wird erzwungen:** Die Precondition-Action liest
`tier-map.json`, `protected-globs.json` und `bot-logins.json` aus der **Basis** (`origin/<base>`, per `git show`),
nie aus dem PR-HEAD; ein PR kann sich die Regeln, nach denen er geprüft wird, nicht selbst setzen. Fehlt eine
Datei in der Basis, gilt sie aus dem HEAD (Arbeitsbaum), dann stdin, sonst `config-missing`; ist die Basis-Datei
unlesbar (kein JSON, kein String-Array, kein reguläres Blob), schlägt der Check mit `config-invalid` fehl (kein
Rückfall). Config-Pfade sind `.devloop/**`, `tools/tier-map.json`, `tier-map.json`. Ein PR, der einen davon
ändert (hinzufügt, ändert, löscht), umgeht die T0/T1-Abkürzung nicht: Sind die Pfade nicht von der
**CODEOWNERS der Basis** gedeckt, `ok:false` mit `config-unguarded`; sonst gilt die Approval-Bewertung wie ab T2.
Ausgenommen ist die **Erstaufnahme** (die Basis enthält keinen Config-Pfad, der PR richtet devloop ein).
**Nach dem Update auf v0.11.0 ist die erste Config-Änderung rot**, bis `/.devloop/ @OWNER` in der CODEOWNERS
der Basis steht; `/devloop:init` legt die Zeile an bzw. meldet die Lücke in `notes`;
- **alle T2/T3-Pfade aus deiner `tier-map`** (auth, migrations, contracts, `src/**`, …).
So funktioniert §9 serverseitig: **T0/T1 berührt keine CODEOWNER-Pfade → kein Review nötig → Auto-Merge;
T2/T3 berührt CODEOWNER-Pfade → required Review.** `verify-review` failt **nicht** auf „noch nicht
Expand Down
40 changes: 33 additions & 7 deletions dist/cli/derive-tier.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
// - { touched, tierMap } — caller supplies the map content (no path resolution)
// - { touched, repo } — devloop LOCATES the repo's tier-map robustly (absolute
// path: .devloop/ -> tools/ -> root) and reads it itself.
// - { touched, repo, baseRef } — wie oben, aber die Suche laeuft in der BASIS (`git show`):
// ein PR waehlt seine tier-map nicht selbst (Issue #13). Hat die
// Basis keinen Kandidaten, gilt der erste Kandidat im Arbeitsbaum.
// Always plain node (sandbox-clean) — never a repo's tsx-based `pnpm run tier`.
import { readFileSync } from "node:fs";
import { deriveTier } from "../core/tier.js";
import { resolveTierMapPath } from "../core/tier-map.js";
import { resolveTierMapPath, TIER_MAP_CANDIDATES } from "../core/tier-map.js";
import { readTreeEntry } from "../core/tree-entry.js";
import { readStdin } from "./_stdin.js";
const req = JSON.parse(await readStdin());
let tierMap = req.tierMap;
Expand All @@ -16,12 +20,34 @@ if (!tierMap) {
process.stderr.write("derive-tier: provide either `tierMap` or `repo` on stdin\n");
process.exit(2);
}
const found = resolveTierMapPath(req.repo);
if (!found) {
process.stderr.write(`derive-tier: no tier-map found under ${req.repo} (.devloop/ , tools/ , or root)\n`);
process.exit(2);
let fromBase = false;
if (req.baseRef) {
try {
for (const cand of TIER_MAP_CANDIDATES) {
const entry = readTreeEntry(req.repo, req.baseRef, cand);
if (entry.kind === "missing")
continue;
if (entry.kind !== "file")
throw new Error(`${cand} ist in der Basis kein regulaeres Blob (${entry.kind})`);
tierMap = JSON.parse(entry.content);
tierMapPath = `${req.baseRef}:${cand}`;
fromBase = true;
break;
}
}
catch (e) {
process.stderr.write(`derive-tier: tier-map der Basis ${req.baseRef} unlesbar: ${e.message}\n`);
process.exit(1);
}
}
if (!fromBase) {
const found = resolveTierMapPath(req.repo);
if (!found) {
process.stderr.write(`derive-tier: no tier-map found under ${req.repo} (.devloop/ , tools/ , or root)\n`);
process.exit(2);
}
tierMapPath = found;
tierMap = JSON.parse(readFileSync(found, "utf8"));
}
tierMapPath = found;
tierMap = JSON.parse(readFileSync(found, "utf8"));
}
process.stdout.write(JSON.stringify({ tier: deriveTier(req.touched, tierMap), tierMapPath }) + "\n");
67 changes: 61 additions & 6 deletions dist/cli/verify-review.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,50 @@
// stdin JSON: { reviews, prAuthor, headSha, botLogins?, humanReviewers?, diffPaths?, protectedGlobs?,
// tier?, headRef?, baseRef?, repo? }
// Spec-Aenderungen (REQ-SPECGATE-*) umgehen die T0/T1-Abkuerzung nicht und verlangen Basis-CODEOWNERS-Deckung.
// Mit baseRef kommen protectedGlobs und botLogins aus der Basis (Rueckfall: Arbeitsbaum, dann stdin;
// REQ-CFGBASE-2..4), und Config-Aenderungen (.devloop/**, tier-map) verhalten sich wie Spec-Aenderungen
// (REQ-CFGBASE-5/6), ausser bei Erstaufnahme.
// reviews come from `gh api repos/{owner}/{repo}/pulls/{n}/reviews`.
import { evaluateApproval } from "../core/review.js";
import { touchesProtectedSet } from "../core/protected-set.js";
import { isSpecChange, readBaseCodeowners, specGlobs, specPaths, uncoveredByCodeowners, SPEC_GLOBS_PATH, } from "../core/spec-change.js";
import { BOT_LOGINS_PATH, PROTECTED_GLOBS_PATH, configPaths, isInitialAdoption, readConfigList, } from "../core/config-change.js";
import { readStdin } from "./_stdin.js";
function fail(reason) {
process.stdout.write(JSON.stringify({ ok: false, reason }) + "\n");
process.exit(1);
}
const req = JSON.parse(await readStdin());
const reviews = req.reviews ?? [];
const repo = req.repo ?? ".";
// 0. Config-Listen aus der Basis (REQ-CFGBASE-2/3/4). Unlesbar = config-invalid (kein Rueckfall),
// nirgends vorhanden = config-missing. Ohne baseRef gilt nur der stdin-Wert wie bisher.
let protectedGlobs = req.protectedGlobs;
let botLogins = req.botLogins;
if (req.baseRef) {
try {
const pg = readConfigList(repo, req.baseRef, PROTECTED_GLOBS_PATH);
const bl = readConfigList(repo, req.baseRef, BOT_LOGINS_PATH);
protectedGlobs = pg?.list ?? req.protectedGlobs;
botLogins = bl?.list ?? req.botLogins;
}
catch (e) {
fail(`config-invalid: ${e.message}`);
}
const missing = [
...(protectedGlobs === undefined ? [PROTECTED_GLOBS_PATH] : []),
...(botLogins === undefined ? [BOT_LOGINS_PATH] : []),
];
if (missing.length > 0) {
fail(`config-missing: weder in der Basis ${req.baseRef}, im Arbeitsbaum noch auf stdin: ${missing.join(", ")}`);
}
}
const approvalCtx = { ...req, botLogins };
// 1. Gate-tamper fails ALWAYS, independent of approval state (reward-hacking alarm).
if (req.diffPaths &&
req.protectedGlobs &&
touchesProtectedSet(req.diffPaths, req.protectedGlobs)) {
if (req.diffPaths && protectedGlobs && touchesProtectedSet(req.diffPaths, protectedGlobs)) {
fail("protected-set-touched: the diff edits a guardian/gate config (reward-hacking alarm)");
}
// 1b. Spec-Aenderung (REQ-SPECGATE-1..7). Config gilt immer (REQ-5): ungueltig = fail-closed.
const repo = req.repo ?? ".";
let globs;
try {
globs = specGlobs(repo, req.baseRef);
Expand Down Expand Up @@ -56,16 +81,46 @@ if (specChange) {
`${owners === null ? " (keine CODEOWNERS gefunden)" : ""}: ${uncovered.join(", ")}`);
}
}
// 1c. Config-Aenderung (REQ-CFGBASE-5/6): kein Abkuerzen, Basis-CODEOWNERS muessen die Pfade decken.
// Erstaufnahme (Basis ohne jeden Config-Pfad) ist ausgenommen: es gibt nichts zu schuetzen.
let configChange = false;
if (req.baseRef) {
const cfgPaths = configPaths(diffPaths);
if (cfgPaths.length > 0) {
let adoption;
try {
adoption = isInitialAdoption(repo, req.baseRef);
}
catch (e) {
fail(`config-invalid: ${e.message}`);
}
if (!adoption) {
configChange = true;
let owners;
try {
owners = readBaseCodeowners(repo, req.baseRef);
}
catch (e) {
fail(`config-unguarded: ${e.message} (Config-Pfade: ${cfgPaths.join(", ")})`);
}
const uncovered = uncoveredByCodeowners(cfgPaths, owners);
if (uncovered.length > 0) {
fail(`config-unguarded: Config-Pfade ohne CODEOWNERS-Deckung in der Basis ${req.baseRef}` +
`${owners === null ? " (keine CODEOWNERS gefunden)" : ""}: ${uncovered.join(", ")}`);
}
}
}
}
// 2. Tier gate (§9): T0/T1 auto-merge — no approval required. (Gate-tamper above still applied.)
// Unknown/absent tier defaults to conservative "T3" (approval required). The authoritative
// T2/T3 merge block is branch protection's required CODEOWNER review on the high-tier paths;
// this check additionally validates a present approval (human, on HEAD) and the protected set.
const tier = req.tier ?? "T3";
if (!specChange && (tier === "T0" || tier === "T1")) {
if (!specChange && !configChange && (tier === "T0" || tier === "T1")) {
process.stdout.write(JSON.stringify({ ok: true, tier, note: "tier T0/T1: no approval required (§9)" }) + "\n");
process.exit(0);
}
const status = evaluateApproval(reviews, req);
const status = evaluateApproval(reviews, approvalCtx);
if (status === "ok") {
process.stdout.write(JSON.stringify({ ok: true }) + "\n");
process.exit(0);
Expand Down
7 changes: 4 additions & 3 deletions dist/cli/verify-unskip.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
//
// SCOPE: the seam applies to the tests devloop MANAGES (those `spec-to-tests` derives from a
// reviewed spec), not to every test file in the repo. The target repo declares them in
// `.devloop/managed-tests.json` (glob list) — a file inside the protected set, so an agent
// cannot widen it. No such file => every test file is managed (today's behaviour, fail-closed).
// `.devloop/managed-tests.json` (glob list) — read from the BASE; changing it is a config change
// that needs a CODEOWNERS review (verify-review, #13), so an agent cannot widen it on its own.
// No such file => every test file is managed (today's behaviour, fail-closed).
// Deliberately NOT branch-name-driven: an agent chooses its own branch name.
//
// Usage: verify-unskip <repoPath> <baseRef> [headBranch] (baseRef e.g. origin/main)
Expand All @@ -33,7 +34,7 @@ const TEST_FILE = /\.(test|spec)\.[cm]?[jt]sx?$/;
// The glob list is read from the BASE ref first: the scope that is already on the protected
// branch decides, so a PR cannot loosen the seam for itself. Only if the file does not exist on
// base do we fall back to the checkout (a repo adopting the file — that PR necessarily touches
// `.devloop/**` = the protected set and is already flagged by verify-review).
// `.devloop/**`, a config change that verify-review handles: review required unless initial adoption).
const readWorktree = (rel) => {
try {
return readFileSync(join(repo, rel), "utf8");
Expand Down
88 changes: 88 additions & 0 deletions dist/core/config-change.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// `.devloop/`-Config aus der Basis (Issue #13, docs/2026-11-27-devloop-config-aus-basis-design.md).
// Die Precondition-Action darf die Regeln, nach denen ein PR geprueft wird, nicht aus dem PR-HEAD
// lesen. Dieses Modul liest Config-Listen aus der Basis (`git show`) und erkennt Config-Aenderungen;
// die CODEOWNERS-Deckung der Basis (wie bei Spec-Pfaden, #4) erzwingt das Review.
import { execFileSync } from "node:child_process";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { matchesAnyGlob } from "./glob.js";
import { readTreeEntry } from "./tree-entry.js";
export const PROTECTED_GLOBS_PATH = ".devloop/protected-globs.json";
export const BOT_LOGINS_PATH = ".devloop/bot-logins.json";
/** Config-Pfade: alles unter `.devloop/` plus die tier-map-Kandidaten ausserhalb davon. */
export const CONFIG_GLOBS = [".devloop/**", "tools/tier-map.json", "tier-map.json"];
export class ConfigInvalidError extends Error {
}
export const configPaths = (diffPaths) => diffPaths.filter((p) => matchesAnyGlob(p, [...CONFIG_GLOBS]));
export const isConfigChange = (diffPaths) => configPaths(diffPaths).length > 0;
function assertRefResolvable(repo, baseRef) {
if (baseRef.startsWith("-"))
throw new ConfigInvalidError(`ungueltiger baseRef: ${baseRef}`);
try {
execFileSync("git", ["-C", repo, "rev-parse", "--verify", "--quiet", `${baseRef}^{commit}`], {
stdio: ["ignore", "pipe", "ignore"],
});
}
catch {
throw new ConfigInvalidError(`baseRef nicht aufloesbar: ${baseRef}`);
}
}
/**
* Erstaufnahme: die Basis enthaelt keinen einzigen Config-Pfad (der PR, der devloop einrichtet).
* Ein unaufloesbarer baseRef wirft (fail-closed), er gilt nie als "leere Basis".
*/
export function isInitialAdoption(repo, baseRef) {
assertRefResolvable(repo, baseRef);
let out;
try {
out = execFileSync("git", ["-C", repo, "--literal-pathspecs", "ls-tree", "-r", "-z", "--name-only", baseRef, "--", ".devloop", "tools/tier-map.json", "tier-map.json"], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], maxBuffer: 64 * 1024 * 1024 });
}
catch (e) {
throw new ConfigInvalidError(`Basis ${baseRef} nicht lesbar: ${e.message}`);
}
return !out.split("\0").some((p) => p !== "" && matchesAnyGlob(p, [...CONFIG_GLOBS]));
}
/** Parst ein JSON-Array von Strings (leeres Array ist gueltig). Sonst ConfigInvalidError. */
export function parseStringArray(raw, label) {
let parsed;
try {
parsed = JSON.parse(raw);
}
catch {
throw new ConfigInvalidError(`${label} ist kein gueltiges JSON`);
}
if (!Array.isArray(parsed) || !parsed.every((x) => typeof x === "string")) {
throw new ConfigInvalidError(`${label} ist kein JSON-Array von Strings`);
}
return parsed;
}
/**
* Liest eine String-Listen-Config. Rangfolge: (1) Basis, (2) Arbeitsbaum, (3) null (Aufrufer
* entscheidet, z. B. stdin-Wert). Existiert die Basis-Datei, aber ist unlesbar (kein JSON, falsche
* Form, kein reguelaeres Blob), wirft sie ConfigInvalidError: kein Rueckfall auf HEAD.
*/
export function readConfigList(repo, baseRef, path) {
assertRefResolvable(repo, baseRef);
let entry;
try {
entry = readTreeEntry(repo, baseRef, path);
}
catch (e) {
throw new ConfigInvalidError(`${path} in der Basis ${baseRef} nicht lesbar: ${e.message}`);
}
if (entry.kind === "file")
return { list: parseStringArray(entry.content, `${path} (Basis)`), source: "base" };
if (entry.kind !== "missing") {
throw new ConfigInvalidError(`${path} in der Basis ${baseRef} ist kein regulaeres Blob (${entry.kind})`);
}
let raw;
try {
raw = readFileSync(join(repo, path), "utf8");
}
catch (e) {
if (e.code === "ENOENT")
return null;
throw new ConfigInvalidError(`${path} im Arbeitsbaum nicht lesbar: ${e.message}`);
}
return { list: parseStringArray(raw, `${path} (Arbeitsbaum)`), source: "worktree" };
}
Loading
Loading