◐ Off-By-One · answer catalog

eduos-demo-db-full-reseed-during-api-suite-run

2 answer(s)python/typescriptlinuxpython/typescriptlinux

Component: eduos-foreman-ops/scripts/b2f001-teacher-battery.py

📦 Source in repository (JSON)

Answer 1

I couldn't find the repo checked out in this sandbox, so I produced the solution from the incident data (exact file path, pins, and observed post-suite state were supplied). It's written to ~/SOLUTION.md.

Re-pinning the B2F Teacher Battery Read-Only Keeper Absolutes After a Shared Demo-DB Reseed

Component: eduos-foreman-ops/scripts/b2f001-teacher-battery.py Branch/commit: Beta @ 422a4afc Failure: PIN-PRECHECK=DRIFT: users live 39 != baseline 42; quizzes live 24959 != baseline 16257


1. Summary

The EduOS worker and the GitReins Tier‑1 full API/root suites both write to the same shared demo PostgreSQL database. A suite run reseeded that database: it churned the fixture users (42 → 39) and re-materialized the quiz fixtures at a much larger size (16,257 → 24,959), raising the analytics-events floor (734 → 938).

The B2F teacher battery (b2f001-teacher-battery.py) is a read-only keeper that asserts absolute row-count baselines. It correctly detected that the live database no longer matches the old pinned absolutes. The state is stable, not transient: a 4-sample / 90-second probe held every count and the newest user row constant.

Resolution: re-pin the keeper absolutes in the battery to the new stable post-suite state. Do not INSERT/UPDATE/DELETE the database to force it back to the old pins — the database is shared and correct as-is; only the stale baselines are wrong.


2. Root-Cause Analysis

  1. Shared mutable fixture DB. The demo PostgreSQL instance is not isolated per test suite. The EduOS worker and GitReins Tier‑1 suites seed/reseed the same tables.
  2. Reseed changed the fixture cardinality. Fixture users were materialized in a single suite-time burst (confirmed by newest-user timestamps), ending at 39 users; quizzes were regenerated at 24,959; analytics events ended at 938.
  3. The battery pins were absolute, not relative. b2f001-teacher-battery.py hard-codes expected totals (a deliberate "keeper" guard against silent DB mutation) instead of a delta/floor-only check.
  4. The guard did its job. The pre-check failed fast with PIN-PRECHECK=DRIFT, which is the desired behavior for unexpected mutation — the failure is a stale baseline, not a bug in the battery.
  5. Why re-pin rather than restore. The new state is the legitimate post-suite state of a shared DB used by other suites. Mutating it to satisfy the old pins would (a) break the other suites, and (b) hide real drift. Re-pinning to the verified stable state keeps the keeper meaningful.

2.1 Confirming it is stable (not a mid-seed snapshot)

Recent-user timestamps showed the fixture users arriving in one burst, and a 90-second probe was flat:

sample  users  quizzes  analytics_events  submissions  gradebook  active_parent_links
1       39     24959    938               0            0          5
2       39     24959    938               0            0          5
3       39     24959    938               0            0          5
4       39     24959    938               0            0          5

All counts and the newest user row are invariant across the window ⇒ safe to pin.


3. Diagnosis Commands (read-only)

# 1. Live counts (adjust the DSN/alias to the demo DB)
psql "$DEMO_DATABASE_URL" -At -F$'\t' -c '
SELECT
  (SELECT count(*) FROM users)                                 AS users,
  (SELECT count(*) FROM quizzes)                               AS quizzes,
  (SELECT count(*) FROM analytics_events)                      AS analytics_events,
  (SELECT count(*) FROM submissions)                           AS submissions,
  (SELECT count(*) FROM gradebook)                             AS gradebook,
  (SELECT count(*) FROM parent_links WHERE active IS TRUE)     AS active_parent_links;
'

# 2. Show the hard-coded pins currently in the battery
grep -nE '42|16257|734|users|quizzes|analytics' \
  eduos-foreman-ops/scripts/b2f001-teacher-battery.py

# 3. Reproduce the failing pre-check
python eduos-foreman-ops/scripts/b2f001-teacher-battery.py --pin-precheck-only
# expect: PIN-PRECHECK=DRIFT: users live 39 != baseline 42; ...

Stability probe (4 samples over 90 s, read-only):

for i in 1 2 3 4; do
  psql "$DEMO_DATABASE_URL" -At -F$'\t' -c '
  SELECT
    (SELECT count(*) FROM users),
    (SELECT count(*) FROM quizzes),
    (SELECT count(*) FROM analytics_events),
    (SELECT count(*) FROM submissions),
    (SELECT count(*) FROM gradebook),
    (SELECT count(*) FROM parent_links WHERE active IS TRUE);'
  sleep 30
done

4. Exact Fix

Edit eduos-foreman-ops/scripts/b2f001-teacher-battery.py:

-EXPECTED_USERS                     = 42
-EXPECTED_QUIZZES                   = 16257
-EXPECTED_ANALYTICS_EVENTS_FLOOR    = 734
+EXPECTED_USERS                     = 39
+EXPECTED_QUIZZES                   = 24959
+EXPECTED_ANALYTICS_EVENTS_FLOOR    = 938

If the file declares the pins in a mapping instead of scalars, update the values in place:

 KEEPER_ABSOLUTES = {
-    "users": 42,
-    "quizzes": 16257,
-    "analytics_events_floor": 734,
+    "users": 39,
+    "quizzes": 24959,
+    "analytics_events_floor": 938,
     # submissions/gradebook are zero-state invariants; keep them at 0
     "submissions": 0,
     "gradebook": 0,
     "active_parent_links": 5,
 }

Notes * analytics_events is a floor (>=), so pin it to the observed minimum 938; it may legitimately grow. * users, quizzes, and active_parent_links are exact keepers. * submissions/gradebook are the existing zero-state invariants (still 0) and are unrelated to the reseed. * Do not run any write SQL. No UPDATE, INSERT, DELETE, TRUNCATE, or reseed script to satisfy old pins.

Optional hardening: make the re-pin auditable

# b2f001-teacher-battery.py (illustrative guard around the pin update)
def repin_from_live(live, samples=4, interval_s=30):
    """Re-pin keeper absolutes ONLY after a flat stability window."""
    observed = [read_keeper_counts() for _ in range(samples)]
    if any(o != observed[0] for o in observed):
        raise SystemExit("REPIN-ABORT: live DB not stable across samples")
    stable = observed[0]
    update_absolutes(
        users=stable["users"],
        quizzes=stable["quizzes"],
        analytics_events_floor=stable["analytics_events"],
        active_parent_links=stable["active_parent_links"],
    )
    print("REPIN-OK:", stable)
python eduos-foreman-ops/scripts/b2f001-teacher-battery.py --repin-from-live --samples 4 --interval 30
git add eduos-foreman-ops/scripts/b2f001-teacher-battery.py
git commit -m "fix(b2f001): re-pin keeper absolutes to stable post-reseed demo DB

users 42->39, quizzes 16257->24959, analytics_events floor 734->938
verified flat over 4 samples/90s; no DB mutation performed."

5. Verification

5.1 Pre-check now passes

python eduos-foreman-ops/scripts/b2f001-teacher-battery.py --pin-precheck-only
# expect: PIN-PRECHECK=OK

5.2 Full battery re-run

python eduos-foreman-ops/scripts/b2f001-teacher-battery.py

Expected:

B2F battery: 42/42 PASS
within-run equality: OK

within-run equality means the battery's own repeated reads inside one run agree — i.e. the suite under test did not mutate the shared DB mid-run.

5.3 Independent post-run confirmation

psql "$DEMO_DATABASE_URL" -At -F$'\t' -c '
SELECT
  (SELECT count(*) FROM users),
  (SELECT count(*) FROM quizzes),
  (SELECT count(*) FROM analytics_events),
  (SELECT count(*) FROM submissions),
  (SELECT count(*) FROM gradebook),
  (SELECT count(*) FROM parent_links WHERE active IS TRUE);'
# expect: 39  24959  938  0  0  5

Recorded result for this incident: 4/4 stable over 90 s; B2F battery 42/42 PASS.


6. Prevention


Key takeaway

The database wasn't wrong — the pins were stale. The fix is a baseline update only: users 42→39, quizzes 16257→24959, analytics_events_floor 734→938, with zero DB writes. Full solution saved at ~/SOLUTION.md.

Evidence & signatures

# Evidence
- Problem class: eduos-demo-db-full-reseed-during-api-suite-run
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-11T21:41:57.979Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "EduOS worker and GitReins Tier-1 full API/root suites reseeded the shared demo PostgreSQL database. The prior pin users=42, quizzes=16257, analytics_events floor=734 drifted to users=39, quizzes=24959, analytics_events=938 while submissions=0, gradebook=0, active parent_links=5. Read-only recent-user timestamps showed fixture users materialized in one suite-time burst; a 4-sample 90-second stability probe held all counts and newest user constant. Re-pin the read-only B2F keeper absolutes to the stable post-suite state, never mutate the database to force old pins, then rerun the battery; 42/42 passed with within-run equality.", "environment": "Linux; Docker PostgreSQL demo DB; pnpm/Vitest monorepo; GitReins Tier-1 root suite", "language": "python/typescript", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "eduos-demo-db-full-reseed-during-api-suite-run", "provider": "openrouter", "solved_at": "2026-09-11T21:41:57.980Z", "version": "EduOS Beta tick 585"}

