56 Commits

Author SHA1 Message Date
eust-w
13ceca5c8f 🔀 Merge review/overhaul into feat/wiki-copilot-diagnostics
Some checks failed
CI / Format, types and tests (pull_request) Has been cancelled
CI / PostgreSQL migrations and integration tests (pull_request) Has been cancelled
Brings the branch up to the current base (executor settings, project
skills, Chinese run messages, cloud IDE removal, wish attachments) and
resolves the ten conflicted files, keeping both sides:

- wish-refiner: the tenant's executor settings pick the models first,
  then the Copilot model setting; the tenant credential still goes
  before the operator's login
- worker providers: executor settings apply, and a run with its own
  credential still gets an empty home
- main.ts: Copilot screenshot uploads and wish attachments each keep
  their own body limit
- contracts, http, web types: default budget and skill auto-activation,
  Copilot and attachment entity kinds, ./text and ./attachments exports
- globals.css: Copilot styles and attachment styles, one after the other
- tests: the canceled-release reason is Chinese; the refiner's default
  models have no [1m] suffix, as this branch names them

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 00:39:05 +08:00
wishforge
d2006ae140 🐛 Run an executor with the run's own credential, not the operator's login
In development the worker handed Claude Code both the tenant's key and the operator's
logged-in home. The CLI signs in with the login it finds there, so the gateway saw a
subscription credential it does not accept and answered 401 "Invalid API key provided" —
the run then waited on provider_error with its work saved.

A run that carries a credential of its own now gets an empty home, exactly like a Copilot
answer; the operator's login stays for runs that have nothing else to sign in with.
2026-11-09 05:35:57 -08:00
wishforge
2bd9333089 🐛 Keep reporting a live lease while the control plane is slow
The workflow's 45 s heartbeatTimeout is reset only by the activity's own heartbeat, and the
keeper sent one inside the same promise that awaits the control-plane request. A request
that stalls therefore also silenced the heartbeat, and the run was canceled as if its
activity had died — the cancellation then surfaced as "Execution was canceled".

The workflow is now told on every tick, before and independently of the request; a stopped
keeper still says nothing, and still reports its own reason.
2026-11-09 04:13:03 -08:00
eust-w
3a2296e9d7 ✨ Support image and file attachments on wishes
Wishes can now carry screenshots, designs, logs and documents: upload,
drag-and-drop, or paste into the goal/criteria boxes. The files are stored
as attachment records, written into the executor's workspace under a
Git-ignored directory, and pointed out to the agent in its prompt. People
fetch them back one at a time (images inline, everything else downloads)
with nosniff and a sandbox CSP.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-11-09 14:28:07 +08:00
eust-w
4e0ac6bdfd 🔀 Merge Chinese run messages
Resolved against the IDE removal and the lessons-to-skills merge; the
pitfall skills, their events and repair notes are written in Chinese too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-04 12:50:03 +08:00
eust-w
3217982f32 🔀 Merge project knowledge
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

# Conflicts:
#	apps/web/src/features/projects.tsx
#	apps/web/src/lib/types.ts
#	docs/architecture.md
#	docs/reference/ui.md
#	docs/requirements.md
#	docs/user-manual.md
#	tests/local-loop.test.ts
2026-11-04 12:45:22 +08:00
eust-w
91ab5f91e6 🌐 Write run events, waiting details and agent replies in Chinese
The run page mixed English stage events and agent summaries into the
Chinese console. Messages are now written in Simplified Chinese at their
source (control plane, dispatcher, worker, POC build), keeping commands,
SHAs, branches and error codes verbatim; raw runtime errors get a Chinese
prefix. The agent prompt asks for the plan, summary and questions in
Chinese. File-change parsing accepts old and new messages, and the event
label table covers every event kind written.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-04 12:42:04 +08:00
eust-w
0e4ef42771 ♻️ Unify project lessons into self-evolving project skills
Lessons become skills with a category (workflow / pitfall / convention):
one model, one prompt section, one permission rule. A repaired failure
records or updates a pitfall skill deduplicated by failure signature;
harvest sees every skill and may merge into an existing one; corroborated
skills auto-activate per project (skillAutoActivation, default on).
Runs given a skill are counted (skill_usage); platform-maintained skills
retire after 3 failing runs in a row or 90 days unused. Skills can be
imported from SKILL.md / zip, copied between projects and searched across
projects. Migration 004 converts existing lesson rows to skills.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-04 12:37:36 +08:00
eust-w
4e9e5fb874 ✨ Let tenant admins configure each executor: gateway, models and time limit
A per-tenant, per-executor settings record (GET /executor-settings,
GET/PUT /executor-settings/:provider, owner/admin, idempotent replace) with
baseUrl, defaultModel, smallFastModel, fallbackModel, timeoutMinutes, askModel
and askFallbackModel. Unset fields keep the operator's configuration.

- defaultModel is pinned at submission below the wish and bundle models.
- smallFastModel, fallbackModel and timeoutMinutes travel in the run context
  to the worker; Claude Code gets ANTHROPIC_SMALL_FAST_MODEL /
  ANTHROPIC_DEFAULT_HAIKU_MODEL and --fallback-model, CodeBuddy the limit.
- baseUrl goes only with the tenant's own key, over HTTPS (plain HTTP only
  where plainHttpAllowed), never in production, behind the model proxy or
  with the deployment's native Claude account.
- The wish refiner tries the tenant's ask models first.
- The 执行器 page gets an 执行器设置 dialog, also in native-account mode;
  model fields (and the agent page's) accept gateway names like
  deepseek-flash@latest[1m].

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-04 12:19:02 +08:00
eust-w
35c00f076d 🧪 Do not hold a change to failures already on its branch
- Checks run in a repository of their own holding only the commit (and
  the commit the run started from, as refs/wishforge/base), so code that
  asks Git which commit it is gets the true answer; the verifier's
  repository and configuration stay out of reach
- A frontend test gets two minutes before it fails, instead of one that
  never settles holding the whole suite until the check is killed
- When frontend or Go tests fail, the same tests run at the commit the
  run started from; only failures that were not there before fail the
  change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 05:37:14 +08:00
eust-w
4cffd71be8 ✨ Learn project skills from runs, and export a wish's report
- Skills: per-project know-how the platform proposes from each succeeded
  run (in the background, or on request from a run), people confirm,
  edit, disable, delete or write; active ones enter later prompts
- Export one skill as SKILL.md, or all as a zip with a directory per
  skill, as .claude/skills/ expects
- A wish's report: every run, its stage timeline, the agent's plan,
  replies, commands, changed files and model usage, the change, the
  checks, failures, reviews and releases, and the full event log, as
  Markdown, or laid out for printing to PDF

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 03:57:24 +08:00
eust-w
6d615c0ffd ⚖️ Count cache reads a tenth toward budgets, and allow runs up to 10M tokens
- countedTokens: input, output and cache creation in full, cache reads a
  tenth, as they cost; the worker meters Claude CLI usage with it and the
  usage event says how much counted
- A run's token budget may be raised to 10,000,000

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 03:26:27 +08:00
eust-w
72085cf752 ✨ Let a project offer models and a wish choose one
- Projects list the models their wishes may run with, the first by
  default; owners and admins set them in the project settings
- A wish may choose one of its project's models; the choice is checked
  and pinned to the run, which shows it, and the executor starts the
  agent with it (--model), else with the agent configuration's
- Model names may be spelled as the model gateway does
  (deepseek-pro@latest[1m]), in projects and agent configurations alike

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 03:08:35 +08:00
eust-w
aa151d16f9 ✨ Deliver to Fanyu's cluster from the dev branch beside the POC
- Profiles pin each environment: POC (branch poc) and Fanyu (branch dev,
  180.76.138.88, droboticflow-fanyu), with their Deployments by UID
- Releases expect every Deployment of their profile; Fanyu's api image
  also runs its annotation processor and validator, each rolled back to
  its own image
- Bindings may list several projects; each Runner has its own settings
- fanyu-access: least-privilege identity and build-Pod admission policy in
  Fanyu's cluster, its token only in the executor and Fanyu's Runner
- projects --replace: delete every project with all it holds, then create
  the POC and Fanyu projects, their environments and Runners
- Ship the Runner's public keys in the ConfigMap, not a Mac path

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 17:47:47 +08:00
eust-w
c5a6c6160d 🚀 Deploy WishForge to the POC cluster, with check Pods and daily backups
- cluster-poc.mjs: image (in-cluster Kaniko), bootstrap, secrets, apply,
  migrate --rehearsal|--final, public HTTPS entry, backup and restore
- One restricted Pod (platform, executor, Runner, PostgreSQL, Temporal,
  MinIO, Caddy, backup) listening only on loopback except Caddy
- Protected checks run in per-workspace check Pods; cancellation during
  start-up now always removes them
- Daily snapshots on the node (consistent dump with row counts, Temporal
  online backup), copied to the Mac by launchd with SHA-256 checks and a
  notification on failure; restore verified on the rehearsal copy
- Downloads and uploads survive the Mac's lossy link to the cluster
- Local public entry, evidence isolation labels, acceptance records

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:27:07 +08:00
eust-w
bf3313620e ✨ Let each wish stay frontend-only, and optimize wishes into short goals with choices
- Each wish says whether it may change backend code. A frontend-only wish is told
  which paths it must leave alone; a change to them goes back before any check runs,
  the platform puts those files back before the repair round, and the control plane
  never integrates them. A wish that may change backend code integrates directly for
  people with backend permission and waits for a code review otherwise.
- Owners and admins grant backend permission per person on the members page as well
  as per project in the project settings.
- AI optimization has its own button for the wish and for the criteria. It writes a
  wish of at most three lines (goal, scope, limits), keeps the details in checkable
  criteria, and asks only what the person must decide, as choices whose answers join
  the wish; suggested criteria are taken one by one.
- Lists, run titles, Feishu cards and pull request titles show a wish's first line;
  the run details show the rest.
- Changed paths no longer follow renames, so moving backend code into a frontend
  directory counts at both places for code review and for the frontend-only scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 20:37:30 +08:00
eust-w
a4eaefc69f ✨ Hold reviewed paths, take back runs, optimize wishes and notify in Feishu
What the pilot asked for, from its meeting:

- Code review: a project names the paths changes to which a person reviews
  before they reach the target branch (globs, with exceptions). After the
  checks pass, the verifier asks the control plane, and the run waits at
  integration until an owner or admin approves the exact commit; approving
  integrates it without repeating the checks, rejecting hands the comment to
  the agent as a new requirement. Continuing cannot get around it: the
  verifier asks again before every integration.
- Undo: "take back this change" starts a run that reverses what a run
  integrated on the current target branch, three-way, keeping later commits;
  only lines later commits changed too go to the agent. It then verifies,
  integrates and delivers like any run. Releases get a rollback button for the
  version live in their environment.
- Wish optimization: the local Claude account rewrites a draft wish and its
  acceptance criteria by built-in and project rules, with no tools at all;
  the person compares and decides, nothing is submitted for them.
- Release confirmation: an environment can make every release wait for a
  person, not only those the risk rules flag.
- Feishu notifications: a group bot is told of releases awaiting approval and
  changes awaiting review (mentioning the decision makers), runs that need a
  person, finished runs and failed releases; each once, signed when a secret
  is set, with text from runs never acting as card markup.
- Reviewers see the agent's change summary and who submitted the wish, and
  whether the checks ran in the macOS sandbox; the wish form offers only the
  executors this deployment can run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 17:08:27 +08:00
eust-w
9099f06ba8 🔒 Ask for approval on every image recipe and dependency manifest
A release counted as protected only a file named exactly Dockerfile,
the Node and Python manifests and the .github directory. The local POC
builds its images from Dockerfile.api, Dockerfile.worker and
Dockerfile.drosync-coordinator, and pins Go and Rust dependencies in
go.mod, go.sum and Cargo files: changing any of them was deployed
without approval wherever releases are preauthorized, and so were
changes to .dockerignore, *.dockerfile, Containerfiles and Gitea or
GitLab CI.

The rule now lives in the contracts package. Any Dockerfile or
Containerfile, the build context's ignore list, Compose files, every
dependency manifest and lock file the verifier knows, and the CI
locations need a person; the verifier's notion of a dependency manifest
is the same list. Ordinary source, tests and documents still go
through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 22:43:13 +08:00
eust-w
fb85c3fe2a 🐛 Weigh a POC release only by what it replaces
A POC release counted, besides what the target branch gained, the
changes since the commit every component runs. Worker and coordinator
keep their images while only web files changed, so they lag behind the
api, and every later release counted again the changes of releases the
api had long deployed: on the POC a run's classification listed the
previous run's test file, and an earlier change to a protected web file
would have asked for approval on every api-only release after it.

A component that keeps its image does not change; the release now
counts the changes since what the api and each component built again
run. pocComponentsToBuild says which commits those are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:14:47 +08:00
eust-w
b201fd04a9 ✨ Wait for people when commits pushed to the target branch broke it
When a run's change passed its checks but failed one once merged onto
a target branch that moved meanwhile, the agent got a repair round for
it, even when the failure came from commits other people had pushed:
it would change their code, and spend rounds and tokens doing so.

The verifier now runs that check, recording no evidence, on the target
branch alone. If the branch passes, combining the two caused the
failure, and the agent repairs it as before. If the branch fails too
while the commit the run started from passes, the commits pushed since
broke the branch: the run waits on the new reason target_broken, uses
no repair round, and has its own verified change as its checkpoint
again. A run that started from a commit already failing the check may
be its fix, and is repaired as before.

Continuing merges the verified change onto the repaired branch and
checks the merge. An integration that continues reuses the change's own
verification under the same policy instead of repeating the checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 18:14:19 +08:00
eust-w
6722319314 🔒 Weigh a release by everything its environment does not run yet
A release's risk only counted what the target branch gained when the
run integrated. Commits people pushed to the branch directly, and
integrations that were never deployed, went out with the next release
without being classified: an environment preauthorized for automatic
release took a migration or a Dockerfile change pushed straight to the
branch without approval. The POC chose what to rebuild from the same
narrow diff, so worker and coordinator kept running old code; on the
local POC, WishForge had in fact only ever rebuilt the api.

The control plane now gives the verifier the commit of the release the
environment runs, and the classification covers everything between it
and the release, as well as what the integration brought. On the POC,
each deployment records the commit and the image a release put there.
The build plans from that snapshot, the one the release is checked
against: worker and coordinator keep their images only while what they
run differs from the source in web files alone. A component of unknown
source (never deployed by a release, restored by a rollback, or set by
hand, which leaves the annotations stale) is rebuilt, and the release
is marked partial: it needs approval and does not roll back on its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 16:44:13 +08:00
eust-w
8b2a8ca4fe 🐛 Build what a run integrated even after people pushed onto the poc branch
The POC build only accepted a source equal to the head of the Gitea
poc branch. Once someone pushed to poc after a run integrated, the
build failed, and so did every continue: a build stopped by a drop of
the link to the cluster could never finish if poc moved meanwhile, and
the run stayed waiting with an error that did not say why.

When poc has moved on, the build now fetches it and requires only that
its history contains the run's commit; it builds that commit and tells
the timeline that the newer commits deploy with a later run. A source
the branch lost to a rewrite is still never built: the run waits on
the repository with POC_SOURCE_REWRITTEN and says to cancel it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 16:43:12 +08:00
eust-w
ad06e82c67 ⚡ Reuse the verification of an integrated commit when its build continues
A build that stopped on an infrastructure fault, like the drops of the
POC's link to its cluster, repeated the whole protected verification
when continued: installation and every check, about two and a half
minutes on the POC, for a commit whose verdict could not change.

When the integrated commit is the verified checkpoint itself, the
verifier now reuses that verification evidence and only restores the
workspace for the build; the timeline says so. The control plane
offers only test and build evidence recorded under the current
protected policy, as a release requires: after the operator changes
the checks, the run verifies again. That also keeps an executor that
continues at the release stage from requesting a release with
evidence the release would refuse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 14:54:01 +08:00
eust-w
3623d318af ✨ Sandbox the local POC's protected checks and installations on macOS, by operator opt-in
In the development host mode, protected checks and dependency
installations ran directly as the operator. They run the agent's code:
a test it wrote could read the home directory's secrets, reach the
network, or plant Git configuration that the trusted Git commands after
it would execute.

With WF_HOST_CHECK_SANDBOX=true they run under Seatbelt instead. File
contents in the home directory are unreadable except the command's own
directory and the paths the operator lists; it may write only there,
in the caches the operator lists and in a temporary directory of its
own, never in a .git directory. Only installations reach the network;
checks may use loopback ports by opt-in, for test suites that start
local servers. The platform's own ports (control plane, Temporal and
its web UI, database, object storage, provisioner, Git service, IDE,
console) stay blocked in any case: the local start lists them from
their configured addresses. Checks get no answer from the keychain,
and a command whose home is the executor's (holding its credentials)
gets a private one. A sandbox that cannot start leaves the run waiting
on infrastructure; verification evidence records checkSandbox.

