WIP: preserve failed Codex job issue-485-5cicl5k1

このコミットが含まれているのは:
Codex Night Worker
2026-11-18 20:58:12 +09:00
コミット a55408dc32
5個のファイルの変更、207行の追加、15行の削除
+5 -6
ファイルの表示
@@ -41,10 +41,9 @@ class HistoryAccess < ActiveSupport::CurrentAttributes
table = model.table_name
keys = KEYS.fetch(table)
matches = keys.map { "boundary.#{ _1 } = #{ row }.#{ _1 }" }.join(' AND ')
boundaries = "SELECT #{ keys.join(', ') }, MAX(version_no) AS version_no FROM #{ table } " +
"WHERE event_type = 'discard' GROUP BY #{ keys.join(', ') }"
clauses = ["NOT EXISTS (SELECT 1 FROM (#{ boundaries }) boundary WHERE #{ matches } " +
"AND boundary.version_no >= #{ row }.version_no)"]
# Any discard at or after this version hides it, including after a restore.
clauses = ["NOT EXISTS (SELECT 1 FROM #{ table } boundary WHERE #{ matches } " +
"AND boundary.version_no >= #{ row }.version_no AND boundary.event_type = 'discard')"]
clauses += reference_sql(table, row) if references
clauses.map { "(#{ _1 })" }.join(' AND ')
end
@@ -62,8 +61,8 @@ class HistoryAccess < ActiveSupport::CurrentAttributes
# A scalar lookup avoids MySQL's semijoin rewrite losing the JSON row correlation.
"(SELECT 1 FROM JSON_TABLE(COALESCE(#{ document }, JSON_ARRAY()), " +
"'$[*]' COLUMNS (reference_id BIGINT PATH '$' NULL ON EMPTY)) reference_entry " +
"JOIN (#{ discarded_keys(table, key) }) blocked " +
"ON reference_entry.reference_id = blocked.#{ key } LIMIT 1) IS NULL"
"JOIN #{ table } blocked ON reference_entry.reference_id = blocked.#{ key } " +
"WHERE blocked.event_type = 'discard' LIMIT 1) IS NULL"
end
def self.list_reference(table, key, document)