From 9d983f892d02f8312e5c1189828aad920fe0b451 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 18 Oct 2026 14:43:06 -0700 Subject: [PATCH] Feat: trunk-law extension scopes fleet git rules to ~/Projects sessions before_agent_start handler appends the trunk-based git law to the system prompt only when cwd is under ~/Projects/. Hard cwd scope because every context-file provider resolves at or below the repo root - an ancestor AGENTS.md is never loaded by descendant repos. Verified live: quote probe fires under serverAppConfig, silent in /tmp and ~/.omp. Fires for subagent sessions too (shared cwd). Changelog entry added. --- agent/extensions/trunk-law.js | 38 +++++++++++++++++++++++++++++++++++ omp-docs/log.md | 4 ++++ 2 files changed, 42 insertions(+) create mode 100644 agent/extensions/trunk-law.js diff --git a/agent/extensions/trunk-law.js b/agent/extensions/trunk-law.js new file mode 100644 index 0000000..447bc2f --- /dev/null +++ b/agent/extensions/trunk-law.js @@ -0,0 +1,38 @@ +// trunk-law.js — fleet git law for repositories under ~/Projects/. +// +// Hard cwd scope: sessions outside ~/Projects get an untouched system prompt. +// The rule text mirrors ~/.omp/omp-docs (command-center), AGENTS.md +// § Trunk-based SDLC (operator decision 2026-10-18): single-dev repos, no +// develop branch, PRs directly on main. This extension is the delivery +// mechanism because every context-file provider (AGENTS.md walk-up, .omp +// dirs, CLAUDE.md) resolves at or below the repo root — a file in +// ~/Projects/ itself is never loaded by ancestors' sessions. +// +// before_agent_start receives the current base system prompt and may return +// a replacement; returning undefined leaves it untouched. The appended text +// is constant, so provider prompt caching is unaffected after the first +// request. Fires for subagent sessions too (they share the session cwd). + +const ROOT = "/home/blank/Projects/"; + +const RULES = [ + "", + "", + "# Fleet git law — trunk-based (injected because cwd is under ~/Projects/)", + "- `main` is the only long-lived branch: no `develop`, no release branches, no back-merges.", + "- Before every work item: `git fetch`, then branch off the freshest `origin/main`. If main moves underneath you, merge it into your branch — never rebase.", + "- Pull requests target `main` directly; merge with `--no-ff` so feature arcs stay visible.", + "- Never merge a PR without an explicit, current OK from Frank.", + "- Releases: tag `vX.Y.Z` straight on `main`; tags are the deploy markers machines pull to.", + "- This law supersedes git-flow text still living in repo-local AGENTS.md/docs (e.g. serverAppConfigs) until Frank changes it.", +].join("\n"); + +export default function trunkLaw(pi) { + pi.on("before_agent_start", async (event, ctx) => { + const cwd = (ctx && ctx.cwd) || ""; + if (cwd !== ROOT.slice(0, -1) && !cwd.startsWith(ROOT)) return; + const base = event.systemPrompt; + if (Array.isArray(base)) return { systemPrompt: [...base, RULES] }; + return { systemPrompt: (base || "") + RULES }; + }); +} diff --git a/omp-docs/log.md b/omp-docs/log.md index 6eb1c76..9bc7cd2 100644 --- a/omp-docs/log.md +++ b/omp-docs/log.md @@ -11,6 +11,10 @@ timestamp: 2026-08-28 # Bundle Change Log +## 2026-10-18 — Trunk law propagated to ~/Projects repos via extension + +New tracked extension `agent/extensions/trunk-law.js`: a `before_agent_start` handler that appends the trunk-based git law to the system prompt **only when the session cwd is under `~/Projects/`** (hard-scoped; verified live with quote-the-prompt probes: fires under `serverAppConfig`, silent in `/tmp` and `~/.omp`). This was the only mechanism that works — every context-file provider (AGENTS.md walk-up, `.omp/` dirs, CLAUDE.md) resolves at or below the repo root, so a hypothetical `~/Projects/AGENTS.md` is never loaded by ancestor sessions. Subagent sessions inherit the cwd and get the law too. Note: repo-local git-flow text (serverAppConfigs' AGENTS.md) contradicts it until that repo is updated; the injected law declares precedence explicitly. + ## 2026-10-18 — SDLC switched to trunk-based development `develop` retired by operator decision (single-dev repo; the branch bought nothing and cost a back-merge every release). New law in AGENTS.md § *Trunk-based SDLC*: branch off the freshest `origin/main` before every work item, PRs target `main` directly, `--no-ff` merges, tags `vX.Y.Z` straight on main. No back-merges, no release branches. The last back-merge (`527596a`) lands with this switch; the managed skill `gitflow-back-merge-plumbing` is now historical. -- 2.54.0