Skip to content

feat(cloud): admit imports against published limits - #292

Open
Artexis10 wants to merge 15 commits into
mainfrom
feat/cloud-import-admission
Open

Artexis10 wants to merge 15 commits into
mainfrom
feat/cloud-import-admission

Conversation

@Artexis10

@Artexis10 Artexis10 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Cloud import admission and Home now use the import limits that each cell publishes in C5. An import that cannot succeed is refused before the owner encrypts and uploads it, and an import that needs more storage grows the vault within the published cap first.

Why

Without published limits, Home and the import API accept a selection that the cell later refuses, after the owner has spent the time to encrypt and upload it. A vault whose storage is too small has no way to grow for an import without an operator.

What changed

  • Import creation checks the declared files and bytes against the cell's published limits in its existing transaction. It refuses with IMPORT_TOO_MANY_FILES or IMPORT_STORAGE_LIMIT, and prepare-upload refuses with IMPORT_PARTS_LIMIT. Each refusal carries a typed limit.
  • When an import needs more storage, creation raises the cell's desired storage within the cap and records the requirement on the import. The cap is the larger of the published cap and the current size. The capacity overhead ratio applies only when the usage reading is at least as recent as the capacity reading, so a reading from before an earlier growth cannot inflate growth that cannot be undone. Home shows the wait for growth and the published bound on that wait.
  • The import replies carry the limits, the vault's storage readings, the growth state and the staged counts from the import Job's report.
  • Home's preflight shows the archive's entries and the growth estimate against the published limits. It refuses a selection that has too many entries, cannot fit within the cap, or whose encrypted copy exceeds the upload ceiling. It warns about free space only when growth cannot cover the need, and says when the limits are not published or could not be read. It shows the staged size from the Job's report, and "not recorded" for older imports.
  • Browser uploads keep a receipt for each confirmed part, keyed by import and ciphertext digest, so a reload resumes at the next part.
  • Unpublished limits keep the earlier admission and leave both storage sizes unchanged.

The earlier adopted-count work is removed. Home already reads each import's filing through the cell's public inspect_memory imports.status, which reports the filed counts, and a cell refuses the private tool that work used. The OpenSpec change marks its tasks 5.1 and 5.2 as superseded.

Proof

  • The unit suite passes, including the Home component tests for the preflight, the refusals, the growth wait and the staged size.
  • The PostgreSQL integration suites for imports, the Home channel and the grants pass: growth with rollback and replay, each refusal, unpublished limits and the staged counts.
  • Typecheck, lint, Prettier on the changed files and the strict OpenSpec gate pass.
  • The Home admission journey passes in CI against the production build and a migrated PostgreSQL, on desktop and phone: growth before encryption, and a reload that sends only unrecorded parts.
  • A rendered pass of the dialog covered the preflight with growth, growth stopped at the cap, both preflight refusals, unpublished limits, the growth wait after starting, the Home row after a reload, and an import with no staged count. It ran at 1440 and 390 wide, light and dark: every state rendered, with no console errors and no failed requests.

Rollout

Merge only after the paired controller change completes its real-volume rehearsal. Then roll out in the order that the OpenSpec change's task 6.2 names. The C5 migration and grants are already on main.

Risk and undo

Growth on demand can raise any vault's storage up to the published cap. To undo, set the cell's import_limits to NULL, which returns admission to the earlier behaviour, and roll the deployment back. Grown volumes stay grown.

Weight: product +716/-94, proof +1007/-92, across 30 files. The proof includes the OpenSpec change text.

The browser writes one TAR member per selected file. Count these entries so that implicit folders do not reject imports at the limit.
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Quality report

3757068d against base 325c7a6. Only the gate fails this check; the rest informs review. Why each check exists: PRACTICES.md.

Gate: passed

Nothing found by knip.

Proof weight

Product +735 lines against proof +1037 lines (tests, specs).
Proof that outweighs the product it covers needs a reason in review.

Measures on added lines

Check Result
New duplicate code, exact token clones (jscpd) 10 on added lines

New duplicate code, exact token clones (jscpd)

e2e/exomem-home/import.spec.ts:431: Duplicates exomem-home/import.spec.ts:55
src/app/exomem/home/__tests__/home-import.test.tsx:420: Duplicated code block (62 tokens), duplicated at [app/exomem/home/__tests__/home-import.test.tsx:433](0)
src/app/exomem/home/__tests__/home-import.test.tsx:433: Duplicates app/exomem/home/__tests__/home-import.test.tsx:420
src/app/exomem/home/__tests__/home-import.test.tsx:539: Duplicated code block (113 tokens), duplicated at [app/exomem/home/__tests__/home-import.test.tsx:571](0)
src/app/exomem/home/__tests__/home-import.test.tsx:571: Duplicates app/exomem/home/__tests__/home-import.test.tsx:539
src/lib/exomem-hosted/__tests__/cloud-import-browser-file.test.ts:23: Duplicated code block (53 tokens), duplicated at [lib/exomem-hosted/__tests__/cloud-import-browser-file.test.ts:46](0)
src/lib/exomem-hosted/__tests__/cloud-import-browser-upload.test.ts:91: Duplicated code block (87 tokens), duplicated at [lib/exomem-hosted/__tests__/cloud-import-browser-upload.test.ts:119](0)
src/lib/exomem-hosted/__tests__/cloud-import-browser-upload.test.ts:119: Duplicates lib/exomem-hosted/__tests__/cloud-import-browser-upload.test.ts:91
src/lib/exomem-hosted/__tests__/cloud-import-browser-upload.test.ts:91: Duplicated code block (55 tokens), duplicated at [lib/exomem-hosted/__tests__/cloud-import-browser-upload.test.ts:231](0)
src/lib/exomem-hosted/__tests__/cloud-import-browser.test.ts:145: Duplicates lib/exomem-hosted/__tests__/cloud-import-browser.test.ts:90

Test runtime

This run against the median of the last 5 successful main runs of this workflow on the same runner, from the GitHub Actions API.

Job This run Median on main Change
test 4m 58s 5m 06s (5 runs) -3%
onboarding end-to-end 10m 35s 11m 42s (5 runs) -10%

Every table: this run's summary.

@Artexis10

Copy link
Copy Markdown
Contributor Author

Automated review: APPROVE
Head: 6cc5605
Patch: d23e2c224f1505bebd5a0d752f16e02d787561ef
Reviewer: reviewer, gpt-6.1-sol, xhigh
Blocking by round: 1, 0
Net call: hold for the member-count correction.

The correction clears the only blocking finding. Ship the reviewed implementation after the controller and image rollout and the real-volume rehearsal pass.

The independent whole-batch review covered admission, ownership, transaction rollback and replay, storage readings, upload receipts, cancellation, and Home states. The correction recheck covered all four changed files.

Original finding, now resolved:

P2 - False member-limit refusal - cloud-import-browser.ts:106. The forecast counts parent directories that the TAR writer never emits. With max_members=1, one nested file forecasts two members and Home blocks a valid import. Real encryption/decryption confirmed one archive entry. Count the entries actually written and correct the Home test that expects this refusal.

The writer now reports only the file entries it emits. The revised Home case admits a nested file at the published member limit. Independent real encryption and decryption measured one forecast member and one archive member, with no refusal. The ciphertext forecast and actual size both remained 2,248 bytes.

Independent validation at this head: 19 tests passed using node --import tsx --experimental-test-module-mocks --test --test-concurrency=1 on src/app/exomem/home/tests/home-import.test.tsx and src/lib/exomem-hosted/tests/cloud-import-browser.test.ts. The initial review also ran 43 scoped checks successfully. git diff --check passed.

C4: absent. C6: the added schemas, units and stop codes implement the closed import protocol; the SHA expression checks format. Their reasons are present. No unresolved unsound mechanism was found.

Weight against the PR base, from git diff --numstat: 28 files.

Scope Added Deleted
Product 599 84
Proof 851 32

Proof outweighs product because it covers PostgreSQL growth, rollback and replay, browser reload receipts, and rendered workflow states.

I did not independently rerun PostgreSQL or live Chrome; I inspected the supplied integration and DevTools evidence. Current-head CI and the controller/image rollout and real-volume rehearsal remain delivery dependencies. Local publication and growth remain deferred under the separate capacity-accounting gate.

Blocking: 0
Verdict: APPROVE

@Artexis10

Copy link
Copy Markdown
Contributor Author

Automated review: APPROVE
Head: 27b6e1a
Patch: 3de3ced0c8f6879852964bc49584405fceecc314
Reviewer: reviewer, gpt-6.1-sol, xhigh
Blocking by round: 1, 0, 0
Net call: hold for the member-count correction.

Current call: ship the combined admission, resumable-upload and filing-count implementation after the existing rollout dependencies pass. No blocking findings remain.

This record extends the prior P4/P5 review to all 11 files in the P7 delta and their combined contracts. The server reads the owned import before requesting its scoped filing count. The path comes from the stored import ID. The existing Home channel retains the session's reviewer credential and tenant binding. Bearer status does not acquire a Home principal.

Only a complete reply with a nonnegative safe integer becomes a Filed count. Unavailable, older, incomplete, malformed or refused replies leave the count unknown. Home keeps Filed distinct from staged and selected totals. The supplied real MCP-to-Home proof checks distinct original paths across overlapping runs, and DevTools evidence covers complete and unknown states at desktop and phone widths in both themes.

Original finding, now resolved:

P2 - False member-limit refusal - cloud-import-browser.ts:106. The forecast counts parent directories that the TAR writer never emits. With max_members=1, one nested file forecasts two members and Home blocks a valid import. Real encryption/decryption confirmed one archive entry. Count the entries actually written and correct the Home test that expects this refusal.

The prior correction removed the implicit parent count. Independent encryption and decryption then measured one forecast member and one archive member, with no refusal. The ciphertext forecast and actual size both remained 2,248 bytes. The revised Home test admits that nested file at the published member limit.

Earlier independent runtime checks passed 43 scoped tests and 19 correction checks. The P7 review reused the supplied isolated PostgreSQL, real MCP-to-Home and DevTools evidence; it did not repeat those runtime checks. The current combined diff passes git diff --check. CI on this exact head remains a delivery dependency.

C4: absent. C6: added schemas, units and stop codes implement the closed import protocol; SHA expressions check format. P7 uses structured output validation and the existing server-selected staging path. No unresolved unsound mechanism was found.

Weight against the PR base, from git diff --numstat: 32 files.

Scope Added Deleted
Product 684 90
Proof 1028 36

Proof outweighs product because it covers transactional growth, replay and rollback, durable reload receipts, owner isolation, reviewer credential lineage and truthful count states.

The controller and image rollout and the real-volume rehearsal remain explicitly open deployment dependencies. This review does not authorize rollout. Local publication and growth remain deferred under the separate capacity-accounting gate.

Blocking: 0
Verdict: APPROVE

…ission-rebase

# Conflicts:
#	src/app/exomem/home/__tests__/home-import.test.tsx
#	src/app/exomem/home/home-import-panels.tsx
#	src/app/exomem/home/home-import.tsx
#	src/lib/exomem-hosted/__tests__/cloud-import-browser-file.test.ts
#	src/lib/exomem-hosted/cloud-import-browser-api.ts
#	src/lib/exomem-hosted/cloud-import-browser-file.ts
#	src/lib/exomem-hosted/cloud-import-browser.ts
#	src/lib/exomem-hosted/cloud-import-selection.ts
#	src/lib/exomem/theme-script.generated.ts
…he Home preflight

Use the capacity ratio only when the usage reading is at least as recent as the
capacity reading, never below 1, and clamp against the larger of the published
cap and the current size. Home warns about free space only when growth cannot
cover the need, refuses an encrypted copy above the multipart ceiling, needs the
growth deadline only for the wait text, and says when limits could not be read.
The staged size modifies the existing staged-originals requirement; hidden items
stay out of the selection.
…l writes

The closed dialog keeps reading an import that waits for growth, a paused or
stopped upload outranks the growth wait on the row, and the upload loop reads
less often while storage grows. storage_ready holds once observed capacity
covers the requirement. Admission writes the cell only for real growth, an
owner with no import gets an empty reply instead of 404, the receipt goes
before its ciphertext, and stop reasons live in one table. New dialog text
is labelled rows and one-line states.
…on one line

The preflight shows the selected files against the published maximum less the
series file's entry. The growth row keeps a size and its unit together. The
change text gives the real reason for skipping no-op growth writes, and the
rendered pass ticks task 3.2.
@Artexis10

Copy link
Copy Markdown
Contributor Author

Automated review: APPROVE
Head: 1e5a122
Base: 325c7a6
Patch: 2372f51cf27c304cf9a11d7df00f90d4b4402200
Reviewer: lane-reviewer, claude-opus-5-5, effort not reported to the lane
Blocking by round: 4, 0
Net call: hold
Risk lens: yes
Pass: 61bf118c874fa8b5

Current call: ship 1e5a122 once the separate risk-lens pass approves. CI on this head passed every job, including the Home end-to-end journey. All four round-1 blocking findings are fixed and checked at this head, and what remains is wording and small refactors. Risk lens: admission writes billed volume growth that cannot be undone, sized from a client-declared byte count.

Weight against the PR base: product +716/-94, proof +1007/-92 (tests and e2e +902/-8, OpenSpec +105/-84).

Round-1 blocking findings, now resolved:

  1. The generated theme prepaint script was stale after hosted-browser.ts gained fetcher, so npm run build failed and the new e2e never ran. Fixed in 0c62dfe. The check passes at this head.
  2. While the page's own upload waited for growth, the dialog hid its progress and said nothing about the wait. Fixed at home-import.tsx:914-934. A component test and the e2e cover it.
  3. With the dialog closed, the Home row stopped reading after one read and kept saying "growing" after growth ended, and it hid a paused or stopped upload. Fixed at home-import.tsx:346 and :808-822. A reviewer check at this head confirmed both: one 15 s read moved the row on, and pausing shows "Upload paused".
  4. The new dialog states had no rendered pass. A separate QA pass on 459ab66 covered seven states plus the row, at 1440 and 390 wide, light and dark, with no console errors and no failed requests. Its two text-only follow-ups are in 1e5a122 and have not been rendered again.

Also fixed from round 1: no cell write when no growth is needed (cloud-imports.ts:350-355); storage_ready is display only and survives unrelated generation bumps (cloud-imports.ts:191-199); status without an ID keeps {import: null} (cloud-imports.ts:251); the estimate shows the age of its reading, and the refusal says "Space needed to unpack"; one importStopText lookup; the receipt is removed before its ciphertext; task 6.4 names its owner; the entitlement risks are recorded in the design; limits() parses the schema directly.

Non-blocking:

  • home-import.tsx:189: the pause line is still an explanatory sentence (operator's call).
  • home-import-panels.tsx:103: derive the series-file - 1 from forecast.members - forecast.files.
  • The preflight says "Files" and the server refusal (home-import.tsx:958) says "Archive entries". Use one name.
  • design.md:135 (D8) still says Home shows the member count against max_members.
  • home-import.tsx:899-910 and :921-932 repeat the "Growth time limit" block.

C4: absent. C6: the added schemas, units, stop codes and poll intervals implement the closed import protocol, each with a reason. Scale: the growth wait polls every 15 s, and no N+1 query or unbounded query was added. The open-first status sort is old debt.

@Artexis10

Copy link
Copy Markdown
Contributor Author

Automated review: APPROVE
Head: 1e5a122
Base: 325c7a6
Patch: 2372f51cf27c304cf9a11d7df00f90d4b4402200
Reviewer: lane-reviewer, Claude Opus 5.5, effort not stated to the lane
Blocking by round: 0
Net call: Ship
Risk lens: yes
Pass: c1e58ab00b26e80e

Ship. Admission, growth within the cap, replay before checks, rollback on an open-slot conflict, the typed refusals, the unpublished-limits path, owner scoping and the part-receipt resume are correct. Tests cover them at the PostgreSQL, browser and Home boundaries.

Weight: product +716/-94; proof +1007/-92 (tests +902/-8, OpenSpec +105/-84). The change grows storage irreversibly and spends money, which justifies the proof; jscpd flags five duplicated test setup blocks.

C4: absent. C6: no unsound mechanism; the digest regex, the new STOPS codes and the C5 key schemas each carry a reason line. Scale: no defect in the change; old debt: the status query sorts every import of the cell by an expression to pick one row.

Non-blocking findings:

  1. home-import.tsx:951 and cloud-import-stop.ts:60-66: a server IMPORT_TOO_MANY_FILES or IMPORT_STORAGE_LIMIT stop shows "Choose fewer files." and then "Choose the files again to continue."; give these codes their own step text.
  2. cloud-import-contract.ts:55: the capacity-to-filesystem ratio has no ceiling, so a usage stamp taken at write time instead of measurement time could size irreversible growth far above the need; state in C5 that usage_observed_at is the measurement time.
  3. cloud-imports.ts:183: limits() hides valid part keys and the growth deadline when one admission key is invalid; return any JSON object, and let each reader parse its own keys.
  4. cloud-import-browser.ts:272: a failed receipt write, such as a quota error, stops the upload at the same part on every resume; catch it and continue with the in-memory map.
  5. cloud-imports.ts:191-199: storage_ready is false when no capacity reading exists, so Home says storage is growing; return null (unknown) instead.
  6. home-import.tsx:898-931: the "Growth time limit" block appears twice, and its label does not say that the limit counts from the upload's start.
  7. cloud-imports.ts: the cell column list is written twice by hand, two columns are read and never used, and the growth UPDATE uses RETURNING *; use one shared column fragment.
  8. The integration tests have no case for published limits with grown storage above desired storage, where admission must skip the cell write; add it before the local cutover.
  9. Design: growth comes from a declared size, before any upload, with no entitlement limit. The design defers this decision, and the cap bounds the cost per cell; keep that decision tracked.
  10. cloud-imports.ts:381: a prepare-upload in the wrong state with an oversize report gets 422 instead of 409.
  11. theme-script.generated.ts is unrelated regenerated output; its check passes.
  12. Task 3.2's claim of Chrome checks at desktop and phone widths in both themes has no evidence in the diff, so it stays unverified.

A part receipt the browser cannot write no longer stops the upload. Limit
refusals name their next step once, show files against the limit in the same
terms as the preflight, and the series entry count lives beside the archive
builder. The growth limit is one component that says it counts from the
upload's start. The reply passes published limits whole for each reader to
check, the growth write returns only the cell columns it reads, and C5
timestamps are measurement times.
@Artexis10

Copy link
Copy Markdown
Contributor Author

Automated review: APPROVE
Head: 7236b6f
Base: 325c7a6
Patch: 447ae028ab53059a98ce780d9d1dc7c4b7b7bc45
Reviewer: lane-reviewer, Claude Opus 5.5, effort not stated to the lane
Blocking by round: 0, 0
Net call: Ship
Risk lens: yes
Pass: c1e58ab00b26e80e

Ship. This recheck covers only the follow-up commit against the first round's findings. Findings 1, 2, 3, 4 and 6 are fixed, and the receipt and refusal fixes each have a test that fails if the fix is reverted. Finding 5 is withdrawn: cellctl holds the key until a capacity reading covers the requirement, so the import really does wait.

Weight of the follow-up: product +44/-29, proof +32/-2.

Status of the earlier findings:

  1. Fixed: home-import.tsx:951-952. The fix depends on the refusal carrying a parsable limit; a refusal without one would show both next steps again.
  2. Fixed: the tenant spec requires C5 timestamps to be measurement times. The paired controller check stays with the rollout.
  3. Fixed: cloud-imports.ts:182-186 returns any published JSON object.
  4. Fixed: cloud-import-browser.ts:272-277. The next receipt rewrite restores a part whose receipt write failed.
  5. Withdrawn.
  6. Fixed: the GrowthLimit component, home-import.tsx:122-132.
  7. Not fixed, non-blocking: RETURNING * is gone, but cloud-imports.ts now writes the same cell column list out by hand three times, and two of those columns are read and never used.
    8, 9, 10, 11: Not fixed, as agreed: deferred or harmless.
  8. Fixed for 459ab66: a rendered pass covers seven states at both widths and in both themes. The later label changes have component tests only.

New in this commit, non-blocking: cloud-import-envelope.ts:67-73 puts SERIES_ENTRIES between importArchive's doc comment and the function, which detaches that comment. Move the constant above the comment.

@Artexis10

Copy link
Copy Markdown
Contributor Author

Automated review: APPROVE
Head: 1135681
Base: 325c7a6
Patch: 39ed57f8e5e778080e260127ad1c5cdfc71c6f21
Reviewer: lane-reviewer, Claude Opus 5.5, effort not stated to the lane
Blocking by round: 0, 0, 0
Net call: Ship
Risk lens: yes
Pass: c1e58ab00b26e80e

Ship. This recheck covers only 7236b6f..1135681, and the diff is sound.

Weight of the follow-up: product +9/-6, proof +1/-1.

  • home-import.tsx:951-955: a refusal's next step now depends on its code, not on whether its limit parsed, so the earlier gap is closed. The two codes are closed protocol codes, and the comment above the line gives the reason. The refusal test still fails if the duplicate next step comes back.
  • cloud-import-envelope.ts:67-68: SERIES_ENTRIES now sits above importArchive's doc comment, which fixes the detached comment.
  • cloud-import-contract.ts:8: admissionLimits is no longer exported, and its only user is inside the module.
  • home-import.tsx:205: the pause line is back to main's wording. A receipt write may now fail without stopping the upload, so this wording stays true where "including after a reload" might not.

Non-blocking: Home's list of codes whose STOPS text already names the next step lives apart from the STOPS table. A flag on each STOPS entry would keep both in one place.

@Artexis10

Copy link
Copy Markdown
Contributor Author

Automated review: APPROVE
Head: 1135681
Base: 325c7a6
Patch: 39ed57f8e5e778080e260127ad1c5cdfc71c6f21
Reviewer: lane-reviewer, claude-opus-5-5, effort not reported to the lane
Blocking by round: 4, 0, 1, 0
Net call: hold
Risk lens: yes
Pass: 61bf118c874fa8b5

Current call: ship 1135681 once the separate risk-lens pass approves. Every blocking finding from all four rounds is fixed and was checked at this head, and CI passes every check. Risk lens: admission writes billed volume growth that cannot be undone, sized from a client-declared byte count.

Weight against the PR base: product +735/-95, proof +1037/-92 (tests and e2e +932/-8, OpenSpec +105/-84).

Blocking findings, all resolved:

Round 1 (4):

  1. The generated theme prepaint script was stale, so the build failed. Fixed in 0c62dfe.
  2. The dialog said nothing while the page's own upload waited for growth. Fixed, with a component test and the e2e.
  3. With the dialog closed, the Home row froze on "growing" and hid a paused or stopped upload. Fixed: the row keeps reading during a growth wait, and paused or stopped states come first.
  4. The new dialog states had no rendered pass. A separate QA pass covered them at desktop and phone widths, in light and dark.

Round 3 (1):

  1. admissionLimits stayed exported after its only importer was removed, so the knip quality gate failed. Fixed: it is module-private, and quality passes.

Round 4 also moved SERIES_ENTRIES above importArchive's doc comment, decides the refusal's next step from the stop code, and restores main's pause line, which stays true when a receipt write fails.

Non-blocking debt: the growth UPDATE's RETURNING list repeats lockCell's column list in cloud-imports.ts. Share one list when either changes.

C4: absent. C6: the added schemas, units, stop codes, poll intervals and code branches implement the closed import protocol, each with a reason. Scale: the growth wait polls every 15 s, and no N+1 query or unbounded query was added. The open-first status sort is old debt.

This branch has not been deployed

No deployments
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