feat(rotation): 90-day policy, due runs wait for owner approval (CLI 0.16.0) (#270)

Every automatic secret older than the team's max age (90 days default) is
queued as one run in awaiting-approval. An owner/admin approves it on the
Rotation page or with `teams rotation-approve`; machine keys can queue but
never approve. logicsrc-rotate --queue (*/5 cron) runs approved runs with
propagate + health checks + rollback. rotation_auto_approve per team is the
paid automatic rotation add-on (off by default).

Co-authored-by: Anthony Ettinger <anthony@profullstack.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sh1pt-actions-fleet[bot] 2026-10-29 04:36:26 +00:00 • committed by GitHub
parent 87bbc50423
commit 0f237cb6e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 407 additions and 24 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@logicsrc/cli",
"version": "0.15.0",
"version": "0.16.0",
"description": "LogicSRC CLI: every LogicSRC standard and tool as one command.",
"type": "module",
"main": "./dist/index.js",

View file

@ -39,7 +39,7 @@ import { registerKeysCommands } from "./keys.js";
import { registerKeyringCommands } from "./keyring-cmd.js";
import { sshAgentAction, sshListAction, sshPullAction, sshPushAction } from "./ssh.js";
import { credentialsRotateAction } from "./rotate.js";
import { teamsRotateFromQueue, teamsRotateKeysAction, teamsRotationAction, teamsRotationSetAction } from "./rotate-keys.js";
import { teamsQueueDueAction, teamsRotateFromQueue, teamsRotateKeysAction, teamsRotationAction, teamsRotationApproveAction, teamsRotationSetAction } from "./rotate-keys.js";
import { teamsAuditAction, teamsKeyImportAction, teamsRekeyAction, teamsRotateIdentityAction } from "./hardening.js";
import { teamsCleanAction } from "./vault-clean.js";
import { boards, tasks } from "./fixtures.js";
@ -961,6 +961,7 @@ teams
.option("--allow-roll", "let desktop roll recipes run (Cloudflare Global API Key: the old key dies at once; a capture self-test runs first)")
.option("--from-queue", "run the rotations queued on app.logicsrc.com (Rotation page / API / MCP) and report back; approved runs write only with --approve here too")
.option("--max-runs <n>", "with --from-queue: stop after n runs")
.option("--queue-due", "90-day policy: queue every automatic key older than the team's max age as one run awaiting approval")
.option("--format <format>", "table, json, or markdown", "table")
.description("Rotate secret values: automatic ones are minted and written to every vault holding the old value; manual ones come back as steps.")
.addHelpText(
@ -974,6 +975,11 @@ Dry run first, then apply:
logicsrc teams rotate-keys profullstack wx93 prod --key CRON_SECRET --propagate --approve
logicsrc teams rotate-keys profullstack --scheduled --propagate --approve --report r.json (the weekly job)
90-day policy (default max age 90 days): due keys wait for an owner/admin to approve
logicsrc teams rotate-keys profullstack --queue-due queue the overdue keys as one run
logicsrc teams rotation-approve profullstack <run-id> approve it (or the Rotation page)
logicsrc teams rotate-keys profullstack --from-queue --propagate --approve the runner rotates it
Provider rotators (method provider): resend, cloudflare-token, coinpay-api-key,
coinpay-webhook-secret, vapid, postgres-role. Each mints the new credential,
writes the vaults, redeploys consumers, health-checks them, and only then
@ -1007,6 +1013,11 @@ After rotating: redeploy the consumers, install new SSH public keys, revoke the
desktop: options.desktop,
allowRoll: Boolean(options.allowRoll)
};
if (options.queueDue) {
if (project || env || options.key || options.fromQueue) throw new Error("--queue-due covers the whole team; run it alone.");
await teamsQueueDueAction(slug, { format: options.format as OutputFormat });
return;
}
if (options.fromQueue) {
if (project || env || options.key || options.setFromStdin) throw new Error("--from-queue takes its keys, project and env from each queued run.");
const reports = await teamsRotateFromQueue(slug, { ...common, maxRuns: options.maxRuns === undefined ? undefined : Number(options.maxRuns) }, {}, join(homedir(), "www"));
@ -1029,6 +1040,14 @@ After rotating: redeploy the consumers, install new SSH public keys, revoke the
});
});
teams
.command("rotation-approve")
.argument("<slug>", "Team slug")
.argument("<run-id>", "The awaiting-approval run (rotate-keys --queue-due prints it)")
.option("--format <format>", "table, json, or markdown", "table")
.description("Approve a due rotation run (90-day policy): owner or admin only. The queue runner then rotates it.")
.action(async (slug, runId, options) => { await teamsRotationApproveAction(slug, runId, { format: options.format as OutputFormat }); });
teams
.command("clean")
.argument("<slug>", "Team slug")

View file

@ -824,3 +824,31 @@ export async function teamsRotateFromQueue(slug: string, options: FromQueueOptio
}
return reports;
}
/**
* The 90-day policy: ask the app to queue every automatic key older than the
* team's max age as one run. It waits for an owner or admin to approve it on the
* Rotation page (or `teams rotation-approve`), unless the team has the paid
* automatic rotation add-on; then `--from-queue --approve` rotates it.
*/
export async function teamsQueueDueAction(slug: string, options: { format?: OutputFormat } = {}) {
const { client } = authedClient();
const out = await client.queueDueRotation(slug);
if (options.format && options.format !== "table") return print(out, options.format), out;
if (!out.run) console.log(`Nothing in ${slug} is older than ${out.maxAgeDays} days.`);
else {
const verb = out.created ? "Queued" : "Already open";
console.log(`${verb}: run ${out.run.id}, ${out.run.keys.length} key(s) older than ${out.maxAgeDays} days, status ${out.run.status}.`);
if (out.run.status === "awaiting-approval") console.log(`Approve: https://app.logicsrc.com${out.approveUrl} or logicsrc teams rotation-approve ${slug} ${out.run.id}`);
}
return out;
}
/** An owner or admin approves a due run; the queue runner then rotates it. */
export async function teamsRotationApproveAction(slug: string, runId: string, options: { format?: OutputFormat } = {}) {
const { client } = authedClient();
const { run } = await client.approveRotationRun(slug, runId);
if (options.format && options.format !== "table") return print(run, options.format), run;
console.log(`Approved run ${run.id} (${run.keys.length} key(s)): status ${run.status}. The queue runner rotates it next.`);
return run;
}