Skip to content

Bound Apple container identifiers to 64 characters - #1237

Merged
penso merged 5 commits into
mainfrom
fix/apple-container-name-limit
Aug 24, 2026
Merged

Bound Apple container identifiers to 64 characters#1237
penso merged 5 commits into
mainfrom
fix/apple-container-name-limit

Conversation

@penso

@penso penso commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fix Apple Container sandbox startup failures when identity-scoped prefixes plus session UUIDs exceed the 64-character identifier limit.
  • Generate stable Apple-only names with SHA-256 suffixes, reserve room for stale-container generation suffixes, and keep startup/per-session cleanup discoverable.
  • Report the actual active container name through sandbox and failover backends without changing Docker container naming.
flowchart LR
    A[Instance prefix + session key] --> B[Normalize components]
    B --> C[Bound prefix and key with stable digest]
    C --> D[Reserve generation suffix]
    D --> E[Apple container ID at most 64 chars]
    E --> F[Create, report, and clean same ID]
Loading

Closes #1137

Validation

Completed

  • cargo test -p moltis-tools container_name
  • cargo test -p moltis-tools apple_container_names_fit_runtime_limit
  • cargo check -p moltis-chat
  • just release-preflight
  • ./scripts/local-validate.sh 1237

Remaining

  • Live Apple Container smoke test on a machine with sandbox execution configured.

Manual QA

  1. Configure tools.exec.sandbox.backend = "apple-container" with the default Moltis identity.
  2. Start a new chat session and execute a sandboxed command.
  3. Confirm the Apple container starts and its logged identifier is no longer than 64 characters.
  4. Trigger session cleanup and confirm the generated container is removed.

Default identity-scoped sandbox names plus session UUIDs exceed Apple Container's 64-character identifier limit, and stale-name generation suffixes can make them longer still.

Generate deterministic bounded Apple-only names with hashed components, reserve room for generation suffixes, keep cleanup discovery aligned, and expose the active runtime name for diagnostics without changing Docker naming.
@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR bounds Apple Container identifiers to 64 characters while preserving stable naming, stale-container generations, management discovery, and backend-aware diagnostics.

  • Adds normalized, digest-suffixed Apple container names with reserved generation space.
  • Aligns listing, cleanup, web, and Swift management with compact Apple prefixes.
  • Reports backend and runtime container names from the same resolved sandbox backend.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/tools/src/sandbox/container_name.rs Defines stable bounded Apple container names and delimiter-aware compact-prefix matching, including maximum-generation coverage.
crates/tools/src/sandbox/apple.rs Uses the bounded naming helper consistently for container creation, generation rotation, runtime reporting, and session cleanup.
crates/tools/src/sandbox/containers.rs Extends Apple container discovery and cleanup to recognize compact runtime prefixes while preserving Docker naming behavior.
crates/web/src/container_management.rs Accepts compact Apple runtime names during management authorization, resolving the previously reported rejection.
crates/swift-bridge/src/ffi_sandbox.rs Aligns Swift stop and remove authorization with compact Apple container naming.
crates/chat/src/service/chat_impl.rs Resolves backend metadata and runtime container name from one effective session backend, resolving the previously inconsistent response pair.
crates/tools/src/sandbox/router.rs Delegates runtime metadata through failover and session backend routing so backend names remain paired with their runtime resource names.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Configured prefix and session key] --> B[Normalize components]
    B --> C[Compact long values with stable digest]
    C --> D[Reserve generation suffix space]
    D --> E[Apple identifier at most 64 characters]
    E --> F[Create and report runtime container]
    E --> G[List, stop, remove, and clean by matching prefix]
Loading

Reviews (3): Last reviewed commit: "test(sandbox): cover management prefix f..." | Re-trigger Greptile

Comment thread crates/tools/src/sandbox/container_name.rs
Comment thread crates/chat/src/service/chat_impl.rs Outdated
@codspeed-hq

codspeed-hq Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 10.32%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 38 untouched benchmarks
⏩ 9 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
session_history_path[default] 6.2 µs 6.9 µs -10.32%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/apple-container-name-limit (d6130ea) with main (fc65e52)

Open in CodSpeed

Footnotes

  1. 9 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.04301% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/web/src/api.rs 0.00% 26 Missing ⚠️

📢 Thoughts on this report? Let us know!

penso added 3 commits August 23, 2026 23:36
Allow Web and Swift management authorization to recognize deterministic Apple prefixes, and resolve the session backend once so diagnostics pair its runtime name with the correct backend label.
The compact-prefix matcher is covered in the sandbox naming module; keeping the duplicate Web assertion pushed api.rs over the enforced 1,500-line limit.
Container management reloaded the raw configured prefix even though gateway startup replaces it with an identity-scoped runtime prefix, so generated Apple containers could not be listed or managed. Read the immutable router prefix in web and Swift paths, with an identity-derived fallback before the embedded gateway starts.\n\nFailover diagnostics also read runtime name and backend state separately. Capture both from one selected backend so chat.context cannot report a container from one backend with another backend's label.
@penso

penso commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile review

Exercise the configured-prefix fallback, duplicate-prefix branch, and identity-scoped gateway helper so the runtime management paths remain covered on Linux CI.
@penso

penso commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile review

@penso
penso merged commit 39dfef8 into main Aug 24, 2026
50 of 51 checks passed
@penso
penso deleted the fix/apple-container-name-limit branch August 24, 2026 18:41
SP-937-215 pushed a commit to SP-937-215/moltis that referenced this pull request Aug 25, 2026
Bring in moltis-org#1237 Apple container ID bounds and moltis-org#1243 cron channel context
while keeping fork-only xAI OAuth and audit remediations.
SP-937-215 pushed a commit to SP-937-215/moltis that referenced this pull request Aug 25, 2026
After merging moltis-org#1237, name length is handled by apple_container_name().
Drop the fork-only "ms" default to reduce drift from upstream.
SP-937-215 pushed a commit to SP-937-215/moltis that referenced this pull request Sep 3, 2026
After merging moltis-org#1237, name length is handled by apple_container_name().
Drop the fork-only "ms" default to reduce drift from upstream.
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]: Apple Container ID exceeds name limit

1 participant