Repository navigation
Keep the log history through schema_consolidate (#354) - #355
Merged
NewGraphEnvironment merged 11 commits intoOct 18, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
.lnk_log_create_tables() reads it; schema_consolidate.R will too. Tests: every built table is named, no log table's primary key includes watershed_group_code, and lnk_pipeline_persist() never deletes from one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
The bucket DELETE now runs over persist tables only. A log table's rows go through a one-transaction staged replace by primary key, so a group copied home from another host keeps the rows of its earlier builds, and a re-consolidate of the same rows changes nothing. A source whose log primary key is not shared is refused before anything is deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
5 log rows (DUNC, KOTL, LARL, SLOC and PINE) and their 60 log_input rows, from the driver's pre-consolidate backup, added with ON CONFLICT DO NOTHING. study_area_verify.sql and verify_extra.sql pass at 241. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
Plan-review fixes. With history kept, a group's newest log row is what names the build its persist rows hold, so consolidate now refuses a source (nothing deleted) when that row on the destination is newer than the source's, or the source has none. The bucket DELETE list and the stage-2 command move into tested helpers; psql gets -X; dropping -1 is measured to fail closed. NULLS LAST in two diagnostic log readers, and the stale consolidate docs and banners are corrected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
Code-check round 1: a group the host no longer holds is refused by the newest-log guard, not lost; only a partial one loses persist rows. A failed read of the source's log now refuses under its own stage rather than as missing rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
Code-check round 3, closed by enumerating every added sentence that restates the history rule or the guard: seven dropped a condition the code has (only three log tables are copied; never deleted by group on the destination; refusal needs a destination log row). RUNBOOK names the pre-log case the guard does not protect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
NewGraphEnvironment
deleted the
354-schema-consolidate-deletes-the-destinati
branch
October 18, 2026 04:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
schema_consolidate()deleted the destination's bucket from every table with awatershed_group_codecolumn before copying. The three log tables that carry that column (log,log_input,log_recompute) were deleted with it, so each cloud-built group kept only its newest row, and every earlier build's provenance on the dispatcher was lost..lnk_log_specs()(inR/lnk_log.R) gives each table's name, columns and primary key..lnk_log_create_tables()and the consolidate script both read it.psql -1 -X -fscript. The script stages the rows, deletes the destination rows whose primary key matches an inbound row, and inserts. Earlier builds stay, and running a consolidate again over the same rows changes nothing.dest_log_newer). It also refuses when the source's log cannot be read (source_log_query), or when a log table's key is not a shared column (log_pk_unshared).lnk_pipeline_persist()never deleted from a log table. That was the issue's second point; a test now pins it.fresh_default. They came from the driver's pre-consolidate dump: 5logrows and 60log_inputrows. The groups are DUNC, KOTL, LARL, SLOC and PINE; PINE was not named in the issue. Evidence:data-raw/logs/consolidate_history_354/.data-raw/README.md, the host banners and CLAUDE.md.NULLS LASTis added to two diagnostic log readers, which would otherwise pick an unfinished run first once history is kept.Related Issues
Test plan
devtools::test(), run locally: 3,147 pass, 5 fail. None of the failures comes from this branch: 3 need the:63333tunnel, which was down, and 2 are the golden ADMS dams pin (8 → 7), already recorded in CLAUDE.md.test-schema_consolidate.R(26 expectations). They cover the split, the DELETE list, the stage-2 command and the refusal. A live block on scratch schemas checks that history is kept, that a re-copy replaces rows, that a malformed file and a script run without-1both leave the table unchanged, and that a repeat run changes nothing.test-lnk_log.R: the specs cover every log table, and no log table's key includes the group.test-lnk_pipeline_persist.R: persist never deletes from a log table.-1dropped, refusal turned off.study_area_verify.sqlandverify_extra.sqlpass atrun_uid=20261017_004619-3f4c713b,expected_n=241.lnk_log_read()still returns this run as the newest row for all 241 groups.schema_consolidate()end to end with a fakesshon scratch schemas, covering five cases including both refusals.Notes
run_key. The code replaces rows by the full primary key instead, which deletes only rows that are being rewritten.fresh's 98 groups and 0 offresh_default's 241. RUNBOOK §8d says so.log_parameters_fresh,log_parameters_habitat_thresholdsandlog_dimensionsare keyed onconfig_hashand still never travel between hosts. This was already noted in the RUNBOOK and is unchanged here./gh-pr-merge, as in this repo's earlier releases./code-checkrounds. Round 3 found a wording defect inside round 1's fix. The loop ended by enumerating every added sentence that restates the history rule or the refusal: 47 lines, 7 corrected. Records are inplanning/archive/2026-10-issue-354-consolidate-log-history/.🤖 Generated with Claude Code
https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx