Skip to content

Add an asynchronous background job manager - #95

Merged
sodejm merged 1 commit into
mainfrom
feature/51-background-job-manager
Jul 22, 2026
Merged

Add an asynchronous background job manager#95
sodejm merged 1 commit into
mainfrom
feature/51-background-job-manager

Conversation

@sodejm

@sodejm sodejm commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a bounded worker-thread job manager with stable IDs and serializable lifecycle snapshots
  • track queued, running, completed, failed, and cancelled states with timestamps, results, and sanitized failures
  • serialize mutating operations by normalized target-resource keys while allowing independent targets to run concurrently
  • submit long REPL operations without blocking the prompt and add jobs list / jobs show JOB_ID
  • capture dispatcher DTOs for later job inspection without changing one-shot output
  • document the lifecycle and add queue, concurrency, failure, cancellation-state, and responsiveness tests

Verification

  • make test — 401 passed, 8 skipped
  • make lint — passed
  • make typecheck — passed
  • make security — dependency audit clean; Semgrep 1,102 rules / 64 files / 0 findings
  • git diff --check — passed

Fixes #51

- Run long REPL operations in a bounded worker pool with serializable lifecycle snapshots.\n- Serialize mutating jobs by target resource and capture sanitized results and failures.\n- Add REPL job inspection, documentation, and concurrency regression tests.\n\nFixes #51
@sodejm
sodejm merged commit e353af8 into main Jul 22, 2026
5 checks passed

@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: a91411cd64

ℹ️ 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 on lines +228 to +229
exit_code = dispatch(namespace, self.context, emit=capture)
return {"exit_code": exit_code, "output": output}

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 Mark nonzero sync jobs as failures

When gedcom sync runs in the background, dispatch() can return the sync workflow's nonzero exit code (for example when the sync parser or manifest validation returns an error) without raising. _dispatch_job then wraps that integer in a normal result, so JobManager records the job as completed with no stable error code and jobs list/show cannot distinguish a failed sync from a successful one; convert nonzero dispatch returns into a failed job snapshot instead.

AGENTS.md reference: AGENTS.md:L18-L19

Useful? React with 👍 / 👎.

locks = [self._resource_lock(key) for key in resource_keys]
try:
for lock in locks:
lock.acquire()

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 Keep resource-lock waiters out of the worker pool

Because worker threads call lock.acquire() before the job is marked running, jobs waiting on a busy resource consume executor workers. With max_workers=2, one long job for tree.ged and one same-resource waiter occupy both workers, so a later job for other.ged cannot start until the same-resource backlog advances; that violates the intended parallelism for independent targets. Gate per-resource waiters outside the worker pool or reschedule blocked jobs instead.

Useful? React with 👍 / 👎.

@sodejm
sodejm deleted the feature/51-background-job-manager branch July 24, 2026 01:15
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.

Add an asynchronous background job manager

1 participant