Skip to content

retention test: second CREATE TRIGGER fails in CI with "trigger fail_retention_audit already exists" #70

Closed

Description

@TusanHomichi

Current repair scope (2026-09-23)

This existing failure now blocks the authorized workflow correction in #73 / PR #74. The canonical dependency graph remains in #73. A deterministic diagnostic using the repository-pinned SQLite 3.46.0 reproduces the duplicate-trigger error on a stale connection while a fresh connection observes the trigger absent. This supports a fixture schema-cache explanation; the rollback mechanism below was the initial hypothesis, not a verified cause.

Observable outcome: both audit-failure rollback scenarios retain their assertions and run with independent fresh fixtures, removing pooled DROP/recreate schema churn. Only crates/consolebook-server/tests/retention.rs may change. No runtime, migration, dependency or CI/gate changes are needed.

Acceptance: inspect the minimal diff, run the unchanged full local and hosted gates on the frozen candidate, preserve failed evidence, verify exact merged main, archive/read back evidence and remove only owned resources. Repair is the direct prerequisite for the already authorized #73 merge/cleanup. Effort follows the owner's current no-default-cap policy; no separate owner budget was supplied.

Completed: PR #75 merged as f154004374d897d8419d2b9dca9275ed996cc904, exact-main tree verified against candidate 0e2a21a, full local and hosted gates passed (176 Rust / 10 browser each), evidence archived and read back, and only owned branch/worktree removed.

Next action: continue #73 / #74; no further #70 work remains.

Initial report (preserved)

What happens

crates/consolebook-server/tests/retention.rs::authority_and_policy_failures_leave_no_partial_state fails on CI, deterministically so far (2/2 attempts on one head), with its own fixture injection rather than a product assertion:

thread 'authority_and_policy_failures_leave_no_partial_state' panicked at crates/consolebook-server/tests/retention.rs:607:212:
inject: Database(SqliteError { code: 1, message: "trigger fail_retention_audit already exists" })

Line 607 is the test's second CREATE TRIGGER fail_retention_audit. The first is created at 583, dropped at 605 (.expect("remove") did not panic), and then re-created at 607 — where SQLite says it already exists. So the DROP TRIGGER did not take effect, even though it reported no error.

Evidence

  • Runs: 34664913384 (attempt 1 and the --failed rerun) — both failed at the same line with the same message; cargo test --workspace otherwise green in the same job.
  • The head that failed is afed873 on codex/34-draft-refused-text, whose diff against main (7936a4e) touches no Rust file (git diff --stat 7936a4e..afed873 → docs/development.md plus four web/ files). The retention test and the code it exercises are byte-identical to main.
  • Locally (Linux, same toolchain, cargo test --workspace): 0 failures, twice; the retention binary alone: 10/10, six consecutive runs; the single test alone: 12/12.
  • Earlier CI run of the same branch before it was rebased: cargo test --workspace green (34661983530).

Why it looks pre-existing rather than introduced

The failing sequence is inside the test's own setup and depends on a DROP TRIGGER that the test observed as successful. The most plausible mechanism is transactional: if the DROP executes on a pooled connection that still has an uncommitted write transaction open (or whose queued ROLLBACK lands after it), the drop is undone and the trigger reappears. That would make the test sensitive to connection reuse and timing rather than to any product behaviour — which also fits the CI-only reproduction, given that the same Rust code is green on main's PR run and on every local run.

Suggested fix (for whoever owns it)

Make the injection and its removal explicit about the connection and the transaction, for example:

  • take one connection (let mut conn = fx.pool.acquire().await?) and run the CREATE/DROP/CREATE on it, so a pooled connection cannot interleave a transaction with the DDL; and/or
  • DROP TRIGGER IF EXISTS fail_retention_audit before each CREATE, so a leftover trigger is removed rather than fatal; and/or
  • assert the drop's effect (SELECT 1 FROM sqlite_master WHERE type = 'trigger' AND name = ...) before re-creating.

Impact

It is the only thing standing between #67 and a green pr-gate: the branch's own Rust, web, and browser gates are green, and the branch adds no Rust code. Filing it separately as the repository guidance asks rather than folding a retention-test change into a web-only PR.

Activity

  1. TusanHomichi commented on Sep 23, 2026

    @TusanHomichi
    MemberAuthor

    Hosted gate failure — preserved, not retried

    Candidate 1ec841a7ccdb3a7c79fd5e321f635b0385da88f8 failed hosted run 35883145504. The four-file policy diff changes no Rust source or tests.

    Web install/check/build, Rust formatting and Clippy passed. cargo test --workspace failed in tests/retention.rs::authority_and_policy_failures_leave_no_partial_state at line 607:

    inject: Database(SqliteError { code: 1, message: "trigger fail_retention_audit already exists" })
    

    The retention suite reported 9 passed / 1 failed. The explicit server build and hosted browser steps were skipped. This matches the existing symptom in #70; its proposed mechanism remains a hypothesis pending investigation. The local receipt remains a local pass, not a substitute for hosted acceptance.

    Full failed log preserved locally at /data/dev/home/.codex/tmp/consolebook-repair-policy-20260923/hosted-failed.log, SHA-256 c1b07fce01e4966c7991b2a171b4390148a0f49ae316995d9c79bcd8ad63a751; run metadata is archived beside it. No hosted rerun has been requested. Sol/max is investigating the fixture and pinned dependency behavior read-only; the parent retains the docs-only scope and integration decision.

    Next action: establish a supported cause or precise blocker for #70, then determine the smallest legitimate repair path without weakening or bypassing the gate.

  2. TusanHomichi commented on Sep 23, 2026

    @TusanHomichi
    MemberAuthor

    Supported mechanism and frozen repair

    Candidate 0e2a21aecd216520f7b6b07154eb63adb3c77431 (tree 332ad374d6dc12104f0ae4a30c02629df7d53086) splits the authority and policy audit-failure cases into separate fresh fixtures. The one-file diff is +6/-5 lines and retains every product call and rollback assertion.

    Sol/max reproduced the exact error using pinned SQLx 0.8.6 and SQLite 3.46.0. The parent independently compiled the diagnostic against the bundled SQLite source and checked these observations:

    sqlite=3.46.0
    drop_on_a: rc=0
    after_drop a=0 c=0
    create_second_on_b: rc=1 message=trigger fail_retention_audit already exists
    create_second_on_fresh_c: rc=0
    

    A stale connection-local schema view is enough to produce the error. The absent trigger observed by an independent connection is a negative control for an undropped trigger in this sequence; it supersedes the earlier speculative rollback explanation. The full hosted run's connection assignment was not traced, so that final attribution remains an inference. SQLite's maintainer describes the same class of schema-cache preparation behavior.

    The exact pinned parser checks the trigger hash before schema refresh (sqlite3.c:151900-151912). Detailed findings, probe sources and lockfile remain in /data/dev/home/.codex/tmp/consolebook-repair-policy-20260923/retention-investigation/. The independent compile/run receipt is /data/dev/home/.codex/tmp/consolebook-retention-fixtures-20260923/schema-probe-reviewed.json (actual commands, timing and hashes). Reviewed log SHA-256: 2901d03be27fc58cbccaa94077ba4921c1c8c4fa0238f8c49b9f95a5c7b570a2.

    No original assertions were removed, and no retries, IF EXISTS, pool restrictions, runtime/migration changes or gate exemptions were introduced. Required gates are now running against the frozen repair. Requested model routes are recorded from native spawn/assignment records; individual per-turn runtime metadata is not exposed.

  3. TusanHomichi commented on Sep 23, 2026

    @TusanHomichi
    MemberAuthor

    Candidate verification receipt

    Candidate 0e2a21aecd216520f7b6b07154eb63adb3c77431; tree 332ad374d6dc12104f0ae4a30c02629df7d53086. Recorded 2026-09-23T15:59:06.034027+00:00. All local checks below ran as the unprivileged dev user in the isolated issue worktree; none changed tracked files. Local output hashes were independently regenerated from actual files.

    Check UTC start Seconds Exit
    web-ci 2026-09-23T15:55:01.986800+00:00 1.449 0
    web-check 2026-09-23T15:55:03.464440+00:00 7.151 0
    web-build 2026-09-23T15:55:10.644982+00:00 6.987 0
    fmt 2026-09-23T15:55:17.661746+00:00 0.354 0
    clippy 2026-09-23T15:55:18.051324+00:00 26.693 0
    rust-tests 2026-09-23T15:55:44.774033+00:00 138.406 0
    binary 2026-09-23T15:58:03.214235+00:00 0.614 0
    browser-install 2026-09-23T15:58:03.857953+00:00 1.19 0
    browser 2026-09-23T15:58:05.084988+00:00 29.622 0

    Rust: 27 reported suite summaries, 176 passed, 0 failed, 0 ignored; no load, recovery, or production-readiness claim.

    Commands and working directories:

    web-ci: cwd=/data/dev/src/consolebook-worktrees/70-isolate-retention-fixtures/web
      npm ci
    web-check: cwd=/data/dev/src/consolebook-worktrees/70-isolate-retention-fixtures/web
      npm run check
    web-build: cwd=/data/dev/src/consolebook-worktrees/70-isolate-retention-fixtures/web
      npm run build
    fmt: cwd=/data/dev/src/consolebook-worktrees/70-isolate-retention-fixtures
      cargo fmt --check
    clippy: cwd=/data/dev/src/consolebook-worktrees/70-isolate-retention-fixtures
      cargo clippy --workspace --all-targets -- -D warnings
    rust-tests: cwd=/data/dev/src/consolebook-worktrees/70-isolate-retention-fixtures
      cargo test --workspace
    binary: cwd=/data/dev/src/consolebook-worktrees/70-isolate-retention-fixtures
      cargo build -p consolebook-server
    browser-install: cwd=/data/dev/src/consolebook-worktrees/70-isolate-retention-fixtures/web
      npx playwright install chromium
    browser: cwd=/data/dev/src/consolebook-worktrees/70-isolate-retention-fixtures/web
      npm run e2e
    

    Actual local output evidence:

    {
      "target/debug/consolebook-server": "bd2491e35fa5665935b17645c7385c918a0bf88c018c61819305ec7d332f043d",
      "asset_manifest": {
        "path": "/data/dev/home/.codex/tmp/consolebook-retention-fixtures-20260923/browser-assets.json",
        "sha256": "eb31f061b3b17c7f23651f0c3e9ab426ee8ec7234521af445f6d3b50adc128aa",
        "files": 46
      }
    }

    The web-build, binary, and browser asset manifests are compared by hash; the binary exercised by the browser suite is hashed after the explicit build and again after E2E. Hosted results use their separate GitHub run record and are not relabeled as local runs.

    Log SHA-256 values (raw logs and JSON receipts retained in the local archive):

    web-ci.log  3d7c0c961580fcb240ac83dee24f597be20503ea7ce83dc1980e3daa7aec63ee
    web-check.log  4756466b815c2627ce1df82f73686f1caa7d5611efd0be5fc4fa3b7632c05182
    web-build.log  3d586b4a26e608bae252b5b3af3cd630d74d2fc7b6bf3002f9b6fba6a71d7a61
    fmt.log  e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
    clippy.log  bd8f23064244eb298a54da34e43af7b747370d8698151a38ecc70f23a67d020a
    rust-tests.log  d571ccb557b33c392cc162e5594713c5e4c949d11cafaf0ff3d9d8f8cd18b956
    binary.log  299f16a2c523be18fef769975d2df00e0505521db047540feea3a74b94666887
    browser-install.log  e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
    browser.log  fd79eb07357bc7fd2047ed547a5dea3f51a74ee60896e745a440327e4cba7c16
    
    rust-tests:
    hip_and_close_rules ... ok
    
    test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 5.21s
    
         Running tests/web_shell.rs (target/debug/deps/web_shell-a17394566ea013b2)
    
    running 3 tests
    test root_serves_spa_or_honest_notice ... ok
    test unknown_api_routes_return_json_404_not_html ... ok
    test instance_reports_initialization_state ... ok
    
    test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.52s
    
         Running tests/write_transactions.rs (target/debug/deps/write_transactions-03fb0435a76f302c)
    
    running 21 tests
    test program_writes::publication_has_one_winner_and_one_audit_event ... ok
    test account_writes::reset_issuance_serializes_without_discarding_valid_codes ... ok
    test program_writes::draft_discard_has_one_winner ... ok
    test program_writes::duplicate_program_name_has_one_winner ... ok
    test program_writes::version_creation_assigns_distinct_monotonic_numbers ... ok
    test program_writes::draft_replacements_remain_whole_last_write_content ... ok
    test account_writes::setup_code_rotation_serializes_with_initialization ... ok
    test training_writes::assignments_serialize_creation_and_ending ... ok
    test program_writes::import_serializes_names_and_version_numbers ... ok
    test training_writes::cancellation_and_draft_creation_cannot_both_commit ... ok
    test training_writes::competing_session_requests_return_created_and_typed_conflict ... ok
    test training_writes::duplicate_enrollment_has_one_winner ... ok
    test wal_deferred_snapshot_reproduction ... ok
    test training_writes::overlapping_session_creation_has_one_winner ... ok
    test training_writes::phase_events_validate_the_committed_pause_state ... ok
    test training_writes::membership_additions_and_removals_have_typed_losers ... ok
    test account_writes::duplicate_usernames_are_rechecked_after_hashing ... ok
    test account_writes::setup_has_one_administrator_and_consumes_its_code_once ... ok
    test account_writes::reset_code_is_consumed_once_and_revokes_sessions ... ok
    test training_writes::enrollment_events_validate_the_committed_status_and_pin ... ok
    test training_writes::session_updates_and_closes_keep_existing_outcomes ... ok
    
    test result: ok. 21 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.95s
    
       Doc-tests consolebook_server
    
    running 0 tests
    
    test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
    
    
    
    browser:
    
    > [email protected] e2e
    > playwright test
    
    
    Running 10 tests using 6 workers
    
    (node:1053819) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:1053815) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:1053816) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:1053825) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:1053818) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:1053817) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
    (Use `node --trace-warnings ...` to show where the warning was created)
      ✓   3 e2e/server.spec.ts:6:1 › missing executable and early exit fail at startup (65ms)
      ✓   7 e2e/server.spec.ts:12:1 › an occupied listener cannot be mistaken for the spawned server (161ms)
      ✓   8 e2e/server.spec.ts:38:1 › parallel installations have distinct listeners and awaited cleanup (430ms)
      ✓   4 e2e/retention.spec.ts:4:1 › administer retention authority, policy versions, and hold history (3.3s)
      ✓   6 e2e/programs.spec.ts:11:1 › author, publish, and compare a program version (5.2s)
      ✓   2 e2e/sessions.spec.ts:46:1 › record, close, and read sessions with local time semantics (6.2s)
      ✓   5 e2e/lifecycle.spec.ts:49:1 › assign a trainer, record phase history, and read it scoped (6.6s)
      ✓   9 e2e/shell.spec.ts:11:1 › full shell lifecycle (6.0s)
      ✓  10 e2e/signoff-history.spec.ts:83:1 › a trainee reads their own complete signoff history (8.9s)
      ✓   1 e2e/drafts.spec.ts:113:1 › draft, collaborate, transfer, and submit a daily evaluation (26.2s)
    
      10 passed (27.8s)
    
    

    Independent model review of 0e2a21aecd216520f7b6b07154eb63adb3c77431, retained Astra/max assignment: no substantive findings. Each test owns a distinct temporary database and pool. Both failure injections, service calls, and every explicit rollback assertion remain intact. No runtime, schema, dependency or gate changes. The diagnostic supports a stale-schema mechanism, not a claim to have observed the failed hosted run's exact connection assignment. No edits or gates were run by the reviewer. Per-turn runtime routing is not exposed by the native tool; the requested route is recorded here.

    Reviewed tests/retention.rs SHA-256: bdccd5b09531a16557d00776c69ae30b8a7f82fa9eadc43a11499005e649690b.

    Hosted run 35885138099 is separate and still running. No merge has occurred.

  4. TusanHomichi commented on Sep 23, 2026

    @TusanHomichi
    MemberAuthor

    Integration evidence archive

    PR #75 merged as f154004374d897d8419d2b9dca9275ed996cc904. Remote main was fetched and local main fast-forwarded to that exact SHA. Its tree 332ad374d6dc12104f0ae4a30c02629df7d53086 equals tested candidate 0e2a21aecd216520f7b6b07154eb63adb3c77431; the candidate is an ancestor and the merged parents are recorded. No new test execution on the merge SHA is claimed.

    Acceptance evidence: supported diagnosis; local gates and independent review; successful hosted run. Local and hosted suites each passed 176 Rust and 10 browser tests. The local retention binary passed 11/11, including both isolated rollback scenarios. Hosted raw-log SHA-256: f0b4230467370430f5747b7b943df22459daf9a8d9efecdf8512f0a6f29403e6. Hosted binaries/assets were not downloaded, so no hosted artifact hash is claimed.

    Only one test fixture file changed. All original product calls and assertions remain. The arbitrary repair cap is superseded by the owner's active instruction; the pending policy PR #74 persists that correction. No broader product, deployment or unrelated merge authority was used.

    All five pre-existing untracked files match their initial SHA-256 values. Local main has no tracked changes. Full local receipts, logs, independent review and exact-main proof remain in /data/dev/home/.codex/tmp/consolebook-retention-fixtures-20260923/; diagnostic sources remain in the linked #73 archive. Main-proof SHA-256: 411ce415532446555d62a1377cac8fd9755f91bfc65c7fe7667094dada9d6e3b.

    Next action: read this archive back, remove only branch/worktree codex/70-isolate-retention-fixtures, close #70 and unlock policy integration after #74's own gates. The original #74 failed run remains preserved.

  5. TusanHomichi commented on Sep 23, 2026

    @TusanHomichi
    MemberAuthor

    Cleanup verified: removed only the codex/70-isolate-retention-fixtures local/remote branch and its owned worktree after archive read-back. No task-owned gate/server processes remain. The unrelated worktrees and all five original untracked file hashes are unchanged.

    #70 is complete at main f154004374d897d8419d2b9dca9275ed996cc904. The next authorized action is final verification/integration of #74 under the canonical #73 graph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions