diff --git a/docs/handoff.md b/docs/handoff.md index 8747221a..6eef523e 100644 --- a/docs/handoff.md +++ b/docs/handoff.md @@ -1,121 +1,108 @@ -# Handoff — Fledge v0.2.4 +# Handoff — Fledge (v0.5.0 current) -Status: **v0.2.4 is the latest release (`fledge.hugoxk.online`, GitHub OAuth login; the token login is disabled); docs are live; CI green.** -Last updated: 2026-11-06. +Status: **v0.5.0 is the latest release (2026-11-23, `fledge.hugoxk.online`)**; +this page is current as of 2026-11-23. The previous public baseline is +[handoff-2026-11-10.md](handoff-2026-11-10.md), kept as history. The plan and +open questions live in [roadmap.md](roadmap.md). -This page is the public handoff for a new development session. The operator's -private handoff (server paths, env locations, non-public URLs) is not committed; -it lives next to the working copy as `SESSION_HANDOFF.md`. +The operator's private handoff (server paths, env locations, non-public URLs) is +not committed; it lives next to the working copy as `SESSION_HANDOFF.md`. ## Start here 1. Read [AGENTS.md](../AGENTS.md), [LESSONS.md](../LESSONS.md), [docs/code-standards.md](code-standards.md) and [docs/autonomous-dev.md](autonomous-dev.md). -2. Run `npm ci && npm run check`. +2. Run `npm ci && npm run check` on Node 22.9+. 3. `cp .env.example .env`, then `npm run dev` and open `http://localhost:8080/auth/dev` for a local admin (the dev login is refused when `NODE_ENV=production`). -4. Pick the next item from **Open work** and follow the pipeline. +4. Pick the next item from **Open work** below and follow the pipeline. ## What exists - **Repository:** -- **Release:** -- **CI:** `ci.yml` (Node 22 + 24, lint, typecheck, tests, build, Docker, audit, - changelog, risk), `ci-ok-publish.yml` (publishes the required `ci-ok` verdict - from the default branch), `codeql.yml`, `dependency-review.yml`, - `release.yml`; the aggregate job inside `ci.yml` keeps publishing `ci-ok` until - a follow-up renames it to `ci-ok-head`. +- **Release:** +- **CI:** `ci.yml` (Node 22 + 24, lint, typecheck, tests, coverage, build, + visual, Docker, audit, dependency review, changelog, version, risk, + restore-drill, action pins, workflow lint, secret scan, CodeQL, deploy-check, + mock-check), `codeql.yml`, `release.yml`, `daily-release.yml`, + `release-slot.yml`, `review-gate.yml`. The aggregate is **`ci-ok`**. - **Stack:** Node 22.9+, TypeScript, Fastify, `node:sqlite`, nodemailer, server-rendered HTML. -- **Service:** (live; GitHub OAuth login with the - token login disabled). -- **Docs:** (mirror: +- **Service:** (GitHub OAuth; the token-login + fallback is disabled in production). +- **Docs:** (mirror: ). - **Project page / guide:** . ### Implemented -- GitHub login with an application gate: a new user signs the disclaimer and the - information-security agreement once, submits, and sees a live queue/status - page. The administrator receives a single-use approve/reject email from - the configured administrator address (7 days). The login is OAuth when - `GITHUB_CLIENT_ID` is configured; the token login is a bootstrap fallback. -- Bilingual Chinese/English UI with a persistent language switch shared with the - rest of the platform, and a focused `/console` workspace for repositories, - active jobs and quota. The shared Portal is a footer link, never a permission - handoff. -- Admin panel, roles, audit log, in-app notifications. -- Team stage evidence gate (`off` / `shadow` / `enforced`), issue-label intake - (`priority:*`, `agent-ready`), a deduped repeated-failure ops alert, and - selective question-notification read. -- Model providers with multiple models, discovery, editing with re-test, - per-bot model assignment, a mandatory platform connection test and a per-user - private/HTTP permission. -- Repository lifecycle banner and danger zone, PR delivery with maintainer merge, - issue commands and a live inbox SSE stream. -- Durable job events, personal and admin delivery metrics (7/30 days), - cost by repository and model, alerts, a read-only `/api/read/metrics` JSON - contract, a baseline shadow report (`npm run evolution:export -- --report`) and the first AgentDescent evolution ledger/ADR. -- Failed jobs show an actionable failure category and recovery link, with an - admin failure breakdown for the window. -- Plan path constraints are enforced against the PR diff, PR evidence is - verified against GitHub, the delivery list shows ready/blocked/not-verified, - and transient failures retry with bounded backoff. -- Platform concurrency is configurable with `PLATFORM_MAX_ACTIVE_JOBS`. -- `/metrics` and optional OTLP traces cover HTTP, jobs, retries, merges, GitHub - and the bridge; shutdown drains active work and startup cleans orphans. -- GitHub webhooks are delivery-deduped, GitHub calls use a token budget, - auto-merge reconciles on green checks and on a schedule, and open operational - alerts are delivered to the repository owner with cooldown dedupe. -- Product/Test stage sessions, a Fledge-driven delivery chain, grounded team - attribution, token backfill and managed instance-token rotation. -- Multiple repositories per user; per-repo fine-grained GitHub tokens, validated - on add and encrypted with AES-256-GCM. -- Upstream/fork onboarding: Fledge detects or creates the user's fork, pushes - work to the fork, and targets issues/PRs at the upstream. If the user owns the - upstream, work stays in that repository. -- Reviewer role for repository maintainers with GitHub admin/maintain permission: scheduled review jobs - list all open upstream PRs, score them, and post COMMENT reviews without - merging. -- Repo goals, manual/hourly/daily/weekly cadence, enabled flag. -- Job lifecycle (`queued → running → succeeded|failed|quota_exhausted`), a mock - runner and a signed FlyBot bridge contract (credential URL + callback). -- OpenAI-compatible model gateway with a per-user **1 CNY** quota, real cost - headers, a `quota_ledger`, a 402 `FLEDGE_QUOTA_EXHAUSTED` response, and an - own-model fallback with a 1-token connection test. -- SSRF guard for user model URLs, CSRF, rate limits, security headers, redacted - logs. -- Dockerfile, docker-compose, systemd/nginx samples, online SQLite backup, - deployment/security/quota/API docs, tests and issue/PR templates. +- **Governed delivery loop.** One issue → one branch → one PR. A tip-SHA review + gate (`review-gate`), risk tiers computed from every changed path, path + guards, PR evidence verification, merge bound to the job's own PR, duplicate + preflight, and an opt-in maintainer auto-merge that independently verifies the + PR state, checks, reviews and branch protection. +- **Durable execution.** `job_attempts` with lease epochs and fencing, + idempotent callbacks, plan-first checkpoints, decision pauses, schedule + occurrences with timezone/misfire/pause/run-now, durable retries with bounded + backoff, a platform emergency stop, orphan cleanup and graceful drain. +- **Identity and governance.** Platform roles, per-repository maintainer / + developer roles, tenants/projects/principals and scoped grants, a shared + repository read path (slice 1 of #105), management commands, audit log, + postmortems, task relations and project memory. +- **Models and budgets.** Platform quota, own-model fallback, provider → models, + per-bot model assignment, a model router health view, and job / repository / + principal budget scopes with alert, pause or cancel. +- **Release chain.** The daily minor drive, the mechanical release identity and + diff shape, release readiness and tagging, draft release notes, SBOM and build + provenance, a publish guard, and `verify-release` for the plan / branch / PR / + tag / image / SBOM / attestation chain. +- **Operations.** Prometheus `/metrics`, optional OTLP traces, SLO rules and an + error-budget report, operational alerts with cooldown, webhook delivery and + replay, GitHub API budget, backup/restore drill, deployment drift and a + previous-release migration fixture. +- **UI.** The flight-deck visual system, owner (`/dashboard`) and operator + (`/console`) surfaces, the loop rail and one next action, bilingual copy, a + design-token layer, the visual/a11y geometry matrix, and the repository + rules/skills and gate-plan surfaces. +- **Public API v1.** `GET /api/v1/jobs` with a `jobs:read` `flg_` token, a + stable cursor, and the three documented refusals. ### Verified -- `npm run check`: lint, typecheck, the full test suite and the production build - — green at the commit this document ships with. -- GitHub Actions: Node 22 and Node 24 green at the release commit. -- A real platform-funded call with the alternate key returned 200 and deducted - `$0.00001064` from the dev account's quota. -- The quota 402, own-model bypass, approval links and repo/job flow are covered - by tests. -- Production startup fails closed when the OAuth app or the two secrets are - missing. - -### Not yet done - -- Production GitHub OAuth login: the OAuth App for - `https://fledge.hugoxk.online/auth/github/callback` is configured, its client - id/secret are in the deployment env, and `ALLOW_TOKEN_LOGIN_ONLY=false`, so - login runs through GitHub OAuth and the token login is disabled. A real - browser sign-in is **not yet verified**; that check and the pending-approval - gate are tracked in #57. -- Real SMTP delivery (the server env is wired to the operator SMTP account; no - test mail has been sent). -- The leaked GitHub development PAT still needs owner rotation; managed bridge - and instance tokens are rotated by `scripts/rotate-instance-tokens.mjs`. -- A merge queue is not available through this repository's API plan, so - branch-protection checks plus auto-merge are used. +- `npm run check` — green at the `v0.5.0` release tip (lint, typecheck, tests, build). +- `ci-ok` is green on `main` at the `v0.5.0` release commit. +- `node scripts/verify-release.mjs --version 0.5.0` reports + `release-status: ok` for the plan, branch, pull request, annotated tag, image, + SBOM and provenance. +- The image is `ghcr.io/hugoxk/fledge:v0.5.0` at + `sha256:d0fe98d6cbaf735a8c2e759f727a0ec75419784461b8c715de17ad48ed6ed7a8`. +- The suite is 3,300+ tests with the coverage floor recorded in `package.json`. +- A local macOS `npm test` has nine known host/tool failures (`deployAutomation`, + `gateBaseTree`, `nginxCheck`, `securityHeaders`); the same nine fail on an + untouched `v0.5.0` tree. CI on Ubuntu is green. + +### Not done / open + +- **#1246** — the architecture-boundary gate is implemented and green on every + code check; it is a T3 tip and needs a PASS from `HugoXK-bot` at its head + before it can merge. +- **v0.5.x foundation series** — #1224–#1236: Store/route/view/job seams, the + architecture gate, the dialect port, lease/query/maintenance visibility, an + audit hash chain, a release fault matrix, an incident bundle and a rotation + drill. +- **v0.6 owner loop and openness** — #1237–#1243: command palette, cross-device + preferences, i18n/a11y gates, `SourceProvider` and `AgentRunner` ports, and + the OpenAPI 3.1 contract. +- **Still open elsewhere** — #387 (Postgres, worker pool, distributed leases), + #651 (a second independent identity for T3), #863 / #879 / #885 (check-name + shadowing, release-tag rule, commit signing and secret-scanning patterns), + #105 (shared repository members beyond slice 1), #654 (product soul and + feature admission test), #547 (owner-surface direction). +- **0.5.0 was an owner-authorized exception.** The nightly planner's feature + threshold was not met (12 merged PRs and 1 feature against 5). The exception + is recorded in #1245; the next release follows the normal rule again. ## Architecture in one screen @@ -134,39 +121,35 @@ back. See [architecture.md](architecture.md) and [api.md](api.md). ## Open work (ordered) -1. **First real browser OAuth sign-in** (#57) for - `https://fledge.hugoxk.online/auth/github/callback`: the OAuth App is - configured, its client id/secret are in the deployment env and - `ALLOW_TOKEN_LOGIN_ONLY=false` is set, so login runs through GitHub OAuth and - the token login is disabled. What remains is the first human sign-in and the - pending-approval gate. -2. **Operational hardening**: repeated-failure alerts, stall detection, the - credential circuit breaker and managed token rotation are done; still needed - are log rotation, a backup restore drill and admin token rotation. The leaked - GitHub development PAT must be rotated by the owner with - `node scripts/rotate-github-token.mjs --token-file <0600 file>` (or - `--token-file -` with the token on stdin). -3. **Next product slice**: shared repository members (design in - [decisions/0002](decisions/0002-shared-repo-members.md)), native DSH message - streaming and deeper stage orchestration. -4. **Homepage + guide**: live at `hugoxk.online/fledge/` and - `hugoxk.online/fledge/guide/` (English under `/en/`); keep them in step with - the product. +1. **Review #1246** at its tip. A `HugoXK-bot` PASS is the only thing missing; + the author of the tip may not PASS it. +2. **Wave 0 of v0.5.x** — #1235 (release fault matrix), #1239 (i18n gate), + #1240 (axe on the visual matrix). +3. **Wave 1** — #1224–#1227 (structure), #1229–#1232 (durability and scale), + #1233–#1236 (trust and release). +4. **v0.6** — #1237–#1243, after **#654** and **#547** are decided. +5. **v1.0** — #387, a second source provider and runtime, a second T3 identity, + merge queue and signing, audit retention, external review. ## Decisions to keep - Name: **Fledge / 羽巢**; tagline “hosted repositories that grow themselves”. - See [decisions/0001-name.md](decisions/0001-name.md). + See [decisions/0001](decisions/0001-name.md). - 1 CNY is a configurable platform budget, not an invoice. - The model gateway uses the platform key only for platform-funded calls; an own model bypasses the quota. -- The platform is single-tenant per instance in v0.1; SQLite is single-writer. +- The platform is single-tenant per instance in `v0.5`; SQLite is single-writer. - The dev login is a local convenience and must never be enabled in production. -- Reviews are by tip SHA; a PASS without a `Ran:` command is invalid. -- Reviewer work is hosted by `HugoXK-bot` (`hugo2001xk@gmail.com`); the owner - `HugoXK` keeps merge authority, the bot gets a required PASS and write access, - and the review policy is read from the base branch. +- Reviews are by tip SHA; a PASS without a real `Ran:` command is invalid. +- Reviewer work is hosted by `HugoXK-bot`; the owner `HugoXK` keeps merge + authority, and the review policy is read from the base branch. - One PR per issue; never a duplicate. +- A release is the mechanical set (`CHANGELOG.md`, `README.md`, + `README.zh.md`, `changelog.d/`, `package.json`, `package-lock.json`, + `docker-compose.yml`) and the tag follows the merge through the tag job. +- The nightly cadence and its release rule live in `docs/autonomous-dev.md` and + `daily-release.yml`; an owner-authorized release outside the rule is recorded + in its PR. ## Environment map (operator-only)