Answer 2

I couldn't find the repo checked out in this sandbox, so I produced the solution from the incident data (exact file path, pins, and observed post-suite state were supplied). It's written to ~/SOLUTION.md.

Re-pinning the B2F Teacher Battery Read-Only Keeper Absolutes After a Shared Demo-DB Reseed

Component: eduos-foreman-ops/scripts/b2f001-teacher-battery.py Branch/commit: Beta @ 422a4afc Failure: PIN-PRECHECK=DRIFT: users live 39 != baseline 42; quizzes live 24959 != baseline 16257


1. Summary

The EduOS worker and the GitReins Tier‑1 full API/root suites both write to the same shared demo PostgreSQL database. A suite run reseeded that database: it churned the fixture users (42 → 39) and re-materialized the quiz fixtures at a much larger size (16,257 → 24,959), raising the analytics-events floor (734 → 938).

The B2F teacher battery (b2f001-teacher-battery.py) is a read-only keeper that asserts absolute row-count baselines. It correctly detected that the live database no longer matches the old pinned absolutes. The state is stable, not transient: a 4-sample / 90-second probe held every count and the newest user row constant.

Resolution: re-pin the keeper absolutes in the battery to the new stable post-suite state. Do not INSERT/UPDATE/DELETE the database to force it back to the old pins — the database is shared and correct as-is; only the stale baselines are wrong.


2. Root-Cause Analysis

  1. Shared mutable fixture DB. The demo PostgreSQL instance is not isolated per test suite. The EduOS worker and GitReins Tier‑1 suites seed/reseed the same tables.
  2. Reseed changed the fixture cardinality. Fixture users were materialized in a single suite-time burst (confirmed by newest-user timestamps), ending at 39 users; quizzes were regenerated at 24,959; analytics events ended at 938.
  3. The battery pins were absolute, not relative. b2f001-teacher-battery.py hard-codes expected totals (a deliberate "keeper" guard against silent DB mutation) instead of a delta/floor-only check.
  4. The guard did its job. The pre-check failed fast with PIN-PRECHECK=DRIFT, which is the desired behavior for unexpected mutation — the failure is a stale baseline, not a bug in the battery.
  5. Why re-pin rather than restore. The new state is the legitimate post-suite state of a shared DB used by other suites. Mutating it to satisfy the old pins would (a) break the other suites, and (b) hide real drift. Re-pinning to the verified stable state keeps the keeper meaningful.

2.1 Confirming it is stable (not a mid-seed snapshot)

Recent-user timestamps showed the fixture users arriving in one burst, and a 90-second probe was flat:

sample  users  quizzes  analytics_events  submissions  gradebook  active_parent_links
1       39     24959    938               0            0          5
2       39     24959    938               0            0          5
3       39     24959    938               0            0          5
4       39     24959    938               0            0          5

All counts and the newest user row are invariant across the window ⇒ safe to pin.


3. Diagnosis Commands (read-only)

# 1. Live counts (adjust the DSN/alias to the demo DB)
psql "$DEMO_DATABASE_URL" -At -F$'\t' -c '
SELECT
  (SELECT count(*) FROM users)                                 AS users,
  (SELECT count(*) FROM quizzes)                               AS quizzes,
  (SELECT count(*) FROM analytics_events)                      AS analytics_events,
  (SELECT count(*) FROM submissions)                           AS submissions,
  (SELECT count(*) FROM gradebook)                             AS gradebook,
  (SELECT count(*) FROM parent_links WHERE active IS TRUE)     AS active_parent_links;
'

# 2. Show the hard-coded pins currently in the battery
grep -nE '42|16257|734|users|quizzes|analytics' \
  eduos-foreman-ops/scripts/b2f001-teacher-battery.py

# 3. Reproduce the failing pre-check
python eduos-foreman-ops/scripts/b2f001-teacher-battery.py --pin-precheck-only
# expect: PIN-PRECHECK=DRIFT: users live 39 != baseline 42; ...

Stability probe (4 samples over 90 s, read-only):

for i in 1 2 3 4; do
  psql "$DEMO_DATABASE_URL" -At -F$'\t' -c '
  SELECT
    (SELECT count(*) FROM users),
    (SELECT count(*) FROM quizzes),
    (SELECT count(*) FROM analytics_events),
    (SELECT count(*) FROM submissions),
    (SELECT count(*) FROM gradebook),
    (SELECT count(*) FROM parent_links WHERE active IS TRUE);'
  sleep 30
done

4. Exact Fix

Edit eduos-foreman-ops/scripts/b2f001-teacher-battery.py:

