Skip to content

feat(custom-app): one-shot status detection (HLD §10 — Feature 4 close-out) - #149

Merged
omarsy merged 1 commit into
mainfrom
feat/oneshot-status
Oct 24, 2026
Merged

omarsy merged 1 commit into
mainfrom
feat/oneshot-status

Conversation

@omarsy

@omarsy omarsy commented Oct 24, 2026

Copy link
Copy Markdown
Member

Implements HLD §10 (merged as #288): the one-shot status mechanism, greffer half — the last Feature 4 slice's detection core.

What

  • get_status classification: a container at rest in exited with ExitCode == 0 under restart policy no/absent (compose's default) is completed — excluded from the aggregate like a label-ignored container, so an app plus a healthy migration helper reports running the moment the helper finishes. The policy is the discriminator the raw exit code cannot carry (graceful-stop images — the platform's own nginx sidecar — exit 0 on stop; always/unless-stopped resting = operator-suppressed restart, stays visible; on-failure deliberately not completed — catalog mains share that policy, labeled on-failure one-shots ride the label).
  • All-excluded aggregate is stopped: containers present but every one label/legacy/completed → stopped, never the undeliverable unknow (the monitor callback vocabulary can't deliver it; the cold-backup quiesce-wait would never see "stopped"). An EMPTY container set keeps today's documented unknow conflation.
  • Detail payload (additive): completed (service names via the com.docker.compose.service label — container names are never parsed) and exited ({name, exit_code} for every non-running non-ignored container; created carries no code; completed names appear here too, by design).
  • Carrier: new GET /api/controller/greffon/{id}/status/ (offloaded under the metrics limiter like the stats/disk family). The legacy bare GET /greffon/{id}/ keeps its exact response shape — pydantic drops the new keys (asserted in the route test).

Tests

The full §10 scenario matrix in OneShotStatusTests (healthy one-shot → running; failed → loud; on-failure rest → counted; suppressed-restart sidecar → counted; all-excluded → stopped; empty set → unknow; label-ignored in neither list; created without a code; attrs-less containers never complete), the failed-unlabeled case re-derived with realistic attrs, and the route test proving the carrier and the legacy shape both.

Suites: compose 46 OK, routes/heartbeat/backup-retention 93 OK, full 1135 passed with only the pre-existing oracle/catalog-pin artifact.

Not here

The manager half (the _relay proxy route) is the next PR; the user-marking stays deferred per §10 (trigger recorded).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T06:01:24.726602Z 0a657fc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a657fcb7f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/utils/docker/compose.py Outdated
Comment on lines +934 to +935
state = (getattr(container, 'attrs', None) or {}).get('State') or {}
return state.get('ExitCode')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Return no exit code for containers that have never run

For a newly created Docker container, State.ExitCode is initialized to 0 even though the container has never run. Returning that field directly therefore exposes {"name": "worker", "exit_code": 0} through the new status endpoint, incorrectly presenting a pending service as having exited successfully instead of returning the promised null. Check for the created state before reading the exit code, and exercise that case with realistic Docker attrs; the added test currently supplies None itself and consequently misses this behavior.

Useful? React with 👍 / 👎.

…e-out)

get_status classifies a container at rest in exited with code 0 under
restart policy no/absent (compose default) as completed and excludes
it from the aggregate — an app plus a healthy migration helper reports
running. The policy is the discriminator the raw exit code cannot
carry: graceful-stop images (the platform's own nginx sidecar) exit 0
on docker stop, and a manual stop SUPPRESSES always/unless-stopped —
those rest visibly, as does on-failure (catalog mains share it).
The all-excluded aggregate is stopped (never the undeliverable
unknow the callback vocabulary rejects and the cold-backup
quiesce-wait treats as never-stopped — the review traced this
strictly improving three backup paths); an empty container set keeps
the documented unknow conflation. Detail payload: completed (service
names via the compose label) and exited ({name, exit_code} for every
non-running non-ignored container) — carried by a new
GET /greffon/{id}/status/ read; the legacy bare GET keeps its exact
shape (pydantic drops the new keys).

Review folds:
- adversarial P2 (live-daemon probed): the daemon reports ExitCode 0
  for never-run created containers and for paused ones (the process
  is alive) — _exit_code now gates on State.Status == 'exited', and
  the fixtures are daemon-realistic (the old mock's ExitCode: None
  was a shape the daemon never produces, masking the leak).
- matrix gaps filled: migrate-named in neither detail list, label
  primary over the policy rule (labeled exited:0 policy-no → neither
  list), the always-policy row, and paused/created rows.
- The feared RestartPolicy-missing-from-list() concern was refuted
  with SDK source + live probe (non-sparse list() inspects every
  container) — the classifier is live in production.

Suites: compose 52 OK, full 1139 passed with only the pre-existing
oracle/catalog-pin artifact. Manager relay proxy next.
@omarsy
omarsy force-pushed the feat/oneshot-status branch from 0a657fc to f177631 Compare October 24, 2026 06:11
@omarsy
omarsy merged commit 661869a into main Oct 24, 2026
1 check failed
@omarsy
omarsy deleted the feat/oneshot-status branch October 24, 2026 06:11
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