feat(FN-675): align session-files endpoint with diff endpoint

- Add git diff for session-files using baseCommitSha with double-dot syntax
- Add merge-base fallback to find common ancestor when baseCommitSha is missing
- Add HEAD~1 fallback when merge-base fails (e.g., no remote main)
- Add 10-second in-memory cache for session-files computation
- Fix scheduler to immediately schedule tasks created via dashboard
- Add task:moved to done handler for immediate scheduling on status change
- Add comprehensive unit tests for scheduler immediate scheduling
- Add unit tests for session-files caching and base ref resolution
This commit is contained in:
gsxdsm
2026-04-02 09:22:50 -07:00
parent 70e9cd9ca3
commit 182fa8eeb2
4 changed files with 301 additions and 57 deletions

View File

@@ -94,6 +94,16 @@ export class Scheduler {
private store: TaskStore,
private options: SchedulerOptions = {},
) {
/**
* Event-driven scheduling: when a task is created, trigger a scheduling
* pass immediately instead of waiting for the next poll interval.
* This reduces latency from up to 15 seconds to near-instant.
*/
this.store.on("task:created", () => {
schedulerLog.log("Task created — triggering scheduling");
this.schedule();
});
/**
* Immediate unpause resume: when `globalPause` transitions from `true`
* to `false`, trigger a scheduling pass right away instead of waiting
@@ -152,6 +162,14 @@ export class Scheduler {
if (task.sliceId && this.options.missionStore && to === "in-progress") {
void this.handleMissionTaskStart(task.id, task.sliceId);
}
// Event-driven scheduling: when a dependency completes (task moves to "done"),
// trigger scheduling immediately so waiting tasks can start without waiting
// for the next poll interval (up to 15 seconds).
if (to === "done") {
schedulerLog.log("Task completed — triggering scheduling");
this.schedule();
}
});
/**