Generic tasks and images¶
Long-term Task candidate¶
Long-term Tasks are separate from one-shot chattask run. POST /api/durable/tasks accepts request_id, instructions and image_profile; the authenticated principal becomes owner. GET /api/durable/tasks, /{id} and /{id}/runs return private history. POST /{id}/resume accepts a new request_id, instructions and optional acknowledge_unknown=true; POST /{id}/pause and /{id}/complete accept request_id. Owner-only POST /{id}/members grants a named principal viewer or editor. GET /{id}/runs/{run_id}/artifacts/{name} checks access and SHA256. These paths all start with /api/durable/tasks, and writes use the existing site CSRF protection. Equal repeated request IDs return the same result; changed input conflicts. An active round cannot be resumed again.
Creation defaults to workflow=development. Research either sets workflow=research with 1–12 caller-verified source_records, or uses authenticated POST /api/durable/research/auto with request_id, instructions, image_profile, plain-text query and optional max_results (1–5). The latter retrieves and persists real arXiv Atom abstracts on the Task. This is abstract-only discovery; it does not imply full-paper reading or relevance review. Later rounds can supply new records or inherit the prior set. The model must write /workspace/result/research/main.tex as self-contained ctexart/xelatex with inline bibliography; references.bib, report and source metadata may accompany it. The trusted worker reads only that round's result archive and never accepts browser-selected container, project, user, path or command. ResearchPublisher binds the original Overleaf project to the Task; actual PDF and source readback become research.pdf and research-source.zip on the same Run, with native receipt and project link. Compile, sync and conflict failures stay blocked. After inspecting an unknown external outcome, POST /{id}/reconcile-research with a new request_id and acknowledge_unknown=true enqueues same-Run publication reconciliation without rerunning Codex.
The bridge is enabled only when both CHATTASK_RESEARCH_OVERLEAF_CONTAINER and HTTPS CHATTASK_RESEARCH_OVERLEAF_ORIGIN are configured. Development tasks need neither. Optional sensitive CHATTASK_LOGIN_USERS_JSON contains at most eight records with username, password, principal_id, display_name, verified by shared ChatLogin. The original site-operator username/password and site-operator principal remain; principal IDs must be unique. Do not add test accounts to production. Operators supply configuration, never browsers.
Web only enqueues. Run chattask worker --env-profile site --operator operator independently, with --once to process at most one round. Trusted local CLI uses chattask task create/list/show/resume/pause/complete with explicit --owner and --env-profile. The worker needs the existing model gateway, OpenSandbox and registered image. One process holds a native flock; after a worker crash, an active round becomes interrupted and possible external writes require inspection. The queue never replays it automatically. Web restart does not cancel the worker.
Each new Sandbox round checkpoints bounded /workspace/work, /workspace/result and $CODEX_HOME/sessions; links, traversal, special files, secret-looking paths, excess content and known short-lived credentials are rejected. A successful round requires native session ID, turn.completed, a verified checkpoint, container cleanup and gateway lease closure. A later round uses exact-session codex exec resume after checking supported flags in the guest. Pause is cooperative at the round boundary: queued work can pause before start, running work finishes its round first. Failed or interrupted rounds require explicit inspection; an initial failure without a checkpoint remains blocked. Production readiness is established only by the deployed image, gateway, original service and browser acceptance.
- Task: instructions, acceptance criteria, stable request identity and a registered image profile. A verified prior result can be selected as input.
- Executor: Codex works in a real Sandbox, not in the host source environment.
- Image: supplies Codex, its companion binaries, Python, a shell and task-specific infrastructure.
- Result: final text, native events, hashed output files and independent cleanup evidence. Package publishing is an example task, not the engine's fixed workflow.
Configuration boundary¶
The ChatTask ChatEnv provider defines CHATTASK_CODEX_BASE_URL, sensitive CHATTASK_CODEX_API_KEY, CHATTASK_CODEX_MODEL, CHATTASK_CODEX_IMAGES, and the optional pair CHATTASK_CODEX_TOOLS_URL / sensitive CHATTASK_CODEX_TOOLS_TOKEN. Model and tool credentials are separate; a model key is not a tool token. Images use a JSON profile mapping such as {"python-package":"<operator-provisioned-image>"}. The browser can select only registered profile IDs.
Never bake credentials into an image. Runtime command environments inject the Codex access credential. Guest programs can still read that environment, so prefer a short-lived, constrained model/tool gateway credential. Keep GitHub PATs, PyPI passwords, sessions, TOTP secrets and upload keys on their respective trusted tool services. Task input cannot select host paths, raw credentials, arbitrary provider URLs or arbitrary images.
The current image contract includes codex, the companion tool host required by that Codex version, Python 3 and sh. Add Git, compilers, ChatPyPI or other infrastructure according to the task. A package image does not make Python packaging mandatory for generic tasks. Ordinary Docker/runc is a trusted-user isolation boundary, not strong isolation for hostile multi-tenancy.
CLI entry¶
chattask run --instructions-file task.txt \
--image-profile python-package --request-id task-001 \
--env-profile site --json-output
The same request ID and input reconcile to the existing task. Changed input under that ID is rejected. --input-task-id accepts only the same owner's existing digest-verified result archive. CLI calls reuse chattask.agent_tasks.run_task; Web and HTTP share AgentTaskService and CodexTaskExecutor.
HTTP entry¶
| Route | Operation |
|---|---|
GET /api/agent/images |
List configured image profiles |
POST /api/agent/tasks |
Submit request_id, instructions, image_profile, optional input_task_id |
GET /api/agent/tasks |
Current owner's tasks |
GET /api/agent/tasks/{id} |
Status, result, steps, runtime and cleanup evidence |
POST /api/agent/tasks/{id}/cancel |
Request cooperative cancellation |
GET /api/agent/tasks/{id}/artifacts/{name} |
Digest-checked output download |
Routes reuse the host's login and CSRF boundary without exposing model/tool credentials. Closing the browser does not cancel an accepted server-side task.
State and acceptance¶
queued → running → completed, blocked or interrupted. A completed execution means the native Codex turn finished, outputs were collected and the Sandbox was removed. It is not independent proof of an external publication. A release task additionally needs real repository, Publisher, merged tag, OIDC upload, registry and clean-install evidence.
The default Codex command budget is 900 seconds; Sandbox lifetime includes cleanup headroom and must be allowed by the control plane. Existing per-Sandbox limits remain 1 CPU, 512 MiB, 128 PIDs, no host mounts and loopback data ports. Failed turns preserve redacted native events when available. Uncertain external writes are never replayed automatically.
Python package template (candidate source)¶
The Python package card uses the same versioned, channel-neutral schema as GET /api/package/schema. A one-sentence request prefills only an obvious mode and name. The user provides the module, CLI, owner/repository, description and explicit requirements. The defaults are a private repository, MIT, Python >=3.10, bilingual MkDocs and standard CI/OIDC. Literal names are preserved and checked before remote lookup; normalized collisions block preparation.
Owner-bound drafts support create, edit, prepare and confirm through /api/package/drafts routes. Every mutation uses a stable request ID. Editing increments the revision and invalidates the old preview. Preparation runs a read-only scoped Codex Sandbox task and produces a bounded package-plan archive. A trusted Sandbox script runs tests and builds wheel/sdist; the server verifies the archive, source manifests, metadata and a separate attestation before showing an exact confirmation phrase. Confirmation starts a second task with only the approved target, source and artifact digests, and action list. Task completion alone is not a publication claim; external receipts and clean installation still need inspection.
Package preparation and submission require an optional HTTPS broker configured with CHATTASK_GATEWAY_URL and sensitive CHATTASK_GATEWAY_CLIENT_TOKEN. Generic tasks retain their legacy runtime option. The broker returns fresh per-task model and tool access, while upstream provider credentials remain on trusted services. CHATTASK_CODEX_HOSTS is an operator-owned hostname-to-IP JSON mapping applied only inside a guest, when required. The CLI exposes package schema, plan, draft-create, draft-show, prepare and confirm. CLI drafts have an operator owner separate from web drafts.
Feishu button cards may link to this site's authenticated form for text input. This package does not implement Feishu transport or native card text callbacks. Deployment and external publication verification remain separate from these source interfaces.
The gateway response must bind id to the exact task ID and model_base_url to
Preparation permits at most 100 source files per branch, 200000 bytes per file, and 2000000 bytes per branch. After native Codex completion, trusted publication validation checks the exact approved plan digest, scoped release source/PR/merge/CI/tag and actual Publish-to-PyPI job/step receipts, PyPI JSON and wheel/sdist file hashes, and a clean install in a fresh Sandbox venv with CLI --version and --tree. Missing evidence blocks the task; evidence is saved in trusted-publication.json and install logs. The scoped status response must expose repository, branches (release SHA, manifest digest and base SHA; main SHA and manifest digest), pull_request, ci.release / ci.main, tag, and publish (workflow/head SHA, job/step names, conclusions, and actual publish action) from provider receipts.
Publication validation reads the exact release JSON through scoped GET /pypi/api/release and, for new projects only, the 0.0.1 placeholder through GET /pypi/api/placeholder. It fetches each official distribution by its SHA256 through scoped GET /pypi/api/artifacts/{sha256} (10 MiB per file), hashes the bytes again, and installs the verified target wheel. The gateway must restrict these fixed read-only routes to the approved project, version and official file digests. With the existing pinned CHATTASK_PUBLIC_DEPS_PATH and CHATTASK_PUBLIC_DEPS_SHA256 archive, validation extracts only deps/wheelhouse/*.whl into a fresh directory and installs with --no-index --find-links. Already installed .py/.so files in the archive are not used as wheels; an empty or invalid wheelhouse blocks validation. Without an archive, dependency resolution explicitly uses the public index while still installing the verified target wheel. The trusted receipt records the dependency source and archive digest. Operators must provision a new pinned archive containing the original infrastructure files plus wheels.
Read-only recheck after a submitted publication¶
When the original publish task is terminal but its final readback failed, the draft page offers a read-only recheck. It creates a new trusted Sandbox validation task against the same approved preparation archive, source manifests, target, and version. It does not run Codex, upload again, create a PR, or tag. The original task status and error remain intact. The page shows the new result separately. A failed recheck requires an explicit new request ID; an uncertain response is reconciled with the same ID. The verify gateway session supplies only scoped read-only tools, no model access, and receives the original policy plus verification_of identifying the original publish task. Public registry and scoped status reads retry only transport timeouts or connection failures, at most twice; certificate, permission, target, and digest failures block immediately.