A local-first multi-agent app development platform, built on PenguinHarness
refactor(server): tickets are read in the frontmatter format only (#754)
Yaowei Zheng224a751486da
diff --git a/changelog/unreleased/2026-09-16-tickets-frontmatter-only.md b/changelog/unreleased/2026-09-16-tickets-frontmatter-only.mdnew file mode 100644index 00000000..fbcc6150--- /dev/null+++ b/changelog/unreleased/2026-09-16-tickets-frontmatter-only.md@@ -0,0 +1,65 @@+# Tickets are read in the frontmatter format only++- **Date:** 2026-09-16+- **Type:** refactor+- **Scope:** `server`, `skills`+- **PR:** [#754](https://github.com/Prism-Shadow/penguin-harness/pull/754)+- **Breaking:** yes — a ticket file still in the `# Ticket:` header format is reported as invalid instead of being read++[中文版](2026-09-16-tickets-frontmatter-only.zh.md)++Company mode's tickets have one format on disk: YAML frontmatter followed by the prose+sections. The reader for the format before it — a `# Ticket: <title>` line followed by+`Key: value` headers — was removed on the schedule set in+[backward compatibility](../0.2.13/2026-09-09-backward-compatibility.md). A ticket file that does+not open with `---` now fails to parse with ``the file must start with `---` (YAML frontmatter)``.++## Details++- `parseLegacyTicket`, its header and progress-line helpers, the older ticket-id pattern it+ accepted in `Parent` and `Blocked-by`, and the server's `splitPrincipalList`, which only it used,+ were deleted from `packages/server/src/organization/`.+- The `company-employee` skill stopped naming the old headers: `penguin org ticket block` is+ described as writing `blocked` / `blocked_by`, and the skill and the handbook a new organization+ is created with say "ticket fields" where they said "ticket headers". The `agent-company` plugin+ version moved to `2026.09.17.1`.++## Compatibility++Affected: a ticket written in the header format by a build before 0.2.13 and never written to+since — 0.2.13 rewrote every ticket in the frontmatter format on its first write. Such a file is+left on disk untouched and is handled like any other ticket file that does not parse:++- The board shows it only under "Ticket files that failed to parse", with its path and the error;+ `penguin org ticket ls` prints it as an `invalid` row (`invalidFiles` under `--json`), and the+ reconcile pass records an `org_ticket_invalid` error.+- Opening it answers 404 `ticket_not_found`; every write to it is refused with 409+ `ticket_invalid` (400 `bad_request` on read and write alike when its slug still carries a+ digit or is otherwise not letters-only), so nothing converts or overwrites it. A new ticket that+ would take its id gets the next suffix.+- Until it is repaired, the sessions only it names count toward no ticket and no employee's spend,+ and a ticket whose `parent` names it is flagged for a missing parent.++To recover a ticket whose slug is letters-only, write to it once through 0.2.13 (a progress line+or a move converts it), or convert it by hand with the mapping below. The 0.2.13 write path helps+no other ticket, because 0.2.13's routes already answered any other id with 400; recover such a+ticket by hand, in three steps:++1. Rename the file, in the directory it sits in, to an id with a letters-only slug: keep the+ `<yyyy-mm-dd>-` prefix, write the slug as lowercase English words joined by hyphens, and add a+ letter suffix (`-b`, `-c`, …) when that id is taken.+2. Replace the title line and headers with a frontmatter block, following the mapping below.+3. Wherever another ticket's `parent` or `blocked_by` names the old id — `Parent` or `Blocked-by`+ in a file still in the header format — write the new id instead.++The mapping from the headers to the frontmatter:++- `# Ticket: <title>` → `title`; `Status` → `status` (it must match the column directory).+- `Owner` → `owner`, or the `Initiator` value when `Owner` is empty.+- `Initiator` → the first `history` entry: `{at: <time of the first progress line>, by: <initiator>, action: created}`.+- `Notify: a, b` and `Sessions: a, b` → the lists `notify: [a, b]` and `sessions: [a, b]`.+- `Parent`, `Priority`, `Due`, `Blocked` → `parent`, `priority`, `due`, `blocked`; `Blocked-by` →+ `blocked_by`. A ticket id there needs a letters-only slug: a renamed ticket's new id.+- Any other `Key: value` header → a field of the same name.+- Each `## Progress` line `- <time> <principal> <text> session:<id>` → `- <text>`, plus a+ `history` entry `{at: <time>, by: <principal>, action: progress, note: <text>}`.diff --git a/changelog/unreleased/2026-09-16-tickets-frontmatter-only.zh.md b/changelog/unreleased/2026-09-16-tickets-frontmatter-only.zh.mdnew file mode 100644index 00000000..0dcb54af--- /dev/null+++ b/changelog/unreleased/2026-09-16-tickets-frontmatter-only.zh.md@@ -0,0 +1,52 @@+# 工单只按 frontmatter 格式读取++- **Date:** 2026-09-16+- **Type:** refactor+- **Scope:** `server`, `skills`+- **PR:** [#754](https://github.com/Prism-Shadow/penguin-harness/pull/754)+- **Breaking:** yes — 仍是 `# Ticket:` 表头格式的工单文件会被报告为无效,不再被读取++[English](2026-09-16-tickets-frontmatter-only.md)++公司模式的工单在磁盘上只有一种格式:YAML frontmatter 加正文各节。此前的格式——一行+`# Ticket: <标题>` 加若干 `Key: value` 表头——其读取器按+[向后兼容](../0.2.13/2026-09-09-backward-compatibility.zh.md) 中约定的时间表删除。不以 `---`+开头的工单文件现在解析失败,错误为 ``the file must start with `---` (YAML frontmatter)``。++## 细节++- 从 `packages/server/src/organization/` 删除了 `parseLegacyTicket`、它的表头与进展行辅助函数、它在+ `Parent` 与 `Blocked-by` 中接受的旧版工单 id 模式,以及只有它在用的服务端 `splitPrincipalList`。+- `company-employee` Skill 不再提旧表头:`penguin org ticket block` 改述为写入 `blocked` /+ `blocked_by`;该 Skill 与新建组织生成的手册把「工单头部」改称「工单字段」。`agent-company` 插件版本升至+ `2026.09.17.1`。++## 兼容性++受影响的是 0.2.13 之前的构建以表头格式写下、此后再未被写入的工单——0.2.13 会在工单第一次被写入时把它改写为+frontmatter 格式。这样的文件原样留在磁盘上,按任何一个解析失败的工单文件处理:++- 看板只在「无法解析的工单文件」下列出它的路径与错误;`penguin org ticket ls` 把它打印为一行+ `invalid`(`--json` 下在 `invalidFiles` 中),reconcile 过程记录一条 `org_ticket_invalid` 错误。+- 打开它返回 404 `ticket_not_found`;对它的任何写入都被拒绝,返回 409 `ticket_invalid`(其 slug+ 仍含数字或因其他原因不是纯字母时,读取与写入一律返回 400 `bad_request`),因此不会有任何操作转换或覆盖它。新建工单若会占用它的+ id,则取下一个后缀。+- 修复之前,只由它记录的会话不计入任何工单,也不计入任何员工的花费;`parent` 指向它的工单会被标为父工单不存在。++恢复 slug 为纯字母的工单时,可以用 0.2.13 对它写入一次(追加一条进展或移动一次即完成转换),也可以按下面的对应关系手工转换。这条写入路径对其他工单无效(0.2.13 的路由对其他 id 已经返回 400),这类工单只能手工恢复,分三步:++1. 在文件所在目录内把它改名为 slug 为纯字母的 id:保留 `<yyyy-mm-dd>-` 前缀,slug 写成以连字符连接的小写英文单词;该 id 已被占用时加字母后缀(`-b`、`-c`……)。+2. 按下面的对应关系,把标题行与表头替换为 frontmatter 块。+3. 其他工单的 `parent` 或 `blocked_by` 指向旧 id 的(仍是表头格式的文件里为 `Parent` 或 `Blocked-by`),一律改写为新 id。++表头与 frontmatter 的对应关系:++- `# Ticket: <标题>` → `title`;`Status` → `status`(须与所在列目录一致)。+- `Owner` → `owner`;`Owner` 为空时取 `Initiator` 的值。+- `Initiator` → `history` 的第一条:`{at: <第一条进展行的时间>, by: <initiator>, action: created}`。+- `Notify: a, b` 与 `Sessions: a, b` → 列表 `notify: [a, b]` 与 `sessions: [a, b]`。+- `Parent`、`Priority`、`Due`、`Blocked` → `parent`、`priority`、`due`、`blocked`;`Blocked-by` →+ `blocked_by`。其中的工单 id 须使用纯字母 slug,改过名的工单写它的新 id。+- 其余 `Key: value` 表头 → 同名字段。+- `## Progress` 中每一行 `- <时间> <principal> <文本> session:<id>` → `- <文本>`,并追加一条 `history`+ 条目 `{at: <时间>, by: <principal>, action: progress, note: <文本>}`。diff --git a/packages/server/src/db/repos/sessions.ts b/packages/server/src/db/repos/sessions.tsindex fe01803f..b51717b9 100644--- a/packages/server/src/db/repos/sessions.ts+++ b/packages/server/src/db/repos/sessions.ts@@ -153,7 +153,7 @@ export class SessionsRepo implements SessionIndex {/*** Stamp `client = "org"` on the rows an organization's files name, leaving the ones* already stamped alone. The reconcile pass calls it with every session the desk ledger- * and the tickets' `Sessions` headers claim, so a row opened before the marker existed+ * and the tickets' `sessions` fields claim, so a row opened before the marker existed* carries the organization's provenance from the next pass on — and keeps it when the* organization is deleted or company mode is switched off, which is exactly when the* organization caches can no longer answer for it. Chunked because the id list isdiff --git a/packages/server/src/organization/files.ts b/packages/server/src/organization/files.tsindex 0e57198b..912881c9 100644--- a/packages/server/src/organization/files.ts+++ b/packages/server/src/organization/files.ts@@ -33,7 +33,7 @@ import { parseScheduleFile } from "../runtime/schedule-file.js";import type { ScheduleDefinition } from "../runtime/schedule-file.js";import { SEMANTIC_ID_PATTERN } from "../services/ids.js";import { DEFAULT_CHANNEL_ID, ceoAgentId, isTicketColumn } from "./paths.js";-import { parsePrincipal, splitPrincipalList } from "./principal.js";+import { parsePrincipal } from "./principal.js";import { isValidTimeZone } from "./zoned.js";export type ParseResult<T> = { ok: true; value: T } | { ok: false; error: string };@@ -661,13 +661,13 @@ function splitFrontmatter(text: string): Frontmatter {* A ticket file: YAML frontmatter followed by the prose sections. The frontmatter carries* the fields (the title among them — there is no H1), the prose carries `## Goal`,* `## Acceptance criteria`, `## Progress` and `## Result`; unknown fields and unknown- * sections survive a round trip. A file in the format that predates the frontmatter is read- * by {@link parseLegacyTicket} and converted the next time it is written.+ * sections survive a round trip. A file that does not open with the frontmatter is not a+ * ticket.*/export function parseTicket(raw: string): ParseResult<TicketDoc> {const text = raw.replace(/\r\n/g, "\n");const fm = splitFrontmatter(text);- if (fm.kind === "none") return parseLegacyTicket(text);+ if (fm.kind === "none") return fail("the file must start with `---` (YAML frontmatter)");if (fm.kind === "unterminated") return fail("the frontmatter block is not closed by `---`");let parsed: unknown;try {@@ -761,7 +761,7 @@ function ticketFields(front: Record<string, unknown>): ParseResult<TicketFields>};}-/** The `Notify` list a ticket falls back to: its owner when an employee owns it, nobody otherwise. */+/** The `notify` list a ticket falls back to: its owner when an employee owns it, nobody otherwise. */export function defaultTicketNotify(owner: string): string[] {return parsePrincipal(owner)?.kind === "agent" ? [owner] : [];}@@ -891,151 +891,6 @@ export function historyNote(text: string): string {.slice(0, HISTORY_NOTE_MAX);}-// ----------------------------------------------------------------------------// Legacy ticket files-// -----------------------------------------------------------------------------const LEGACY_HEADERS = new Set([- "status",- "initiator",- "owner",- "parent",- "notify",- "priority",- "due",- "blocked",- "blocked-by",- "sessions",-]);--/** A legacy progress line: `- <time> <principal> <text> [session:<id>]`. */-function parseLegacyProgressLine(line: string): { time: string; by: string; text: string } | null {- const m = /^-\s+(\S+)\s+(\S+)\s+(.*)$/.exec(line.trim());- if (!m) return null;- let text = m[3]!.trim();- const s = /\s*session:(\S+)$/.exec(text);- if (s) text = text.slice(0, s.index).trim();- if (!isPersonPrincipal(m[2]!)) return null;- return { time: m[1]!, by: m[2]!, text };-}--/**- * A ticket written before the frontmatter format: `# Ticket: <title>` followed by- * `Key: value` header lines. `Initiator` becomes the `created` history entry and, when no- * `Owner` was set, the owner; each old progress line becomes a plain progress sentence plus- * one `progress` history entry carrying its time and principal. Nothing is repaired on disk- * here — the file converts to the new format the first time it is written.- *- * **Compatibility shim.** The frontmatter format ships in 0.2.13, so this can be deleted in- * 0.2.14 — by then every ticket an organization still writes to has been converted; see- * `changelog/0.2.13/2026-09-09-backward-compatibility.md`.- */-export function parseLegacyTicket(text: string): ParseResult<TicketDoc> {- const lines = text.split("\n");- let i = 0;- while (i < lines.length && lines[i]!.trim() === "") i++;- const titleLine = /^# Ticket: (.+)$/.exec(lines[i] ?? "");- if (!titleLine)- return fail("the file must start with `---` (frontmatter) or `# Ticket: <title>`");- const title = titleLine[1]!.trim();- i++;- while (i < lines.length && lines[i]!.trim() === "") i++;- const headers = new Map<string, string>();- const extra: Record<string, unknown> = {};- for (; i < lines.length; i++) {- const line = lines[i]!;- if (line.trim() === "" || line.startsWith("## ")) break;- const kv = /^([A-Za-z][A-Za-z-]*):\s?(.*)$/.exec(line);- if (!kv) return fail(`header line is not \`Key: value\`: ${line}`);- const key = kv[1]!.toLowerCase();- if (LEGACY_HEADERS.has(key)) headers.set(key, kv[2]!.trim());- else extra[kv[1]!] = kv[2]!.trim();- }- const status = headers.get("status") ?? "";- if (!isTicketColumn(status))- return fail(`Status must be one of the board columns, got \`${status}\``);- const initiator = headers.get("initiator") ?? "";- if (!isPersonPrincipal(initiator)) return fail("Initiator must be agent:<id> or user:<id>");- // One owner now: an unassigned legacy ticket is owned by whoever filed it.- const ownerHeader = headers.get("owner") ?? "";- if (ownerHeader !== "" && !isPersonPrincipal(ownerHeader)) {- return fail("Owner must be agent:<id> or user:<id>");- }- const owner = ownerHeader !== "" ? ownerHeader : initiator;- const parent = headers.get("parent") ?? "";- if (parent !== "" && !TICKET_ID_PATTERN.test(parent) && !LEGACY_TICKET_ID_PATTERN.test(parent)) {- return fail("Parent must be a ticket id");- }- const notifyRaw = headers.get("notify");- const notify =- notifyRaw === undefined || notifyRaw === ""- ? defaultTicketNotify(owner)- : splitPrincipalList(notifyRaw);- for (const n of notify)- if (!isPersonPrincipal(n)) return fail(`Notify entry is not a principal: ${n}`);- const priority = headers.get("priority") ?? "P2";- if (priority !== "P0" && priority !== "P1" && priority !== "P2") {- return fail("Priority must be P0, P1 or P2");- }- const due = headers.get("due") ?? "";- if (due !== "" && !/^\d{4}-\d{2}-\d{2}/.test(due)) return fail("Due must start with yyyy-mm-dd");- const blocked = headers.get("blocked") ?? "";- const blockedBy = headers.get("blocked-by") ?? "";- if (- blockedBy !== "" &&- !TICKET_ID_PATTERN.test(blockedBy) &&- !LEGACY_TICKET_ID_PATTERN.test(blockedBy) &&- !isPersonPrincipal(blockedBy)- ) {- return fail("Blocked-by must be a ticket id or a principal");- }- const sessions = splitPrincipalList(headers.get("sessions") ?? "");- const prose = ticketSections(lines.slice(i).join("\n"));- if (!prose.ok) return prose;- // The old progress log carried the operator and the time inline; they move to the history,- // the sentence stays. A line nothing can be read out of is kept as a sentence and nothing else.- const history: OrgTicketHistoryEntry[] = [];- const progress: string[] = [];- for (const line of prose.value.progress) {- const entry = parseLegacyProgressLine(`- ${line}`);- if (entry === null) {- progress.push(line);- continue;- }- progress.push(entry.text);- history.push({- at: entry.time,- by: entry.by,- action: "progress",- note: historyNote(entry.text),- });- }- // Filing is what the `Initiator` header recorded; its time is the first thing that happened.- history.unshift({ at: history[0]?.at ?? "", by: initiator, action: "created" });- return {- ok: true,- value: {- title,- status,- owner,- ...(parent !== "" ? { parent } : {}),- notify,- priority,- ...(due !== "" ? { due } : {}),- ...(blocked !== "" ? { blocked } : {}),- ...(blockedBy !== "" ? { blockedBy } : {}),- sessions,- history,- ...prose.value,- progress,- extra,- },- };-}--/** Ticket ids written before the letters-only slug rule, as legacy files still reference them. */-const LEGACY_TICKET_ID_PATTERN = /^\d{4}-\d{2}-\d{2}-[a-z0-9][a-z0-9-]{0,63}$/;-// ---------------------------------------------------------------------------// channels/<channel_id>/channel.toml// ---------------------------------------------------------------------------diff --git a/packages/server/src/organization/handbook.ts b/packages/server/src/organization/handbook.tsindex 22e117c9..892e9a0e 100644--- a/packages/server/src/organization/handbook.ts+++ b/packages/server/src/organization/handbook.ts@@ -88,7 +88,7 @@ of your system prompt. Never write absolute paths into files other people read.## PrincipalsPeople and employees are named \`user:<user_id>\` and \`agent:<agent_id>\` in every structured-field (ticket headers, message senders and mentions). \`all\` in a mention means every member of+field (ticket fields, message senders and mentions). \`all\` in a mention means every member ofthat channel — in the all-hands channel, every employee; \`system\` is the scheduler. In messagetext \`@<id>\` is shorthand: employees resolve first, then Project members; write\`@agent:<id>\` or \`@user:<id>\` when both exist.@@ -248,7 +248,7 @@ ${input.mission}## 身份记号-人和员工在所有结构化字段(工单头部、消息发送者与提及)里都记作 \`user:<user_id>\` 与 \`agent:<agent_id>\`。提及里的 \`all\` 指该频道的全体成员——在全员频道即全体员工;\`system\` 是调度器。消息正文里的 \`@<id>\` 是简写:先解析为员工,再解析为 Project 成员;两者都存在时写 \`@agent:<id>\` 或 \`@user:<id>\`。+人和员工在所有结构化字段(工单字段、消息发送者与提及)里都记作 \`user:<user_id>\` 与 \`agent:<agent_id>\`。提及里的 \`all\` 指该频道的全体成员——在全员频道即全体员工;\`system\` 是调度器。消息正文里的 \`@<id>\` 是简写:先解析为员工,再解析为 Project 成员;两者都存在时写 \`@agent:<id>\` 或 \`@user:<id>\`。## 工单协议diff --git a/packages/server/src/organization/principal.ts b/packages/server/src/organization/principal.tsindex 6c796a17..683074cb 100644--- a/packages/server/src/organization/principal.ts+++ b/packages/server/src/organization/principal.ts@@ -54,13 +54,3 @@ export function principalUserId(raw: string): string | null {const p = parsePrincipal(raw);return p?.kind === "user" ? p.id : null;}--/** Splits a `Notify`-style list: comma separated, blanks dropped, order kept, duplicates removed. */-export function splitPrincipalList(raw: string): string[] {- const out: string[] = [];- for (const part of raw.split(",")) {- const v = part.trim();- if (v !== "" && !out.includes(v)) out.push(v);- }- return out;-}diff --git a/packages/server/src/runtime/organization/budget.ts b/packages/server/src/runtime/organization/budget.tsindex 4d7d1d04..120f6f5e 100644--- a/packages/server/src/runtime/organization/budget.ts+++ b/packages/server/src/runtime/organization/budget.ts@@ -1,7 +1,7 @@/*** Spend attribution for an organization: every cost figure is derived from usage records* joined to the sessions the organization's files claim — desk sessions from the ledger,- * contributing sessions from the tickets' `Sessions` headers. Nothing is stored; the+ * contributing sessions from the tickets' `sessions` fields. Nothing is stored; the* budget marks in SQLite only remember which alerts already fired.*/import type { TicketDoc } from "../../organization/files.js";diff --git a/packages/server/src/runtime/organization/reconcile.ts b/packages/server/src/runtime/organization/reconcile.tsindex 4cff61fa..3bf486b3 100644--- a/packages/server/src/runtime/organization/reconcile.ts+++ b/packages/server/src/runtime/organization/reconcile.ts@@ -97,7 +97,7 @@ export async function listTickets(deps: OrgDeps, org: LoadedOrg): Promise<Ticket}/**- * Projects the ledger and the tickets' `Sessions` headers into the two session caches, and+ * Projects the ledger and the tickets' `sessions` fields into the two session caches, and* stamps `client = "org"` on every session row those files name. The caches are rebuilt from* the files on every pass and vanish with the organization; the stamp is written once per row* and stays, which is what keeps a desk or ticket session out of development mode's listdiff --git a/packages/server/test/organization-files.test.ts b/packages/server/test/organization-files.test.tsindex bd88cd5d..8cf8430b 100644--- a/packages/server/test/organization-files.test.ts+++ b/packages/server/test/organization-files.test.ts@@ -29,11 +29,7 @@ import {ancestorsOf,} from "../src/organization/files.js";import type { ChannelConfig, OrgChart, OrgConfig, TicketDoc } from "../src/organization/files.js";-import {- formatPrincipal,- parsePrincipal,- splitPrincipalList,-} from "../src/organization/principal.js";+import { formatPrincipal, parsePrincipal } from "../src/organization/principal.js";import {DEFAULT_CHANNEL_ID,channelConfigPath,@@ -281,51 +277,23 @@ describe("tickets", () => {expect(parseTicket("status: done\n").ok).toBe(false);});- it("reads a ticket in the format that predates the frontmatter, and converts it on write", () => {- const legacy = [- "# Ticket: Launch the site",- "",- "Status: in_progress",- "Initiator: agent:acme_ceo",- "Owner:",- "X-Custom: kept",- "",- "## Goal",- "Ship it",- "",- "## Progress",- "- 2026-09-02T10:12:00+08:00 agent:acme_dev scaffolded the site session:session-x",- "- 2026-09-02T11:00:00+08:00 user:alice reviewed the copy",- "",- ].join("\n");- const parsed = parseTicket(legacy);- expect(parsed.ok).toBe(true);- if (!parsed.ok) return;- // No Owner header: the ticket belongs to whoever filed it, and Notify follows the owner.- expect(parsed.value.owner).toBe("agent:acme_ceo");- expect(parsed.value.notify).toEqual(["agent:acme_ceo"]);- // The operator and the time leave the prose for the history; the sentence stays.- expect(parsed.value.progress).toEqual(["scaffolded the site", "reviewed the copy"]);- expect(parsed.value.history).toEqual([- { at: "2026-09-02T10:12:00+08:00", by: "agent:acme_ceo", action: "created" },- {- at: "2026-09-02T10:12:00+08:00",- by: "agent:acme_dev",- action: "progress",- note: "scaffolded the site",- },- {- at: "2026-09-02T11:00:00+08:00",- by: "user:alice",- action: "progress",- note: "reviewed the copy",- },- ]);- expect(parsed.value.extra).toEqual({ "X-Custom": "kept" });- // Written back, it is a frontmatter file that parses to the same document.- const converted = serializeTicket(parsed.value);- expect(converted.startsWith("---\n")).toBe(true);- expect(parseTicket(converted)).toEqual(parsed);+ it("rejects a file that does not open with the frontmatter, `# Ticket:` headers included", () => {+ const headed = parseTicket(+ [+ "# Ticket: Launch the site",+ "",+ "Status: in_progress",+ "Owner: agent:acme_ceo",+ "",+ "## Goal",+ "Ship it",+ "",+ ].join("\n"),+ );+ expect(headed).toEqual({+ ok: false,+ error: "the file must start with `---` (YAML frontmatter)",+ });});it("derives ids: letters-only slugs, letter suffixes, month and path", () => {@@ -496,7 +464,6 @@ describe("principals", () => {expect(parsePrincipal("system")).toEqual({ kind: "system" });expect(parsePrincipal("acme_ceo")).toBeNull();expect(formatPrincipal({ kind: "user", id: "alice" })).toBe("user:alice");- expect(splitPrincipalList(" agent:a, user:b ,agent:a,")).toEqual(["agent:a", "user:b"]);});});diff --git a/packages/server/test/organization-runtime.test.ts b/packages/server/test/organization-runtime.test.tsindex 6c3b6903..2aa60141 100644--- a/packages/server/test/organization-runtime.test.ts+++ b/packages/server/test/organization-runtime.test.ts@@ -1820,6 +1820,65 @@ describe("organization runtime", () => {board.columns.proposed.find((x) => x.ticketId === t.ticketId)?.blocked,).toBeUndefined();});++ it("reports a `# Ticket:` file as an invalid file: listed nowhere, refused on write, never rewritten", async () => {+ const valid = await service.createTicket(+ P,+ ORG,+ { title: "Launch the site" },+ { userId: "alice" },+ );+ const headedId = "2026-09-01-legacy-launch";+ const headedPath = ticketPath(orgDir(), headedId, "in_progress");+ const headed = [+ "# Ticket: Legacy launch",+ "",+ "Status: in_progress",+ `Initiator: agent:${CEO}`,+ `Owner: agent:${HR}`,+ "",+ "## Goal",+ "Ship it",+ "",+ ].join("\n");+ await fs.mkdir(path.dirname(headedPath), { recursive: true });+ await fs.writeFile(headedPath, headed, "utf8");+ errors.length = 0;++ // The pass carries on past it and records it.+ await scheduler.tickOnce();+ expect(errors.filter((e) => e.code === "org_ticket_invalid").length).toBeGreaterThan(0);+ // The board lists the valid ticket in its column and the file under invalidFiles only.+ const board = await service.tickets(P, ORG);+ expect(Object.values(board.columns).flatMap((c) => c.map((x) => x.ticketId))).toEqual([+ valid.ticketId,+ ]);+ expect(board.invalidFiles).toEqual([+ {+ path: path.join("tickets", "2026-09", "in_progress", `${headedId}.md`),+ error: "the file must start with `---` (YAML frontmatter)",+ },+ ]);+ // The overview counts it in no column either.+ expect((await service.detail(P, ORG, "alice")).board.in_progress).toBe(0);+ // Not a ticket to read, and a write asks for a repair instead of converting the file.+ await expect(service.ticket(P, ORG, headedId)).rejects.toMatchObject({+ status: 404,+ code: "ticket_not_found",+ });+ await expect(+ service.progressTicket(P, ORG, headedId, "half done", { userId: "alice" }),+ ).rejects.toMatchObject({ status: 409, code: "ticket_invalid" });+ // A new ticket that would take its id takes the next free one instead.+ const next = await service.createTicket(+ P,+ ORG,+ { title: "Legacy launch", slug: "legacy-launch" },+ { userId: "alice" },+ );+ expect(next.ticketId).toBe(`${headedId}-b`);+ expect(await fs.readFile(headedPath, "utf8")).toBe(headed);+ });});describe("channel messages", () => {diff --git a/plugins/agent-company/plugin.json b/plugins/agent-company/plugin.jsonindex fb1c2b1d..c6de3cda 100644--- a/plugins/agent-company/plugin.json+++ b/plugins/agent-company/plugin.json@@ -3,7 +3,7 @@"description_zh": "把 Project 里的 Agent 组织成一家公司:先与用户一问一答地创建组织,再是每个工位会话与工单会话都遵循的员工协议(触发块、工单看板、频道礼仪、预算、重负载或不可逆的事先向董事会请示),以及 CEO、人事与财务的操作手册——使命拆解为工单、招募与日程、预算与成本巡检——还有科研协议(在董事会批准的资源额度内跑 autoresearch 式实验循环、作者与审稿人对抗评审),以及让数字分身在真人之间传话的镜像协议。","short_description": "Company setup plus the employee, CEO, HR, finance, research and mirror playbooks.","short_description_zh": "创建组织,以及员工、CEO、人事、财务、科研、镜像公司的操作手册。",- "version": "2026.09.16.1",+ "version": "2026.09.17.1","category": "agent-company","preinstall": false}diff --git a/plugins/agent-company/skills/company-employee/SKILL.md b/plugins/agent-company/skills/company-employee/SKILL.mdindex a49aa978..90519620 100644--- a/plugins/agent-company/skills/company-employee/SKILL.md+++ b/plugins/agent-company/skills/company-employee/SKILL.md@@ -60,7 +60,7 @@ The first three arrive at your desk session; `ticket_work` opens a ticket sessio## Principals-Structured fields — ticket headers, a message's `sender` / `mentions`, `--owner`, `--by`, `--notify` — name people and employees as `agent:<agent_id>` or `user:<user_id>`; `@all` means every member of the channel you write it in — in the all-hands channel, every employee — and `system` is only ever a message sender. In message text `@<id>` is the shorthand: the server resolves employees first, then Project members; when an agent and a user share an id, write `@agent:<id>` / `@user:<id>`.+Structured fields — ticket fields, a message's `sender` / `mentions`, `--owner`, `--by`, `--notify` — name people and employees as `agent:<agent_id>` or `user:<user_id>`; `@all` means every member of the channel you write it in — in the all-hands channel, every employee — and `system` is only ever a message sender. In message text `@<id>` is the shorthand: the server resolves employees first, then Project members; when an agent and a user share an id, write `@agent:<id>` / `@user:<id>`.## The desk session: schedule, do not do@@ -72,7 +72,7 @@ Your desk session is permanent — one per employee, the target of every calendaA sweep, on a calendar event or whenever a human asks you for one — start it by reading the `## Since your last sweep` list the event carries, then:-1. `penguin org ticket ls --owner agent:<your_agent_id> --json` — your tickets; add `--status proposed` for candidates and `--blocked` to see what is stuck. Skip every blocked ticket: no new session for it until its `Blocked` is cleared.+1. `penguin org ticket ls --owner agent:<your_agent_id> --json` — your tickets; add `--status proposed` for candidates and `--blocked` to see what is stuck. Skip every blocked ticket: no new session for it until its `blocked` field is cleared.2. For each `in_progress` ticket of yours that no session is working on, start one: `penguin org ticket start <ticket_id> -m "<what to do first, what to leave alone>"`. It runs in the background and prints the session id; start several for independent streams of one ticket. **Only the ticket's owner starts its sessions** — the server answers `403 not_ticket_owner` on anyone else's ticket. When you need a colleague on your ticket, ask in a channel and they answer with `penguin org ticket start <your_ticket_id> --agent-id <them>`; when a colleague asks you for help, it is their ticket, so they start the session naming you and you work in it. To move the work itself, reassign the ticket: `penguin org ticket assign <ticket_id> --owner agent:<them>`, and their desk picks it up in its next sweep.3. Check on the sessions you started earlier: `penguin input <session_id> --timeout 0` for the latest reply, `penguin logs <session_id> --tail 40` for the trail, `penguin input <session_id> -m "<course correction>" --timeout 0` to steer.4. Verify what a finished session claims — `penguin org ticket show <ticket_id>`, then the files in the workspace — and write the verdict back: `penguin org ticket progress <ticket_id> -m "verified: …"`, and `penguin org ticket move <ticket_id> --to review` (or `done`, where the handbook allows) if the session did not already.@@ -106,9 +106,8 @@ history: # the operation log — the server writes this```- **One owner.** `owner` is the single principal responsible: whoever filed the ticket, unless- the filing named someone else. There is no separate "initiator" — who filed it is the- `created` entry of `history`. Handing work over is `penguin org ticket assign <id> --owner- agent:<employee>`, and nothing else.+ the filing named someone else. Who filed it is the `created` entry of `history`. Handing work+ over is `penguin org ticket assign <id> --owner agent:<employee>`, and nothing else.- **`## Progress` is prose.** Plain sentences saying what was done and where. No ids, notimestamps, no principal — the server writes the `history` entry that records who and when.- **The operator is known from your environment.** Every `penguin org` command already carries@@ -211,7 +210,7 @@ penguin org ticket show <ticket_id> [--json]penguin org ticket create --title <s> (--goal <s> [--criteria <s>] | --body-file <path>) [--owner <principal>] [--slug <words>] [--parent <ticket_id>] [--notify <p,p>] [--priority P0|P1|P2] [--due <date>]penguin org ticket move <ticket_id> --to <col> [--reason <s>] # moving into rejected requires a reasonpenguin org ticket assign <ticket_id> --owner <principal>-penguin org ticket block <ticket_id> --reason <s> [--by <principal|ticket_id>] # writes Blocked / Blocked-by; the ticket stays in its column+penguin org ticket block <ticket_id> --reason <s> [--by <principal|ticket_id>] # writes `blocked` / `blocked_by`; the ticket stays in its columnpenguin org ticket unblock <ticket_id> # clears the blockpenguin org ticket progress <ticket_id> -m <text> # appends one plain progress sentence; the server records who and whenpenguin org ticket start <ticket_id> [-m <note>] [--workspace <path>] [--agent-id <id>] [--json] # opens a new ticket session contributing to the ticket (repeatable); only on a ticket you own, --agent-id enlists a colleague on it; runs in the background and prints the session id