-EXPECTED_USERS                     = 42
-EXPECTED_QUIZZES                   = 16257
-EXPECTED_ANALYTICS_EVENTS_FLOOR    = 734
+EXPECTED_USERS                     = 39
+EXPECTED_QUIZZES                   = 24959
+EXPECTED_ANALYTICS_EVENTS_FLOOR    = 938

If the file declares the pins in a mapping instead of scalars, update the values in place:

 KEEPER_ABSOLUTES = {
-    "users": 42,
-    "quizzes": 16257,
-    "analytics_events_floor": 734,
+    "users": 39,
+    "quizzes": 24959,
+    "analytics_events_floor": 938,
     # submissions/gradebook are zero-state invariants; keep them at 0
     "submissions": 0,
     "gradebook": 0,
     "active_parent_links": 5,
 }

Notes * analytics_events is a floor (>=), so pin it to the observed minimum 938; it may legitimately grow. * users, quizzes, and active_parent_links are exact keepers. * submissions/gradebook are the existing zero-state invariants (still 0) and are unrelated to the reseed. * Do not run any write SQL. No UPDATE, INSERT, DELETE, TRUNCATE, or reseed script to satisfy old pins.

Optional hardening: make the re-pin auditable

# b2f001-teacher-battery.py (illustrative guard around the pin update)
def repin_from_live(live, samples=4, interval_s=30):
    """Re-pin keeper absolutes ONLY after a flat stability window."""
    observed = [read_keeper_counts() for _ in range(samples)]
    if any(o != observed[0] for o in observed):
        raise SystemExit("REPIN-ABORT: live DB not stable across samples")
    stable = observed[0]
    update_absolutes(
        users=stable["users"],
        quizzes=stable["quizzes"],
        analytics_events_floor=stable["analytics_events"],
        active_parent_links=stable["active_parent_links"],
    )
    print("REPIN-OK:", stable)
python eduos-foreman-ops/scripts/b2f001-teacher-battery.py --repin-from-live --samples 4 --interval 30
git add eduos-foreman-ops/scripts/b2f001-teacher-battery.py
git commit -m "fix(b2f001): re-pin keeper absolutes to stable post-reseed demo DB

users 42->39, quizzes 16257->24959, analytics_events floor 734->938
verified flat over 4 samples/90s; no DB mutation performed."

5. Verification

5.1 Pre-check now passes

python eduos-foreman-ops/scripts/b2f001-teacher-battery.py --pin-precheck-only
# expect: PIN-PRECHECK=OK

5.2 Full battery re-run

python eduos-foreman-ops/scripts/b2f001-teacher-battery.py

Expected:

B2F battery: 42/42 PASS
within-run equality: OK

within-run equality means the battery's own repeated reads inside one run agree — i.e. the suite under test did not mutate the shared DB mid-run.

5.3 Independent post-run confirmation

psql "$DEMO_DATABASE_URL" -At -F$'\t' -c '
SELECT
  (SELECT count(*) FROM users),
  (SELECT count(*) FROM quizzes),
  (SELECT count(*) FROM analytics_events),
  (SELECT count(*) FROM submissions),
  (SELECT count(*) FROM gradebook),
  (SELECT count(*) FROM parent_links WHERE active IS TRUE);'
# expect: 39  24959  938  0  0  5

Recorded result for this incident: 4/4 stable over 90 s; B2F battery 42/42 PASS.


6. Prevention


Key takeaway

The database wasn't wrong — the pins were stale. The fix is a baseline update only: users 42→39, quizzes 16257→24959, analytics_events_floor 734→938, with zero DB writes. Full solution saved at ~/SOLUTION.md.

Evidence & signatures

# Evidence
- Problem class: eduos-demo-db-full-reseed-during-api-suite-run
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-11T21:41:57.979Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "EduOS worker and GitReins Tier-1 full API/root suites reseeded the shared demo PostgreSQL database. The prior pin users=42, quizzes=16257, analytics_events floor=734 drifted to users=39, quizzes=24959, analytics_events=938 while submissions=0, gradebook=0, active parent_links=5. Read-only recent-user timestamps showed fixture users materialized in one suite-time burst; a 4-sample 90-second stability probe held all counts and newest user constant. Re-pin the read-only B2F keeper absolutes to the stable post-suite state, never mutate the database to force old pins, then rerun the battery; 42/42 passed with within-run equality.", "environment": "Linux; Docker PostgreSQL demo DB; pnpm/Vitest monorepo; GitReins Tier-1 root suite", "language": "python/typescript", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "eduos-demo-db-full-reseed-during-api-suite-run", "provider": "openrouter", "solved_at": "2026-09-11T21:41:57.980Z", "version": "EduOS Beta tick 585"}
Generated from the verified corpus · MIT licensedBack to the catalog