Skip to content

fix(deployments): scope sourceSize to the extracted tree, not the provider archive - #13614

Open
breken-ai wants to merge 1 commit into
appwrite:mainfrom
breken-ai:fix-13586-sourcesize-subdir-scope
Open

fix(deployments): scope sourceSize to the extracted tree, not the provider archive#13614
breken-ai wants to merge 1 commit into
appwrite:mainfrom
breken-ai:fix-13586-sourcesize-subdir-scope

Conversation

@breken-ai

Copy link
Copy Markdown

Fixes #13586.

Root cause (the reporter's, confirmed at HEAD)

@AlimFreight traced this; verified independently:

  1. Deployments.php (~:398-409): the VCS path downloads the whole-repo provider archive, and StatArtifact(id: 'sourceSize', in: 'source.tar.gz') records the entire archive - while the extracted tree is already scoped to rootDirectory via subdir + strip.
  2. Workers/Jobs.php:308-319: the worker writes that stat into sourceSize/totalSize.
  3. Workers/StatsResources.php:262/290/307: sum(sourceSize) becomes DEPLOYMENTS_STORAGE, with sourcePath NULL on VCS deployments so nothing corrects it - the reporter's ~525MB phantom across 94 functions.

Sharpening (confirmed): deployments reporting sourceSize all went through the archive path (the clone path reports none), and forge archives carry no .git - so this is whole-repo-archive vs subdirectory, not a .git effect. The reporter's numbers back it (4.33MB reported vs ~4.46MB whole-worktree estimate).

Fix (1 file, +11/-4)

Re-pack the extracted, rootDirectory-scoped tree into a plain tar and stat that instead:

  • ArchiveArtifact(id: 'sourceSizeArchive', in: 'source', out: 'source-size.tar', format: Tar, depends: 'extract')
  • StatArtifact(id: 'sourceSize', in: 'source-size.tar', depends: 'sourceSizeArchive')

Only existing orchestrator primitives are used - Stat.Apply rejects directories, Archive.Apply packs them (both verified in the orchestrator Go source), and ArchiveArtifact/ArchiveFormat::Tar exist in open-runtimes/sdk-for-php 0.13.0, which appwrite pins. Zero orchestrator or SDK changes.

Semantic change (disclosed)

sourceSize becomes uncompressed subdir bytes (+512B/file tar overhead) instead of compressed whole-repo bytes; existing rows keep inflated values until the next redeploy. Alternative for maintainers who prefer minimal blast radius: gate the three StatsResources.php sums on sourcePath IS NOT NULL - a one-liner that fixes accounting but leaves per-deployment display wrong, hence the artifact fix instead.

Verification

Every step re-traced in source at main (f31509d) plus the orchestrator (Go) and sdk-for-php 0.13.0 pinned ref. Not run: no PHP runtime or live Appwrite/orchestrator build in the author's environment - the reporter offered to verify storage totals after a redeploy.

Overlap note: this touches src/Appwrite/Deployment/Deployments.php (:395-409), about 200 lines from #13589's change (:182) in the same file; both apply independently against current main, but whichever lands second will need a trivial rebase.

Built by breken, your AI support engineer - breken.ai - this one's on us.

…vider archive

For git-source deployments the provider archive spans the whole repository,
so recording its byte size as sourceSize inflated every monorepo deployment
(and the storage totals that sum it) with the rest of the repo. Stat the
extracted tree instead - already scoped to rootDirectory with the forge
wrapper stripped. Stat rejects directories, so re-pack 'source' into a
plain tar via ArchiveArtifact first.

Fixes appwrite#13586
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The PR appears safe to merge, with a non-blocking need for observable regression coverage of root-directory-scoped accounting.

Fix All in Claude CodeFindings

  1. P2 Scoped accounting lacks coverage
Fix with agent prompt
### Issue 1
src/Appwrite/Deployment/Deployments.php:407
This accounting change has no observable regression test for a VCS deployment with `rootDirectory`. Existing coverage only checks that `sourceSize` is positive and contributes to `totalSize`, so it would still pass if this code reverted to measuring the whole provider archive. Add a deployment-level test showing that large files outside the selected root do not affect the reported source size or deployment-storage total, without asserting the artifact pipeline itself.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

  • Adds an intermediate plain-tar archive operation after source extraction.
  • Stats that scoped archive and preserves the existing sourceSize callback contract.
  • Needs observable regression coverage proving files outside rootDirectory do not affect accounting.

Reviews (1) · Last reviewed commit: "fix(deployments): scope sourceSize to th..."

// extracted tree instead, already scoped to rootDirectory with
// the forge wrapper stripped. Stat rejects directories, so
// re-pack 'source' into a plain tar first.
new ArchiveArtifact(id: 'sourceSizeArchive', in: 'source', out: 'source-size.tar', format: ArchiveFormat::Tar, depends: 'extract'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Scoped accounting lacks coverage

This accounting change has no observable regression test for a VCS deployment with rootDirectory. Existing coverage only checks that sourceSize is positive and contributes to totalSize, so it would still pass if this code reverted to measuring the whole provider archive. Add a deployment-level test showing that large files outside the selected root do not affect the reported source size or deployment-storage total, without asserting the artifact pipeline itself.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Deployment/Deployments.php
Line: 407

Comment:
**Scoped accounting lacks coverage**

This accounting change has no observable regression test for a VCS deployment with `rootDirectory`. Existing coverage only checks that `sourceSize` is positive and contributes to `totalSize`, so it would still pass if this code reverted to measuring the whole provider archive. Add a deployment-level test showing that large files outside the selected root do not affect the reported source size or deployment-storage total, without asserting the artifact pipeline itself.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

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.

🐛 Bug Report: VCS deployment sourceSize reports the whole cloned repo (.git included), inflating totalSize and deployments-storage metrics

2 participants