feat: owner review 2 phase 5a: workspace and projects with a local home (#14)
CI / Build and test (push) Successful in 9m43s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 27s
CI / PostgreSQL 16 integration (push) Failing after 8m41s
CI / PostgreSQL 17 integration (push) Successful in 12m37s
CI / Docker image (push) Successful in 56s
Release / Build, test and publish (push) Successful in 14m59s
Release / Server image (push) Successful in 1m51s

Edit opens a sequence as a project of a workspace folder outside the library. Projects have linear version histories kept as sidecars in .chronos/projects/, Main mirrors the sequence's settings, and sync merges setting by setting. Migration 0009, JobKind.WorkspaceCopy = 20, Settings › Workspace, and 241 new strings in 38 languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #14.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-11-04 09:22:08 +01:00
1 parent efa87f68ce
commit 9b24cf74fc
370 files changed
+29237 -287

No files matched your search

+31 -2
View File
@@ -136,8 +136,29 @@ public sealed class JobEngine : IAsyncDisposable
/// </summary>
public bool CanRun(JobKind kind) => _handlers.ContainsKey(kind) && (Options.Kinds is null || Options.Kinds.Contains(kind));
/// <summary>Cancels a queued or running job; a running handler observes its token.</summary>
public Task CancelAsync(Guid id, CancellationToken cancellationToken = default) => TransitionAsync(id, JobState.Cancelled, cancellationToken);
/// <summary>
/// Cancels a queued or running job; a running handler observes its token. A paused or failed one, which no handler runs,
/// leaves what it wrote to its handler to clear (<see cref="ICancelledJobHandler"/>), once a handler of this engine that
/// was still stopping it (paused a moment ago: what it cleared itself was for a pause) has let go.
/// </summary>
public async Task CancelAsync(Guid id, CancellationToken cancellationToken = default)
{
var before = await _db.Jobs.GetAsync(id, cancellationToken).ConfigureAwait(false);
await TransitionAsync(id, JobState.Cancelled, cancellationToken).ConfigureAwait(false);
// Neither claimable nor running here: no handler cleans up after it itself.
if (before is not { State: JobState.Paused or JobState.Failed } || !_handlers.TryGetValue(before.Kind, out var handler)
|| handler is not ICancelledJobHandler cancelled)
return;
if (_running.TryGetValue(id, out var stopping)) await stopping.Ended.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
await cancelled.CancelledAsync(before with { State = JobState.Cancelled }, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex) when (!(ex is OperationCanceledException && cancellationToken.IsCancellationRequested))
{
Log.Warning("jobs", $"{before.Kind} job {id} was cancelled, but what it left could not be cleared", ex);
}
}
/// <summary>Pauses a job: a running one stops at its next check and keeps its checkpoint, and the next queued job starts.</summary>
public Task PauseAsync(Guid id, CancellationToken cancellationToken = default) => TransitionAsync(id, JobState.Paused, cancellationToken);
@@ -468,6 +489,7 @@ public sealed class JobEngine : IAsyncDisposable
if (yieldsTo is not null) context.Log(Loc.L("Jobs.Line.Yielded", Loc.L("Jobs.Kind." + yieldsTo.Kind)));
await PersistAsync(context).ConfigureAwait(false);
_running.TryRemove(job.Id, out _);
run.End();
// Engine stopping: leave the job running so the next start requeues it from its checkpoint.
if (shutdown.IsCancellationRequested) return;
// Yielded to a higher job: back to the queue with its checkpoint, unless the user paused or cancelled it
@@ -487,6 +509,7 @@ public sealed class JobEngine : IAsyncDisposable
finally
{
_running.TryRemove(job.Id, out _);
run.End();
}
await _db.Jobs.SetStateAsync(job.Id, final, error, CancellationToken.None).ConfigureAwait(false);
await NotifyAsync(job.Id, CancellationToken.None).ConfigureAwait(false);
@@ -496,9 +519,15 @@ public sealed class JobEngine : IAsyncDisposable
private sealed class RunningJob(Job job, CancellationTokenSource cancellation)
{
private Job? _yieldsTo;
private readonly TaskCompletionSource _ended = new(TaskCreationOptions.RunContinuationsAsynchronously);
public Job Job { get; } = job;
/// <summary>Completes once the handler has returned and the job left the engine's running jobs.</summary>
public Task Ended => _ended.Task;
public void End() => _ended.TrySetResult();
/// <summary>Jobs this one queued as follow-ups (<see cref="EnqueueFollowUpAsync"/>): they never make it yield.</summary>
public ConcurrentDictionary<Guid, byte> FollowUps { get; } = new();