Skip to content

feat(v0.6): enforce typed W41 conflict identities - #153

Merged
akhiabanchian merged 37 commits into
mainfrom
feat/v0.6-w41-conflict-enforcement
Sep 24, 2026
Merged

akhiabanchian merged 37 commits into
mainfrom
feat/v0.6-w41-conflict-enforcement

Conversation

@ammarheidari

@ammarheidari ammarheidari commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Authority

Continuation of W41 under #150 / tracker #146 from protected main=31ce6cae5963263e403eda9c65e2d30e541e1be1.

Current exact head

2071985bb2f62f19ac2b168748d212a57d4f5646

Current source state

The prior partition-scope and durable-backfill P1 findings remain fixed. A subsequent Codex P1 found that a live pre-fence fleet-state process could write another incomplete obligation after backfill. This head adds a database-enforced fleet conflict writer fence and regressions for stale writer INSERT/UPDATE.

Current behavior:

  • legacy partition claim normalization is guard-scope-only; persisted old resource keys/hashes remain unchanged;
  • legacy obligation snapshots missing legacyResourceKey are durably rewritten inside the serialized backfill transaction;
  • conflict-trigger upgrades are transactional;
  • a durable fleet writer fence is installed in the same serialized migration transaction;
  • current obligation INSERT explicitly carries writer version/token;
  • current safety-relevant UPDATE advances the durable writer token;
  • pre-fence INSERT and UPDATE SQL omit those fields and are rejected at the DB boundary on SQLite/PostgreSQL;
  • no provider route, generic executor, raw record/secret staging or release/publication change is introduced.

Review state

The new writer-fence P1 thread remains unresolved pending exact-head persistence/quality evidence. All prior approvals/reviews are stale after the source push; fresh current-head Codex and akhiabanchian review will be required.

Fresh exact-head CI

On 2071985bb2f62f19ac2b168748d212a57d4f5646:

  • dependency-review #36026632003 — success
  • v05-persistence #36026632084 — queued/running
  • quality-gate #36026632318 — running
  • codeql #36026632021 — running
  • release-supply-chain #36026632206 — running
  • v03-benchmark #36026632201 — running
  • v04-benchmark #36026632087 — running

Admission

MERGE BLOCKED until writer-fence evidence passes, the P1 thread is resolved after validation, all applicable exact-head checks are green, fresh current-head CODEOWNER approval exists, and final live main/head/base/mergeability/rule reconciliation passes.

Refs #150.

Add versioned length-delimited fleet conflict identities, explicit topic/broker parent-child overlap, canonical durable obligation bindings, persistence regression updates, and a W41-specific persistence gate extension without activating provider mutation surfaces.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Fix deterministic C# switch-expression precedence in W41 conflict-key decoding so the backend compiles without changing the admitted conflict identity semantics.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Add the canonical W41 serialization scope that collapses admitted topic and broker conflict families to their exact physical parent identities, preserves exact typed identity elsewhere, and maps only the existing v0.5 topic resource-key shape into the same scope. Add fail-closed regression coverage and include it in v05-persistence.

This establishes the database guard-key contract for the next race-safe claim/obligation integration without activating any provider mutation surface.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Add the W41 common fail-closed classifier/guard for existing Connect create, update, resume, restart and task-restart paths. Recognized MirrorMaker 2 connector classes cannot be activated through the v0.5 Connect surface while managed replication activation remains unavailable.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Wire the W41 replication activation bypass guard into existing Connect create, configuration-update, resume, restart and task-restart pre-dispatch validation while leaving pause and non-replication Connect behavior on the admitted v0.5 path.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Exercise the W41 pre-dispatch guard against MM2 create, update, resume, connector restart and task restart while preserving pause and ordinary non-replication Connect behavior. Classification without connector.class fails closed.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Add a server-derived reversible bridge from typed topic-family conflict identities to the existing v0.5 topic resource key. Non-topic fleet effects remain outside the legacy bridge and ambiguous identities fail closed.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Persist a server-derived, read-only legacy topic resource identity alongside typed fleet conflict keys when and only when the conflict is in the admitted topic family. Recompute it on restore so callers cannot widen or substitute the bridge.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Install database-native serialization guards once both legacy resource claims and fleet obligations exist. SQLite writer serialization and PostgreSQL guard-row FOR UPDATE locking make claim-vs-obligation admission race-safe; a blocking fleet topic obligation causes the existing v0.5 claim insert to be skipped and therefore reported as ResourceConflict.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Have each mutation connection factory install the cross-generation guard once both legacy claim and fleet-obligation schemas are present. The guard remains dormant before W41 persistence exists and does not add a parallel executor.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Return a typed fleet-obligation admission conflict when the database-native W41 guard suppresses insertion behind an existing legacy claim, and prove both directions plus concurrent race serialization on SQLite and PostgreSQL.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Introduce the v4-to-v5 mutation persistence compatibility fence and require a drained execution state before migration.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Exercise drained v4-to-v5 mutation schema migration and fail-closed future-version refusal on SQLite and PostgreSQL.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>

Copy link
Copy Markdown
Contributor Author

W41 PM safety finding on exact head 3c79c2b5e8a516f5526367bf492860f23142501b — this is not an independent admission review.

The new v4→v5 migration fence is not yet sufficient to enforce the admitted mixed-version invariant against an already-running v0.5 executor. AdoMutationOperationRepository.InitializeAsync() checks/migrates the schema marker only at process initialization. A v0.5 process can therefore initialize successfully while the marker is still v4, remain alive but idle, then a v0.6 process can observe zero Executing rows/cluster slots and migrate the marker to v5. The already-running v0.5 process does not re-read that marker before TryAcquireClusterExecutionSlotAsync / TryAcquireResourceClaimsAsync / provider dispatch, and the legacy claim INSERT shape remains admissible. That creates a mixed-version execution window after the v5 marker is active.

Required correction before this mixed-version item can be considered complete: establish a database-enforced effect-admission fence that an old executor cannot satisfy after v5 activation, not only an initialization-time marker check. One viable shape is a version/epoch carried by current claim/slot admission plus DB constraint/trigger enforcement so old SQL fails closed; an equivalent race-safe mechanism is acceptable. Preserve existing outstanding ExecutionUnknown obligations/claims and do not infer process absence from a momentarily drained table.

Please add a regression that models an executor initialized under v4, keeps that repository/process alive across another instance's v4→v5 migration, then attempts a new mutation claim/dispatch after the marker is v5. It must fail before any provider effect. Future/unknown schema versions must continue to fail closed.

Show that expired-worker recovery releases renewable execution state without deleting a blocking fleet obligation, that a conflicting legacy claim remains denied, and that Ready work is not auto-replayed.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Run durable observation-cap/restart accounting tests in the dedicated mutation persistence workflow alongside conflict and recovery evidence.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
@ammarheidari
ammarheidari marked this pull request as ready for review September 24, 2026 13:18

Copy link
Copy Markdown
Contributor Author

@codex review

Please perform a substantive exact-head review of W41 candidate 181104279ec79a0162cbab918bab79a581aa9139. Focus on: v0.5 identity/hash preservation; compound authorization; durable obligation/claim race serialization on SQLite/PostgreSQL; mixed-version v4→v5 drain fence; recovery/no-auto-replay semantics; Connect/MM2 activation bypass guards; and absence of any new provider mutation surface.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 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-09-24T16:33:11.551581Z 20441ea Manual request
ℹ️ 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: 181104279e

ℹ️ 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".

akhiabanchian
akhiabanchian previously approved these changes Sep 24, 2026
Add provider-native slot/claim execution-version guards so an already-running v0.5 executor cannot acquire new effect-admission state after v5 activation.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Prepare and validate the durable v5 admission fence during migration and require current execution-schema version on every new cluster slot and resource claim.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Model a v0.5 executor initialized under schema v4, activate v5 from another instance, and prove the legacy slot/claim SQL fails at the database before provider-effect admission while v0.6 epoch-bearing SQL succeeds.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Recognize the fully-qualified, simple-class and Connector-suffix-stripped aliases accepted by Kafka Connect for the three standard MirrorMaker 2 connector classes, closing alternate activation paths.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>

Copy link
Copy Markdown
Contributor Author

@codex address that feedback

Please address both currently unresolved exact-head P1 review threads on 3d8df98ad85a7e98f70c9f5f2cca941eb70a16cf and keep the change strictly inside admitted W41.

  1. Legacy partition-claim normalization: the v0.5 claim path may hold cluster/<cluster>/topic/<topic>/partition/<n> while v0.6 obligations bind the physical topic scope. Normalize every recognized legacy topic-partition claim to the same physical-topic guard scope for both guard-row serialization and conflict predicates in SQLite and PostgreSQL. Preserve the original stored v0.5 resource key/identity/hash; this is conflict-scope normalization only. Add regressions proving v0.5 partition claims serialize/conflict with both v0.6 Topic and TopicPartition obligations on SQLite and PostgreSQL, including the concurrent exactly-one-admission boundary.

  2. Legacy obligation backfill durability: during EnsureConflictScopePersistenceAsync, if FleetConflictObligation.Restore(...) derives a missing LegacyResourceKey from an older obligation snapshot, persist the normalized snapshot_json atomically in the same serialized initialization transaction before the cross-generation conflict triggers are relied upon. Do not wait for a later save. Add SQLite/PostgreSQL regressions that seed a pre-field outstanding obligation, initialize v5/W41 persistence, then prove a new v0.5 conflicting claim is rejected at the database boundary.

Do not resolve either review thread until the implementation and real regressions are present and passing. Do not weaken the existing execution-version fence, canonical typed conflict identity, current trigger guarantees, or v0.5 compatibility contracts. No new provider mutation surface, generic executor, release/publication, or W42+ work in this correction.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

akhiabanchian
akhiabanchian previously approved these changes Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@codex address that feedback

Please fix the two current exact-head P1 findings on 3d8df98ad85a7e98f70c9f5f2cca941eb70a16cf without weakening any W41/v0.6 safety invariant:

  1. Normalize recognized legacy v0.5 partition claim keys (cluster/{cluster}/topic/{topic}/partition/{n} and any already-supported equivalent legacy shape) to the same physical-topic guard scope as Topic/TopicPartition/TopicConfiguration fleet obligations, for both the serialization lock key and the conflict predicate in SQLite and PostgreSQL. Preserve old persisted claim keys/hashes themselves; this is a guard-scope normalization only.
  2. During legacy obligation backfill, if FleetConflictObligation.Restore derives a missing legacyResourceKey, persist the normalized snapshot atomically inside the same serialized initialization/backfill transaction so the cross-generation DB triggers immediately see it. Do not rely on a later save.

Add/retain real SQLite and PostgreSQL regressions proving: (a) a legacy partition claim conflicts with a fleet topic/partition/config obligation in both admission directions, including concurrent admission with exactly one winner; (b) a pre-existing obligation snapshot lacking legacyResourceKey is durably rewritten during initialization and blocks a subsequent legacy claim immediately; (c) exact old v0.5 resource keys and hashes remain unchanged; (d) no raw records/secrets or new provider mutation surface is introduced.

After changes, run the applicable W41/persistence test surface. Do not resolve the review threads merely by comment; leave them for PM reconciliation after the new head and CI are verified.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

Normalize recognized legacy partition resource claims to their physical-topic guard scope in SQLite and PostgreSQL triggers while preserving the persisted v0.5 resource key and hash. Version the SQLite guard installation and detect the PostgreSQL helper so existing pre-fix trigger installations are upgraded fail-closed.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
When legacy fleet obligations deserialize without legacyResourceKey, atomically rewrite the normalized snapshot inside the existing serialized initialization transaction before accepting the canonical scope binding. Reject conflicting persisted identities and fail closed if the rewrite is suppressed or races.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Exercise SQLite and PostgreSQL legacy partition claims against fleet topic/partition/config obligations in both directions and concurrent admission, verify old resource keys and hashes remain exact, and prove initialization durably rewrites a legacy obligation snapshot before blocking a subsequent partition claim.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>

Copy link
Copy Markdown
Contributor Author

@codex review

Please perform a fresh substantive review of current exact head 2e18db487df1027f2c7d368e325101e21d0521fa. The two prior P1 findings were corrected and validated by the exact-head persistence/quality gates. Prior review evidence is stale; focus on safety/correctness regressions only.

Install or upgrade the SQLite/PostgreSQL cross-generation conflict triggers and their scope helper in one database transaction so legacy v0.5 writers cannot pass through a DROP/CREATE visibility window during guard migration.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>

@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: 2e18db487d

ℹ️ 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".

Copy link
Copy Markdown
Contributor Author

@codex review

Fresh exact-head review requested for 225eb37fd204ea2c325bbe2c7a4cf1afe42a2743. This head retains the two prior P1 corrections and additionally makes conflict-trigger upgrades transactional to close the migration visibility window. Please review substantive safety/correctness only; all prior-head review evidence is stale.

Add a durable insert/update writer fence for fleet conflict obligations so already-running pre-fence fleet-state processes cannot recreate or mutate obligations without current canonical guard identities after backfill.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Install the fleet conflict writer fence inside the serialized scope/backfill transaction and make every current obligation insert/update explicitly satisfy the database writer version/token contract. Older fleet-state SQL remains unable to write after migration.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Model pre-fence fleet-state INSERT and UPDATE statement shapes after migration and prove the database writer fence rejects both on SQLite and PostgreSQL, preventing live old processes from recreating or mutating obligations without current guard identities.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>

@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: 225eb37fd2

ℹ️ 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".

Pass the current durable writer-fence version into the guarded fleet obligation UPDATE statement so current writers satisfy the database fence while stale writers remain rejected.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Model durable pre-fence fleet state before the current store initializes, then prove initialization backfills the missing legacy guard identity, installs the writer fence, blocks a partition claim immediately, and rejects stale post-migration writer SQL on SQLite and PostgreSQL.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Derive SQLite legacy partition guard scope from the terminal numeric /partition/{n} suffix rather than the first /partition/ token, so admitted cluster IDs containing that token cannot bypass physical-topic serialization.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>
Exercise both legacy-claim-first and fleet-obligation-first conflict admission with a cluster ID containing /partition/, proving only the terminal numeric partition suffix is normalized on SQLite while retaining PostgreSQL parity.

Refs #150

Signed-off-by: Ammar Heidari <ammar@arad-itc.org>

Copy link
Copy Markdown
Contributor Author

@codex review

Please perform a fresh substantive review of exact head 20441ea3b014faf04ddb933b5b908e478116516f. All prior P1 findings have source/test corrections and current-head quality/persistence evidence. Focus on new safety/correctness findings only; prior-head review evidence is stale.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 20441ea3b0

ℹ️ 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".

@akhiabanchian
akhiabanchian merged commit fb2cf62 into main Sep 24, 2026
9 checks passed
@akhiabanchian
akhiabanchian deleted the feat/v0.6-w41-conflict-enforcement branch September 24, 2026 17:44
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.

2 participants