Skip to content

feat(schedule): bind reason events to authoritative project versions - #548

Draft
seonghobae wants to merge 18 commits into
feat/schedule-reason-event-sqlite-287from
feat/schedule-reason-project-version-287
Draft

feat(schedule): bind reason events to authoritative project versions#548
seonghobae wants to merge 18 commits into
feat/schedule-reason-event-sqlite-287from
feat/schedule-reason-project-version-287

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Buyer / data-integrity objective

Refs #287. This stacked Draft binds already-authorized terminal schedule reason events to ScopeWeave's authoritative project-plan concurrency field on the same SQLite connection before reason-event and immutable audit evidence can commit. A stale plan, wrong tenant/project, missing or ambiguous work-item identity, malformed authority token, or rollback failure must fail closed without creating a parallel work-item version store.

Exact current stack

Parent #519 moved after the previous child reconciliation. The parent-only movement from predecessor 2360d0cc... to current 92858d9... changes only server/schedule_outcome_domain.mjs and tests/unit/schedule-outcome-domain-edge.test.mjs, disjoint from this child's six-path semantic delta. 22883d1... therefore non-destructively merged the exact live parent while preserving both the parent’s explicit-offset schedule evidence repair and this child’s project-version adapter. Fresh comparison proves the live parent is the exact merge base with no inherited parent deletion or weakening.

Implemented contract

server/schedule_reason_event_project_version.mjs:

  • serializes project concurrency authority as canonical project_version:<positive-safe-integer> tokens;
  • binds transitions to exact canonical decimal organization/project identities;
  • rejects blank, overlong, or control-character work-item authority before database lookup;
  • proves the target work-item ID exists exactly once in the projects.tasks_json snapshot observed at the expected project version;
  • conditionally increments only the exact project/tenant/version row on the caller-provided SQLite connection;
  • leaves customer task JSON byte-for-byte unchanged because terminal reason facts remain normalized in the parent reason-event relations;
  • returns the next immutable project-version token only after a successful conditional update;
  • makes predecessor authority immediately stale after one successful transition; and
  • refuses malformed task JSON, duplicate work-item identity, unsafe stored versions, and advancement beyond Number.MAX_SAFE_INTEGER.

When invoked by #519's repository inside its savepoint, the authoritative project-version transition rolls back together with reason-event/audit persistence. The integration regression deliberately triggers a duplicate immutable audit identity after a real project-version update and proves both the version and child event writes roll back.

TDD chronology

  • Initial RED a11c99db7fe379a60fc01702bbca8bf45a1915a4 registered the project-version contract while the production module was absent.
  • Defense-in-depth RED 63b67b17355c5beae41b5c14b83d214b12691a62 added a whitespace-only work-item identity case and failed unit-and-api on that exact test head.
  • GREEN dc8d1b88af48b8f00d4bf4412ed79cb6d9e8c23a rejected blank identity before database lookup.
  • 22883d1667891080bc5c9fdc2c5e721edb7833c7 is stack reconciliation only; it adds no unique project-version behavior beyond preserving both exact parent and child trees.

Current exact-head evidence

Repository-native workflows for exact contributor head 22883d1667891080bc5c9fdc2c5e721edb7833c7 are currently queued:

  • Server Tests 32808630649;
  • Dependency Review 32808630768;
  • OSV Scanner 32808631129.

Queued, pending, skipped-required, cancelled, absent, neutral-required, failed, stale, predecessor, synthetic-only, status-only, author-only, or model-only evidence is non-passing. No SAST/Security/Fuzz exact-head evidence is currently established. ScopeWeave #523 owns repository-native exact-head Server Tests/coverage integrity; ContextualWisdomLab/.github#1222 owns reusable required SAST/Security exact-head checkout integrity. Do not churn this clean head merely to provoke a retry.

Stack / integration boundary

This slice does not add a route/UI, new table, dependency, workflow, scanner suppression, branch-protection change, or competing work-item source of truth. Current child #597 owns the authenticated HTTP write slice and must remain reconciled to this exact parent while the stack is active.

Remain Draft. After #519/#518/#517/#515 reach protected develop, reconcile only this bounded semantic delta onto the resulting fresh protected head and regenerate every then-applicable exact-head CI/browser/owned statement-branch-function-line coverage/docstring/CodeQL/SAST/security/dependency/supply-chain/package/provenance/recovery/review gate. Valid unresolved findings must be zero and a qualifying independent current-head/last-push approval must exist.

Refs #287

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e85de1f0-3569-4de3-a9ae-5bbba79fa88d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@opencode-agent opencode-agent Bot added area: auth Authentication, authorization, identity, or tenant isolation priority: medium Normal-priority or P2 work status: draft Draft pull request type: feature New or expanded product capability labels Aug 22, 2026
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae marked this pull request as ready for review August 26, 2026 22:59

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 potential issue.

Open in Devin Review

Comment on lines +60 to +80
function countWorkItemIdentity(tasksJson, workItemId) {
let tasks;
try {
tasks = JSON.parse(tasksJson);
} catch {
throw new Error('project tasks_json is invalid');
}
if (!Array.isArray(tasks)) {
throw new Error('project tasks_json is invalid');
}
let count = 0;
for (const task of tasks) {
if (task && typeof task === 'object' && !Array.isArray(task) && task.id === workItemId) {
count += 1;
if (count > 1) {
throw new Error('project tasks_json contains duplicate work-item identity');
}
}
}
return count;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Membership scan only checks top-level tasks

countWorkItemIdentity (server/schedule_reason_event_project_version.mjs:60-80) inspects only top-level entries of the parsed tasks_json array. This matches today's flat tasks array persisted in server/app.mjs:272-276. A future move to nested work items would make valid IDs unfindable, silently failing transitions closed.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@seonghobae
seonghobae marked this pull request as draft August 27, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: auth Authentication, authorization, identity, or tenant isolation priority: medium Normal-priority or P2 work status: draft Draft pull request type: feature New or expanded product capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant