Skip to content

feat(cli): declare projects, agents, labels, tasks and credentials - #5000

Merged
yannickmonney merged 12 commits into
mainfrom
feat/managed-projects-agents
Oct 15, 2026
Merged

yannickmonney merged 12 commits into
mainfrom
feat/managed-projects-agents

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A managed declaration (tale config platform, a deployment's configuration / configurationSource, tale deploy --configuration-only) can now create, not only adopt, what a fleet of agents works with, so the fleet's own Tale is infrastructure as code:

  • Six new managed kinds — project, project-label, project-agent, task (standing tasks), agent-secret, connector-credential. Without a policy each adopts the resource its identity names, as before. With createIfMissing: true it creates an absent one, under a stable UUID the declaration chooses (project, agent, task), so a retried apply finds what an interrupted one created.
  • One kind per field. An agent's harness, model, instructions and tools stay with agent-model / agent-instructions / agent-tools. A created agent is seeded from them, so it never runs on anything else, and creating one requires its agent-model in the same declaration. A task's description stays with task-instructions. Its status is never declared or reconciled: initialStatus (backlog/todo) is a creation-only policy. A field a declaration leaves out keeps what Tale stores.
  • Secrets never enter a declaration, plan, receipt, journal, audit row or refusal. Values come from TALE_CONFIG_SECRET_* variables in the CLI's environment (in a managed deployment, the backend container's environment; each such variable must be a required environment reference, as for provider-credential). Readback is a salted PBKDF2-SHA-256 digest (600,000 iterations, OWASP's figure) computed server-side from the stored value, on the thread pool so the event loop is not blocked. A value rotated in the environment, or replaced in Tale, plans as update while the declaration hash stays the same. tale config platform read shows valueMatches, never the digest. The digest, and the plan/receipt hashes over it, still verify the value offline, so the docs say to treat plans and receipts of secret resources as sensitive. OAuth credentials are never declarable, and a credential keeps its sign-in method.
  • What planning refuses before anything is written. Inside a project, agent or task the declaration creates, only what can be written there plans: a resource that creates itself, the project's instructions, and the model/instructions/tools/description/review context of an agent or task the declaration creates. An adopt-only resource there (a label or agent without createIfMissing, the model of an undeclared agent, the description of an undeclared task) and a task in a new project assigned to an agent nothing creates there are refused at plan. A connector credential is checked against its connector (POST /api/app/connector-credentials/configuration/check, no values sent): unknown connector, sign-in method or endpoint the connector does not take, a changed sign-in method, or a new credential for a connector with required per-credential settings (imap-smtp, http) are refused, naming the field and code.
  • Task labels compare case-folded. A task wears a label by its case-folded name in its declaration and readback, so Bug on a project whose label is bug converges; the spelling belongs to project-label.
  • Plan/apply interplay with fix(platform): check a managed dispatch before anything is written #4995's dispatch check. Nothing inside a project, agent or task the declaration creates is read while planning: those resources plan as create, and apply writes over what the creation left, a retried plan included. The dispatch check sends planned (the agents, standing tasks and labels the dispatch names that the declaration creates, and whether it creates the project). The platform counts them for the check only, and the save, written last, checks what then exists. For a project the declaration creates, the check judges the declaration alone (plus the default labels) and requires an organization Owner/Admin.
  • Apply order: project → project-label → agent-secret → connector-credential → project-agent → task → instruction/tool/model/review kinds → automations → project-dispatch (last, unchanged).
  • Composition: a declaration file may include other declaration files (relative, same source rules, captured into the immutable bundle), merged before validation. A {file} reference named several times is read once. Including the same declaration twice, or in a cycle, is refused. The 128 caps on declaration, plan, journal, receipt and source files are all raised to 512.
  • No delete/prune (unchanged): the docs describe the two-phase retirement (switch off, apply, then drop).

Refinements of the brief, based on what the code does:

  • project-label has no color/description, because labels have no description column and their colour is derived from the name.
  • project-agent has no harness, because agent-model owns it (no two kinds per field).
  • connector-credential also needs authMethod (api-key | bearer | basic) so the platform knows which secret fields to expect. It carries no per-credential settings (config), so connectors that require some (imap-smtp, http) are connected in Tale, and the mailbox-only smtpUsername/smtpPassword fields are not declarable.

Spec rules: PROJ-R21, PROJ-R22, TASK-R67, TASK-R68, TASK-R69, ASEC-R5, CCRED-R8. TASK-R62–R66 are already used by open PRs #4997/#4998, so this PR starts at R67. Manual coverage is recorded as rows in reference/automation/{projects,tasks,connectors}.md plus an error-codes.md row.

Upgrade facts

  • No migration: ids are already text with a default, so an explicit UUID insert works.
  • New app doors under /api/app/... (not /api/v1): projects/{id}/configuration/project, projects/{id}/agents/{agentId}/configuration/agent, tasks/{taskId}/configuration/task, tasks/labels/by-project/{projectId}/configuration, agent-secrets/configuration, connector-credentials/configuration and connector-credentials/configuration/check. The dispatch check accepts an optional planned body.
  • --configuration-only accepts these kinds, but declaring a new secret or rotating a value changes the rendered backend environment, so it needs a full deployment (documented).
  • New variable prefix: TALE_CONFIG_SECRET_ (at most 80 characters). It is documented in .env.example and in the environment reference.
  • A CLI that declares these kinds needs a platform that has these doors. An older platform answers 404 at plan, before anything is written.

Checklist

  • bun run check passes: not run monorepo-wide on this shared, loaded Mac. Targeted gates are listed under the test plan, and CI runs the rest.
  • bun run lint:sast passes: opengrep on every changed source file, 0 findings.
  • Translations: N/A. No messages/ key changed; the user-visible text is docs, in EN/DE/FR.
  • Docs updated in docs/{en,de,fr}/: the CLI install guide, the environment reference, MCP settings and dispatch. tools/cli/README.md is updated too.
  • Root README*.md: N/A.

Test plan

Gates run locally, all green:

  • tsc --noEmit on @tale/shared, @tale/cli and @tale/platform.
  • oxlint on shared and CLI, plus oxlint --type-aware on the changed platform files.
  • oxfmt --check on the changed files.
  • @tale/shared vitest: 1022 tests.
  • CLI bun test src: 1940 pass. 2 tests fail in acceptance-request.test.ts (actual TLS transport, ECONNREFUSED origin.example.test). They fail in isolation too, are untouched here, and come from the local DNS environment.
  • Platform vitest: the projects, tasks (managed, routes, dispatch), agent_secrets and connector_credentials domains, plus the domain-specs and env-example-scope guards.
  • @tale/docs vitest: 716 tests.
  • lint:manual, lint:links, lint:conflicts and knip.

New tests:

  • packages/shared/src/config/managed-fleet.test.ts: schema, identities, caps, kept fields, digest.
  • tools/cli/src/lib/config/managed-fleet.test.ts, the plan/apply flow against a stateful stand-in: create whole, dependency order, the planned dispatch check (bounded to what the dispatch names), adopt/converge/CAS, retry after a lost response inside a created project, secret rotation, no value in plan/journal/refusal, configuration-only.
  • configuration-source.test.ts: include, cycle, read once, 512.
  • inputs.test.ts: a secret's variable must be a required environment reference.
  • Platform managed*.test.ts and routes.managed.test.ts for the six doors: gates, path/body identity, UUID-only creation, planned on a check only.

Re-verified on the pushed head 5fe1df0c74:

  • CI fast tier on this SHA: Format, Lint, Type check, Knip, Unit (platform 1/2, 2/2) and Unit (workspaces, turbo run test --filter='!@tale/platform', which includes @tale/cli and @tale/shared on Linux) are green. The CI ready (*) jobs fail only on the draft hold ("Draft pull request is held"); Backend integration, E2E, Build and CLI builds are skipped while the PR is a draft.
  • Local: tsc --noEmit (shared, CLI, platform), oxlint (CLI), oxlint --type-aware (whole platform, shared), oxfmt --check on every changed file, commitlint over the range, lint:conflicts, lint:manual, lint:links, knip and opengrep on the changed files (0 findings).
  • Local tests: @tale/shared vitest (55 files, 1023 tests). CLI src/lib/config and src/lib/deployment, file by file: 64 of 65 files green (1264 tests); acceptance-request.test.ts fails 2 TLS tests on ECONNREFUSED origin.example.test, which is local DNS (the file imports nothing this PR changes). Platform vitest: agent_secrets, connector_credentials, projects, tasks, automations, governance, core/tasks, rest, mcp settings, lib/mcp, lib/i18n, scripts/openapi and every guard except turbo-inputs, in four runs (156 + 152 + 22 + 13 files; 1,948 + 2,889 + 219 + 772 tests), all green. @tale/docs content suites (24 files, 638 tests).

Review round (findings 1–6), on head 8c5fec7d78

Each finding was verified against the code and fixed with a test:

  1. Adopt-only resource inside a created parent → refused at plan (tools/cli/.../managed-fleet.test.ts: adopt-only agent, adopt-only label, model of an undeclared agent, description of an undeclared task, task assigned to an undeclared agent; zero writes each; an adopt-only agent still adopts once the project exists).
  2. Task labels in another case → foldedLabels on both sides (shared schema test, platform managed-entities.test.ts with Bug vs built-in bug, CLI end-to-end converge with a stand-in that now stores the catalog spelling).
  3. Credential check at plan + SMTP fields dropped (platform managed.test.ts against the shipped catalog: confluence/github/http/imap-smtp/unknown/fixed method/oauth2; routes.managed.test.ts for the check door; CLI test for http, unknown connector, missing endpoint, no value in any request).
  4. Project audience writer only on a changed teamIds (an editor renames with restated teams; a reordered list still goes to the admin-only writer).
  5. 600k iterations, read shows valueMatches (CLI test), docs note.
  6. Docs EN/DE/FR + README: configuration-only and secrets.

Gates run locally on the final tree: tsc --noEmit (shared, CLI, platform), oxlint (CLI, shared, platform --type-aware), oxfmt --check on changed files, commitlint over the range, knip, lint:manual, lint:links, lint:conflicts; @tale/shared vitest (55 files, 1024 tests); CLI managed-fleet.test.ts (22 tests) and src/lib/config + src/lib/deployment (1273 pass, 5 skip, the same 2 local-DNS TLS failures in acceptance-request.test.ts); platform vitest for connector_credentials, projects, tasks, agent_secrets, rest/error-codes and tests/guards (151 files, 2030 tests); @tale/docs locale/structure/docs/links/frontmatter suites (13 files, 525 tests).

Not done

  • backend:integration (real Postgres) was not run: it needs the tale-db image and Docker, which this session could not start. The new writers are covered by unit tests with stand-ins. A real-Postgres lane for create/adopt (explicit-id inserts, label respelling, secret digest readback) would be a good follow-up, and CI's Backend integration check runs the existing lanes.
  • No E2E or real-deployment proof of a fleet created and adopted end to end.
  • Task labels inside a project the declaration creates are not checked at plan against the built-in and declared labels; an unknown one still stops the apply at the task (TASK_LABEL_UNKNOWN). Likewise an agent granted a secret the organization lacks and nothing declares stops at the agent.
  • MCP stays read-only for these kinds by design: they are listed in SETTINGS_KINDS_NOT_OVER_MCP with cli: true and a reason.

@yannickmonney yannickmonney changed the title feat(cli): declare projects, agents, labels, standing tasks and credentials feat(cli): declare projects, agents, labels, tasks and credentials Oct 15, 2026
@yannickmonney
yannickmonney force-pushed the feat/managed-projects-agents branch from 59926ad to 5fe1df0 Compare October 15, 2026 11:11
Six managed kinds (project, project-label, project-agent, task,
agent-secret, connector-credential) adopt the resource their identity
names, and create an absent one under a caller-chosen stable UUID when
the declaration says createIfMissing. Each field has one owning kind:
an agent's harness, model, instructions and tools stay with agent-model,
agent-instructions and agent-tools; a task's description with
task-instructions, and its status is never declared. A field left out
keeps what is stored.

Secrets name a TALE_CONFIG_SECRET_ variable, never a value; readback
carries a salted PBKDF2 digest of the stored value so a rotated value
reads as a change. One declaration holds up to 512 resources. The task
limits move to the shared package, and the automation door narrows the
widened union by kind.
Managed configuration doors for a project, a project agent, a standing
task, a project label, an agent secret and a connector credential: each
reads in its declaration's shape (null for an absent id a creating
declaration names) and writes through the app's own writers on the hash
the plan read. A created agent starts with its declared runtime, model,
instructions and tools; a created task in backlog or todo, its status
never reconciled afterwards; nothing absent from a declaration is
deleted.