scripts/check-host-check-sandbox.ts checks all of this on the target
Mac, from outside the sandbox, then runs the POC's installation and
checks sandboxed on a recent droboticflow source. Enabled on the local
POC, a real wish passed through both, including a repair round for the
agent's own failing tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 10:10:47 +08:00
eust-w
92a06dd3b2 🐛 Repeat the POC acceptance checks a settling rollout can fail, and show every retry
The public checks after a POC rollout (health, readiness, the entry
page, the API build commit and the protected smoke checks) were each
made once. Just after a rollout the public address can still reach a
Pod that is shutting down, which answers with the old build commit, and
the link can drop: either failed a healthy release and rolled it back.
They now take up to six attempts, waiting 2 to 10 seconds; a release
whose checks never pass is still rolled back.

Retries were also silent: a build slowed down by a flaky link looked
stuck. Every repeat now says what went unanswered and when the next
attempt comes, in the run's timeline during a build and in the Runner's
log during a release. Requests and checks share one retry helper.

The third live test found kubectl cp and exec reporting a failed dial
as "error: dial tcp ...: connect: operation timed out", without the
"Unable to connect to the server" of get. That upload was not retried
and the build stopped; dial failures and connection timeouts now count
as unanswered, checked against the messages seen on the POC link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 05:06:46 +08:00
eust-w
f752729d1c 🐛 Remove an attempt's workspace when the agent never ran
An attempt that stopped before its agent started (a failed
installation, an unavailable sandbox, a pause) kept its whole clone and
a recovery note on disk, a new one on every continue, although nothing
in it was worth recovering. Only an attempt whose agent ran and whose
checkpoint was not saved now keeps its workspace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 19:21:24 +08:00
eust-w
5f32e4613e 🐛 Keep the output of stopped commands, and stop what commands leave running
- A check stopped at its time or output limit lost everything it had
  printed: the repair prompt only said that WishForge stopped it, not
  where it hung. The stop now carries the output so far, and the
  verification evidence and failed installations keep it, with the
  reason appended.
- A command that left a process running (a test's server, say) held
  its pipes open until the time limit and counted as hanging, and in
  host mode such processes stayed on the machine. A command now ends
  when its own process exits: the rest of its process group gets two
  seconds to drain the pipes and is then stopped, as is anything else
  it left running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 19:21:24 +08:00
eust-w
9c879ff3c5 🐛 Let a failed build resume, and keep the release risk it classified
- verifyRun returned deliver() unawaited inside try/finally, so the
  session closed and deleted the workspace while the build still used
  it: a build continued after an infrastructure failure always failed.
  The failure handlers there were unawaited too.
- The resumed build classified the release risk from the checkpoint's
  base, not the target branch it integrated onto, and replaced the
  earlier classification: a migration brought by an IDE branch no
  longer counted. Integration evidence now records the target commit
  it integrated onto, the resumed build classifies from it, and a
  commit's classification only ever widens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 19:11:12 +08:00
eust-w
30369c1430 ✨ Save the agent's work before a run pauses
Pausing revoked the executor at once: the agent was killed and the work
of the current attempt stayed only in the executor's local workspace,
so continuing started that attempt over.

A pause of a run whose executor holds the lease now drains it first:

- The run keeps `running` with pauseRequestedAt (the console shows
  pausing). Its agent gets no model credential and no new model
  request; continuing is refused until the pause completes; cancelling
  still stops it at once.
- The executor learns of it from its heartbeat, stops the agent, saves
  a checkpoint with its live lease and completes the pause through
  /internal/runs/:id/pause. Continuing restores that checkpoint.
- The workflow is stopped only after the pause completes; stopping it
  earlier would abort the save. A model request interrupted by the
  stop no longer expires the pausing run's lease.
- If the executor does not complete it within two minutes, or stopped,
  the heartbeat, the next lease, the coordinator's wait or the
  background sweep pause the run anyway.

Runs no executor is working on still pause at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 18:38:06 +08:00
eust-w
9b2c8f14a9 🐛 Repair installations the agent's manifest changes broke instead of waiting
Every failed installation waited as an infrastructure fault. When the
agent's own change broke it (a misspelled package, say), continuing
installed the same manifests before the agent ran, failed again, and
the agent never got a turn: the run could not move without a new
requirement revision.

- The verifier attributes a failed installation to the checkpoint when
  it changed dependency manifests (package.json, go.mod, lockfiles and
  the like) and the output is not a network or registry failure. The
  evidence lists those manifests, and the control plane records an
  `install` failure that the next repair round fixes.
- A repair round for an `install` failure starts the agent even when
  the installation fails again, with that output in the prompt.
- Prompts, lessons and the run page name the failed installation.

Any other failed installation still waits for the environment, without
spending a repair round.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 17:32:16 +08:00
eust-w
a89cd1b9b3 ✨ Let Claude Code run commands inside its own sandbox, by operator opt-in
With WF_CLAUDE_COMMAND_SANDBOX=true, Claude Code also gets Bash, run in
its built-in sandbox through --settings:

- The sandbox must start (failIfUnavailable), and no command may run
  outside it (allowUnsandboxedCommands: false).
- No network: an empty allowedDomains with strictAllowlist, since an
  absent allowlist leaves the network open. Local binding stays off,
  because it would also open every local port, Temporal's included.
- Commands cannot read the home directories, the CLI's home or the
  worker's own directory, except the workspace, a per-run scratch
  directory and WF_CLAUDE_COMMAND_READ_PATHS; they write only to the
  workspace and the scratch directory; credential variables are unset.
- WF_CLAUDE_COMMAND_ENV gives commands toolchain variables, such as the
  POC's read-only Go module cache.

The executor probes the sandbox first (Seatbelt on macOS; bubblewrap
and socat on Linux) and keeps file tools only where it cannot start,
saying so on the timeline. The adapter now writes the execution
contract into the prompt, for the tools the agent actually has.

scripts/check-claude-command-sandbox.ts checks a machine with one short
real session and judges each probe by its effect, not the agent's
account. On the local Mac every probe was blocked; the login keychain
remains reachable, because Claude Code's Seatbelt profile always allows
the security server. That limit is documented.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 14:48:16 +08:00
eust-w
fc90c932ba 🔒 Confine Claude Code to workspace file tools and keep CodeBuddy off Kata
Claude Code with a tenant key started with bypassPermissions and every
tool, Bash included, and loaded the repository's settings, hooks and MCP
servers. It now runs like the native development login already did:
restricted mode with dontAsk, only Read/Edit/Write/Glob/Grep, confined to
the workspace, and no repository or user settings. Every Claude Code run
is told the verifier runs installs and tests.

CodeBuddy's agent runs commands with no sandbox of its own. Like Codex
without its sandbox, it now starts only in a development (host) sandbox,
says so on the timeline, and stops with PROVIDER_SANDBOX_UNAVAILABLE on
Kata.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 05:25:36 +08:00
eust-w
6fc7eaf00c ✨ Improve local WishForge reliability and LAN access
Detect actual service and Runner readiness, restore LAN access after network changes, protect production web builds with rollback, honor cancellation during executor startup, and show truthful cached-data and credential states.
2026-10-25 03:29:51 +08:00
eust-w
4e5ab1719c ✨ Enable local Claude delivery to Gitea and POC
Add authenticated LAN access, native Claude execution, checkpoint and budget recovery, and signed POC build/deploy/rollback contracts. Include local service management, regression coverage, and evidence from the completed POC delivery.
2026-10-22 16:21:33 +08:00
eust-w
27b6e19d6b fix: run a wish end to end on the local k3s cluster
The first runs on k3s found these problems; a wish now goes from submission
through the Codex executor, independent verification and integration in
per-run pods.

- Development deployments refused to start because the images set
  NODE_ENV=production. The local manifest and the sandbox Jobs now set
  NODE_ENV to the deployment mode.
- The model proxy treated x-client-request-id as a per-request idempotency
  key. Codex sends its conversation id there, so every second request of a
  session failed with 409. Only Idempotency-Key names a single request now.
- Codex's command sandbox (bubblewrap) cannot start in a runc pod. Every
  command failed and the agent retried until the budget ran out. The
  executor now probes the sandbox before starting Codex. A Kata sandbox that
  cannot run it waits as PROVIDER_SANDBOX_UNAVAILABLE. A development (host)
  sandbox runs Codex without it, and the timeline records that.
- The prompt asked agents to commit, but Codex keeps .git read-only and the
  platform commits the checkpoint itself. Agents now leave their changes
  uncommitted, and get the platform's Git identity if they commit anyway. A
  resolved merge is recorded even when its tree equals HEAD.
- scripts/k3s-local.mjs:
  - excludes the VM and cluster ranges from a host proxy (NO_PROXY);
  - uses its own Docker client configuration, so a stale credential
    helper does not break builds;
  - recovers from an interrupted k3s install;
  - reports when Colima switches the current kubectl or Docker context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 01:47:33 +08:00
eust-w
8b77085a5f fix: let Kubernetes sandboxes start, and run on a local development cluster
Sandbox Jobs never received WF_DEPLOYMENT_MODE, which every worker requires
before anything else, so each Kubernetes sandbox exited at start. The
provisioner now passes its own mode.

A local development cluster (k3s) has no Kata, no bubblewrap inside runc and no
TLS between services. For it, and only with WF_DEPLOYMENT_MODE=development:

- WF_ALLOW_INSECURE_HTTP=true lets services reach each other over plain HTTP
  (Git, the model proxy, the provisioner and IDE gateway targets, the worker's
  control-plane client); production refuses the setting outright.
- The provisioner accepts WF_RUN_SANDBOX_MODE=host and WF_KATA_RUNTIME_CLASS=none
  and passes the HTTP settings to its sandboxes.
- The development seed is built into the image (dist/api/seed.mjs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 00:56:07 +08:00
eust-w
3eb8ea03bf feat: run models through an operator's OpenAI- or Anthropic-compatible gateway
The model proxy always forwarded to api.openai.com and development runs gave
Codex no base URL or model, so a company model gateway could not be used.

- WF_OPENAI_BASE_URL points the production proxy (and development Codex runs)
  at an OpenAI-compatible gateway with the Responses API; WF_ANTHROPIC_BASE_URL
  gives Claude Code an Anthropic-compatible one as ANTHROPIC_BASE_URL. Both are
  operator settings in the provider catalog, HTTPS without credentials
  (loopback HTTP outside production); an invalid gateway disables the proxy.
- Development credentials now carry the run's model, so WF_CODEX_DEFAULT_MODEL
  selects a model the gateway serves.
- tests/integration/real-model.test.ts (WF_REAL_MODEL_INTEGRATION=1, key from
  WF_TEST_MODEL_API_KEY) runs one wish through the real Codex executor, the
  verifier and integration into a local repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 22:28:33 +08:00
eust-w
1d75b03430 feat: register executors in one catalog and add Claude Code (FR-D1)
Adding an executor touched the contracts, the API's availability check, the
worker and the console separately. Now it is an adapter plus one entry in
@wishforge/contracts' providerCatalog (name, executable variable, whether the
model proxy isolates its credentials) and one in the worker's
providerRegistry; the API, the console's options and MCP's submit_wish read
the catalog, and a test checks every entry is registered with the worker.

The CodeBuddy adapter already parsed Claude-Code-style stream-json, so it is
now a StreamJsonCliAdapter with a dialect per CLI. Claude Code runs headless
with --verbose and --permission-mode bypassPermissions inside the per-run
sandbox and receives only ANTHROPIC_* credentials (WF_CLAUDE_BIN). Like
CodeBuddy it is development-only until the model proxy supports it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 20:23:05 +08:00
eust-w
d7d2cb705d feat: run images from built services instead of transpiling at start-up (FR-K5)
scripts/build-services.mjs compiles the API, its migration runner, the worker,
the Runner and the platform Git service into single ESM files under dist/.
Workspace packages are compiled in, everything else loads from node_modules,
and esbuild applies the transform tsx applied before, so behaviour does not
change. The Temporal workflow bundle is built at the same time and the worker
uses it when present instead of bundling at start-up.

The runtime image builds the services and runs dist/*/main.mjs; the
Kubernetes provisioner starts sandboxes with dist/worker/main.mjs, and
migrations run as node dist/api/migrate.mjs. esbuild is now a declared dev
dependency. A test builds everything and checks that each entry point loads
all its imports and reaches its own configuration checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 20:15:42 +08:00
eust-w
223f497624 feat: give Kubernetes sandboxes an egress proxy for installs and a remote image builder
In Kubernetes mode the per-run network policy allowed only DNS, the API,
Temporal and Git, so dependency installs could not reach a registry and image
builds had no builder.

- WF_RUN_INSTALL_PROXY_URL points both sandboxes at an operator's egress proxy
  (pods labelled egress-proxy); the per-run policy admits it and installation
  commands get HTTP(S)_PROXY, also inside bubblewrap, while checks still have
  no network.
- WF_VERIFIER_DOCKER_HOST with a TLS client certificate points the verifier at
  a remote builder daemon (pods labelled image-builder); a separate policy
  lets only the verifier pod reach it, and release deletes that policy too.
  Builds pass DOCKER_HOST, DOCKER_TLS_VERIFY and DOCKER_CERT_PATH, and refuse
  a Docker context and a remote builder together.
- The control namespace's baseline admits sandbox traffic to both components.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 20:05:30 +08:00
eust-w
15e137ff7f feat: isolate tenants in Temporal with per-tenant namespaces and mutual TLS
Sandboxes can reach Temporal, which used to accept any client in one shared
namespace. Now:

- Every Temporal client (API dispatcher, coordinator, deployer, sandboxes) can
  present a client certificate (TEMPORAL_TLS_*); production refuses to start
  without one.
- TEMPORAL_NAMESPACE_PREFIX gives each tenant its own namespace: the dispatcher
  starts and signals a tenant's workflows there, the shared coordinator and
  deployer poll every served tenant's namespace with one workflow bundle, and a
  sandbox polls only its tenant's. Production refuses to serve several tenants
  through one namespace.
- The Kubernetes provisioner mounts the tenant's Temporal client certificate
  into executor and verifier pods (WF_RUN_TEMPORAL_TLS_SECRET, required in
  production); the local provisioner passes the TLS settings through.

Authorizing certificates per namespace remains Temporal server configuration;
the operations guide describes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 19:59:49 +08:00
eust-w
fb0f60ebe0 feat: let the agent ask clarifying questions before implementing (FR-C4)
A first implementation round may end, without changing any files, with a
QUESTIONS: section of up to five questions. The executor then puts the run in
the clarification wait with the questions in its detail, where the console and
MCP show them; answering already creates a new requirement revision that
starts again from planning. Repair rounds cannot ask: they must fix what the
verifier found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 19:51:16 +08:00
eust-w
0bcfbc13dd feat(ide): push IDE work to ide/ branches and merge it through a verified wish
People's changes now reach the target branch the same way the agent's do. The
IDE credential carries a ref prefix and the Git service runs a pre-receive hook
on every push that refuses updates outside it, so the IDE can push only
`ide/` branches; the platform's own integration is unaffected.

- A wish may name a source branch. The run starts from that branch's head, the
  agent builds on it, and verification, repair rounds, merging onto a moved
  target and conflict repair work as before. A missing branch makes the run
  wait (git_storage) until it is pushed.
- Release risk is now computed from the target branch before integration, not
  from where the run started: a migration committed on the source branch would
  otherwise have been missed and could have skipped approval.
- Clones work on `ide/work`; a plain `git push` publishes it.
- The console lists a project's IDE branches with a button to submit a wish
  that merges one, and the new-wish form has a starting-point field; MCP
  `submit_wish` accepts `sourceBranch`. The Git service lists branches under
  a prefix for this (`POST /refs`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 19:17:14 +08:00
eust-w
b38db08eeb docs: align documentation with the code and write it in Chinese
Operations, development and architecture docs, the reference pages and the
component READMEs were rewritten against the code: every documented variable
exists, and the settings operators need (runtime image, Git service, listen
addresses, Runner targets, single-tenant gateway and provisioner bindings) are
documented.

Gaps the docs used to present as working are now stated as such: IDE
workspaces do not clone the project yet (FR-H2), and in Kubernetes mode
dependency installs and image builds have no network path until an egress
proxy and builder access exist. The Kubernetes README describes what the
provisioner creates, what the Runner needs in a target namespace, and the
cluster acceptance that is still outstanding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 18:01:39 +08:00
eust-w
0b4c09f7eb refactor: declare every entity field instead of an open index signature
Entity carried `[key: string]: unknown`, so a misspelt field compiled and most
records were read as untyped bags. Every stored kind now has an interface in
contracts (workspace, runner task and registration, provider connection,
checkpoint record, resource allocation, integration lease, delivery config) and
the project, run, release and evidence types list all their fields. Entity writes
are generic over the record type, and the project delivery settings no longer
accept a stray target branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 16:32:36 +08:00
eust-w
5aea9b73a9 fix: harden the control plane's storage, identities and recovery paths
- Storage: read-only queries use a read-only transaction without the tenant
  lock, so event streams and dashboards no longer queue behind writers; lists
  filter on indexed project, run and status fields and the run list pages with
  limit/before. Dispatchers claim outbox items with SKIP LOCKED and a claim
  deadline; delivered items and old idempotency records are pruned hourly.
- Migrations are versioned files recorded with checksums in schema_migrations;
  002 adds the claim column and run index and migrates preview-stage runs and
  free-text waiting reasons. Run events and usage are append-only for the app.
- Identities: static service tokens reach only their routes (coordinator: state,
  wait, repair; deployer: lease, transition, releases); the static verifier
  identity is gone; Git credentials go only to the lease holder; internal bodies
  are validated; framework and body-parser errors use the API error envelope.
- Quotas: only queued or running runs (or ones with an unsettled model request)
  hold token reservations; continuing a run reserves its remaining budget again.
- Recovery: owners can list and reconcile model requests with an unknown outcome,
  and requests whose proxy died are marked unknown; definite deployment failures
  free the environment, admins can unlock an environment after checking the
  target, approvals expire with their release, and production approvals need a
  second person. The builder's Docker context is operator configuration.
- MCP: list_projects, absolute console links, request_release resolves the run's
  evidence and default environment, and tool changes are audited as the user.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 16:16:47 +08:00
eust-w
a9411f586b feat: run the whole loop locally with a local provisioner
Local development had no provisioner, so every wish stopped at "sandbox not
ready", and dev:all started neither the coordinator nor the deployer.

- The provisioner moves from apps/ide to apps/provisioner and gains a backend
  switch: `local` starts an executor and a verifier process per run generation
  on this host (WF_SANDBOX_MODE=host, own directories and run-scoped tokens,
  development mode only) and points workspaces at the local Theia; `kubernetes`
  keeps the Kata Jobs, now started with the image entrypoint instead of the npm dev
  script and allowed to reach the platform Git service.
- In development the resource grant needs no runtime image digest.
- setup:local is one idempotent script that creates or completes .env.local,
  including the deployment mode, provisioner and grant settings.
- dev:all starts Git, API, provisioner, coordinator, deployer and web; dev:ide
  starts Theia and the IDE gateway; ide:install and ide:build wrap the separate
  Theia package. npm test also runs the provisioner tests.
- Project settings accept the target branch and dependency install commands.
- Web development conveniences require WF_DEPLOYMENT_MODE=development.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 15:36:12 +08:00
eust-w
cce214f8fb feat: close the main loop from wish to integrated commit
Verification ran git inside the tree under test, kept no command output and
treated every infrastructure fault as a test failure; repairs went through an
executor lease the coordinator should not hold; and a project without delivery
could never succeed. This reworks the worker execution path and the control-plane
contracts it depends on.

- Verification exports the exact commit to a directory without .git, installs
  dependencies (network allowed) and runs the protected commands under
  bubblewrap in kata mode or directly in host mode; evidence records exit code,
  duration, digest, a redacted output tail and the isolation used. Production
  rejects host evidence. A failed installation waits as infrastructure.
- Waiting reasons are an enum with a redacted detail; dispatcher, GitHub and
  model-proxy states map onto it, and the console explains each one with a way out.
- Repairs are requested by the coordinator through /internal/runs/:id/repair;
  the control plane derives the failure summary from the verifier's evidence and
  enforces the repair budget. Continuing after the budget is spent grants one more
  round; a new requirement revision starts a fresh budget.
- Execution identities may only move a run within their own stages and only to
  running or waiting; success comes from integration evidence (no delivery
  configured) or deployment acceptance. The unused preview stage is gone.
- Integration fast-forwards when the target has not moved, merges and re-verifies
  otherwise, retries when a push finds the target moved, and turns merge conflicts
  into a repair round that merges the current target for the agent to resolve.
- Successful runs that needed a repair leave a project lesson; active lessons are
  injected into later prompts, and admins can list, add, disable and delete them.
- Executor progress (messages, commands, file changes, plan updates) is stored as
  normalized events; previously agent messages were recorded as the literal word
  "output". Provider failures keep the work as a checkpoint and wait as
  provider_error instead of failing the run.
- Workers declare WF_SANDBOX_MODE=host|kata (host refused in production),
  heartbeat with retries until the lease could have expired, and retry safe
  control-plane reads with backoff.
- tests/local-loop.test.ts runs the loop end to end with real Git, the in-process
  control plane behind its internal routes and a scripted agent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 15:15:54 +08:00
eust-w
78ed117763 feat: make the deployment mode explicit and fail closed
Security-relevant behaviour (development tokens, loopback HTTP, inline
checkpoints, raw provider keys, optional verification profiles) was
keyed off NODE_ENV === 'production', so any deployment that forgot
NODE_ENV silently ran with development rules.

- @wishforge/contracts exports deploymentMode/isProduction/
  requireDeploymentMode. WF_DEPLOYMENT_MODE wins; misspelled values and
  development combined with NODE_ENV=production are rejected; NODE_ENV
  remains a fallback only for libraries and tests.
- All API, runtime, artifact, Git service and operator-script checks use
  isProduction.
- The API, worker, Git service and Runner refuse to start without an
  explicit WF_DEPLOYMENT_MODE; the IDE gateway treats anything other
  than an explicit development mode as production.
- The development seed loads .env.local before checking the mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 14:07:02 +08:00
eust-w
b90db2cc6f refactor: remove dead code and typecheck the test suite
- Drop the WorkBuddy Cloud executor stub: it always reported
  "unverified" and could never run. WorkBuddy remains an MCP client for
  submitting wishes. Providers are now codex and codebuddy; an unknown
  provider waits with an explicit reason instead of a fake adapter.
- Remove internal routes nobody calls (/internal/releases/:id/begin,
  /accept, /failure and /internal/workspaces/:id/provisioned) with
  their domain methods, the never-consumed release.ready and
  release.rollback outbox events, an unreachable idempotency branch,
  dead helpers in runtime/deploy.ts and an unused RunnerBroker
  dependency.
- Enable noUnusedLocals in the base and web TypeScript configs; the
  runtime package now extends the base config.
- Add tests/tsconfig.json and include it in `npm run typecheck`. This
  surfaced tests still calling the deleted begin/accept path (now
  exercised through the Runner protocol) and five latent type errors.
- Web: provider capability labels match the API's keys and the wish
  form disables unavailable providers.
- Delete the invalid example Runner Job manifest; stop tracking the
  generated apps/web/next-env.d.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 14:02:27 +08:00