fix(metering): a demo target given the tenant's own sources counts under the cap #1080

Merged
sharang merged 1 commits from fix/demo-target-claim into main 2026-11-29 09:56:18 +00:00
Owner

Closes the gap left by #1079: a demo target stayed outside the entry plan's cap even once it was pointed at the tenant's own code.

Rule

  • When a demo target's artifacts change to other sources, it becomes the tenant's own target. The demo mark goes, and from then on it counts under the cap. The ways artifacts change are PATCH /api/v1/targets/{id} with other artifacts, POST …/artifacts and POST …/artifacts/upload.
  • If the plan has no room, the change is refused: 409 {"error": "target_limit"}, and the target stays a demo target.
  • Changing only the name or the branch of the same sources keeps it a demo target. The editor sends every artifact on each save, so only a different kind or reference counts as a change.
  • An upload is checked before the file streams in. A demo target then becomes the tenant's own even when the file turns out unreadable.
  • An archived demo target is not checked against the cap when this happens, because it doesn't count until it's active again.

Dashboard (text only): the target editor's toast and the upload error say, in DE and EN, that a demo target with the tenant's own files or sources counts like the others and that the plan has no room. The 409 from the upload is read by its code.

Left as it is: renaming a demo target and seeding again adds one more demo target with demo content. That's harmless, because it sits outside the cap only while it holds demo content.

Tests

  • New in tests/target_limit.rs (live Mongo): a new name with the same sources stays a demo target; the tenant's own sources are refused while the places are full; with a place free, the target becomes the tenant's own and takes that place.
  • A unit test covers same_sources.
  • Dashboard test for the texts.
  • Agent and core 1665 pass, dashboard 238. Clippy is clean (agent, dashboard server and web), and so is fmt.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9

Closes the gap left by #1079: a demo target stayed outside the entry plan's cap even once it was pointed at the tenant's own code. **Rule** - When a demo target's artifacts change to other sources, it becomes the tenant's own target. The demo mark goes, and from then on it counts under the cap. The ways artifacts change are `PATCH /api/v1/targets/{id}` with other artifacts, `POST …/artifacts` and `POST …/artifacts/upload`. - If the plan has no room, the change is refused: 409 `{"error": "target_limit"}`, and the target stays a demo target. - Changing only the name or the branch of the same sources keeps it a demo target. The editor sends every artifact on each save, so only a different kind or reference counts as a change. - An upload is checked before the file streams in. A demo target then becomes the tenant's own even when the file turns out unreadable. - An archived demo target is not checked against the cap when this happens, because it doesn't count until it's active again. **Dashboard (text only):** the target editor's toast and the upload error say, in DE and EN, that a demo target with the tenant's own files or sources counts like the others and that the plan has no room. The 409 from the upload is read by its code. **Left as it is:** renaming a demo target and seeding again adds one more demo target with demo content. That's harmless, because it sits outside the cap only while it holds demo content. **Tests** - New in `tests/target_limit.rs` (live Mongo): a new name with the same sources stays a demo target; the tenant's own sources are refused while the places are full; with a place free, the target becomes the tenant's own and takes that place. - A unit test covers `same_sources`. - Dashboard test for the texts. - Agent and core 1665 pass, dashboard 238. Clippy is clean (agent, dashboard server and web), and so is fmt. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
sharang added 1 commit 2026-11-28 22:21:09 +00:00
fix(metering): a demo target given the tenant's own sources counts under the cap
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 5m1s
CI / Check (pull_request) Successful in 21m44s
aad3831e82
A demo target sat outside the entry plan's cap for good, even once it
was pointed at the tenant's own code. Now, when its artifacts change to
other sources (editor, attach, upload), it becomes the tenant's own
target: the demo mark goes and it counts. If the plan has no room, the
change is refused with 409 `target_limit` and it stays a demo target.
A new name or branch on the same sources changes nothing.

The dashboard says so in words in the target editor and the upload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
sharang merged commit dd46af6f24 into main 2026-11-29 09:56:18 +00:00
Sign in to join this conversation.