A secret's or credential's value travels only in its own write; readback
answers a salted digest computed from the stored value, and an OAuth
credential is never declared. A dispatch check counts the agents, tasks
and labels its declaration creates, and checks a project the declaration
creates against the declaration alone, for an Owner or Admin.
Plan and apply create what other resources refer to first (project,
labels, agent secrets, connector credentials, agents, tasks), then the
instruction, tool and model kinds, automations and dispatch. Nothing
inside a project, agent or task the declaration creates is read while
planning; apply writes on what the creation left, a retried plan
included. A dispatch check sends the agents, tasks and labels the
dispatch names that the declaration creates.

Secret values are read from TALE_CONFIG_SECRET_ variables when planning
and applying, compared by digest and sent only in their own write, never
into a plan, receipt or refusal; a managed deployment requires each such
variable as an environment reference. A declaration file may include
other declaration files, merged before validation, with a file named
twice read once; plans, receipts and declarations hold 512 resources.
Configuration-only deployments accept the new kinds.
The CLI install guide lists the six fleet kinds with their identities
and fields, the apply order, how secret values are read from
TALE_CONFIG_SECRET_ variables and compared by digest, includes and the
512-resource limit, and the two-phase retirement (switch off, apply,
then drop). The environment reference, the MCP settings page and the
dispatch page say the same in EN, DE and FR.
A managed read of an agent secret or a connector credential derives a
100,000-iteration PBKDF2 digest of the stored value, several times per
apply. The platform now derives it on the thread pool, so other requests
are served meanwhile; the CLI keeps the synchronous form, and both
produce the same digest.
PROJECT_AGENT_ID_TAKEN is answered only when a managed declaration
creates an agent under the id it chooses; a REST create never names an
agent's id, so the REST error-code registry lists it as app-only.
A managed project's declaration that restated the teams a project already has called the audience's writer, which asks for an owner or admin before it notices nothing changes. An editor allowed to rename the project was refused the rename. The audience's writer now runs only when the teams differ, in order, since the first team owns the project.
The platform matches a task's labels without regard to case and keeps the catalog's spelling, but a declared task compared its labels exactly. A task naming `Bug` on a project whose label is `bug`, or `release` beside a declared `Release` label, planned an update on every run and failed its readback after the write. A task now wears a label by its case-folded name, in its declaration and in the platform's readback (`foldedLabels`); the spelling stays with `project-label`.
A declared secret's readback digest verifies its value: whoever holds it, or a plan's or receipt's hashes over it, can test guesses offline. It is derived with 600,000 PBKDF2-SHA-256 iterations, OWASP's recommendation for it, instead of 100,000; the platform derives it from the stored value on every read, so the change reads every declared secret as changed once and the next apply rewrites it. `tale config platform read` shows `valueMatches` instead of printing the digest.
Inside a project, agent or task the same declaration creates, planning read every resource as absent and planned it as created, whether or not its kind can create itself. A label or agent declared without createIfMissing, the model of an agent nothing declares or the description of an undeclared task planned as `create`; apply then wrote the project and stopped at the resource it could not adopt, half-applied. Planning now admits there only what can be written: a resource that creates itself, a project's instructions, and the model, instructions, tools, description or review context of an agent or task the declaration creates. It refuses anything else, and a task in a new project assigned to an agent nothing creates there, before anything is written.
A connector credential the declaration creates was only validated by its write, after the projects, labels and agent secrets before it were written. A connector Tale lacks, a sign-in method or endpoint the connector does not take, or a connector whose per-credential settings are required (an IMAP/SMTP mailbox, HTTP) failed the apply half-way. Plan now asks `POST /api/app/connector-credentials/configuration/check`, without the values, and the CLI refuses the plan naming the field and code. A declaration carries no per-credential settings, so those connectors are connected in Tale, and the SMTP login fields, which only a mailbox takes, are no longer declarable.
The CLI README and the EN/DE/FR CLI install pages now say what planning refuses before anything is written (a resource that only adopts inside a project, agent or task the declaration creates; a task there assigned to an agent nothing creates; a credential its connector would refuse, a connector needing per-credential settings included), that a task's labels read case-folded, that `read` shows `valueMatches` and plans and receipts of secret resources carry a value verifier to treat as sensitive, and that declaring or rotating a secret needs a full deployment, since the backend reads its value from its environment. The manual automation and error-code references record the same.
@yannickmonney
yannickmonney marked this pull request as ready for review October 15, 2026 13:39
@yannickmonney
yannickmonney force-pushed the feat/managed-projects-agents branch from 8c5fec7 to 8b96c92 Compare October 15, 2026 13:39
@yannickmonney
yannickmonney merged commit 5ddb7e1 into main Oct 15, 2026
@yannickmonney
yannickmonney deleted the feat/managed-projects-agents branch October 15, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant