Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Diagnostics:
MissingIncludes: None
InlayHints:
Enabled: true
ParameterNames: true
DeducedTypes: true
CompileFlags:
CompilationDatabase: build/ # Search build/ directory for compile_commands.json
Remove: [ -Werror ]
Add:
- -DDEBUG
- -DLOCAL
- -DPGDLLIMPORT=
- -DPIC
- -O2
- -Wall
- -Wcast-function-type
- -Wconversion
- -Wdeclaration-after-statement
- -Wendif-labels
- -Werror=vla
- -Wextra
- -Wfloat-equal
- -Wformat-security
- -Wimplicit-fallthrough=3
- -Wmissing-format-attribute
- -Wmissing-prototypes
- -Wno-format-truncation
- -Wno-sign-conversion
- -Wno-stringop-truncation
- -Wno-unused-const-variable
- -Wpointer-arith
- -Wshadow
- -Wshadow=compatible-local
- -fPIC
- -fexcess-precision=standard
- -fno-strict-aliasing
- -fvisibility=hidden
- -fwrapv
- -g
- -std=c11
- -I.
- -I../../../../src/include
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
watch_file flake.nix
use flake
use project_steering postgresql
# use aws
144 changes: 144 additions & 0 deletions .gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# HOT-indexed updates (HOT/SIU) — GDB breakpoints for code review
#
# Usage: gdb -x .gdbinit <postgres-binary>
# Or from gdb: source .gdbinit
#
# These breakpoints cover the major code paths of the HOT-indexed updates
# patch series, organized by subsystem so groups can be enabled/disabled
# during debugging. They are set on FUNCTION NAMES (not line numbers) so
# they survive code churn; set finer-grained line breakpoints by hand once
# you are stopped in the relevant function.
#
# Tip: to focus on one subsystem, disable all then enable selectively:
# disable breakpoints
# enable 1 2 3

# =========================================================================
# 1. UPDATE DECISION — heap_update() HOT / HOT-indexed / non-HOT choice
# src/backend/access/heap/heapam.c
# =========================================================================

# Main entry: heap_update (chooses classic-HOT, HOT-indexed, or non-HOT)
break heap_update

# Eligibility classifier: HEAP_HOT_MODE_NO / _CLASSIC / _INDEXED
break HeapUpdateHotAllowable

# Identify the modified indexed attributes from old/new heap tuples
# (the simple_heap_update / catalog-update path; the executor path uses
# ExecUpdateModifiedIdxAttrs, see group 4)
break HeapUpdateModifiedIdxAttrs

# =========================================================================
# 2. ON-DISK FORMAT — building the new tuple with the inline trailing bitmap
# src/backend/access/heap/heapam.c, src/include/access/hot_indexed.h
# =========================================================================

# Form the stored heap-only tuple carrying the inline modified-attrs bitmap
break heap_form_hot_indexed_tuple

# The bitmap accessors/stub predicate are static inlines in hot_indexed.h
# (HotIndexedGetModifiedBitmap, HotIndexedBitmapUnion, HotIndexedHeaderIsStub,
# HotIndexedStubGetForward); break on their callers below rather than here.

# =========================================================================
# 3. WRITE PATH — executor side: which indexed attrs changed, which indexes
# to maintain. src/backend/executor/{nodeModifyTable,execTuples,execIndexing}.c
# =========================================================================

# Compute modified_idx_attrs for an UPDATE (executor path)
break ExecUpdateModifiedIdxAttrs

# Attribute-by-attribute old-vs-new comparison over the indexed-attr set
break ExecCompareSlotAttrs

# Mark each index unchanged/needs-update ahead of ExecInsertIndexTuples
break ExecSetIndexUnchanged

# Insert index tuples; skips indexes whose attrs did not change (HOT-indexed)
break ExecInsertIndexTuples

# =========================================================================
# 4. READ PATH — HOT chain walk and crossed-attribute staleness
# src/backend/access/heap/heapam_indexscan.c, access/index/indexam.c
# =========================================================================

# table AM index fetch (takes the buffer share-lock, calls the chain walk)
break heapam_index_fetch_tuple

# Chain walk: unions each crossed hop's/stub's modified-attrs bitmap and
# arms xs_hot_indexed_recheck
break heap_hot_search_buffer

# index_fetch_heap: bitmap-overlap staleness verdict (xs_hot_indexed_stale)
# and the kill_prior_tuple decision (incl. stale-leaf kill)
break index_fetch_heap

# Per-relation/per-index indexed-attr set used by the overlap test
break RelationGetIndexedAttrs

# =========================================================================
# 5. UNIQUE / EXCLUSION — value-confirmed stale-entry skip
# src/backend/access/nbtree/nbtinsert.c, executor/execIndexing.c
# =========================================================================

# btree unique check: SnapshotDirty fetch + crossed-hop recheck
break _bt_check_unique

# Opclass-correct key comparison of the live tuple vs the arriving leaf
# (the value confirmation behind the bitmap verdict for unique inserts)
break _bt_heap_keys_equal_leaf

# Exclusion / unique constraint check (uses index_recheck_constraint to
# value-confirm a stale chain hit)
break check_exclusion_or_unique_constraint

# =========================================================================
# 6. PRUNE / COLLAPSE — dead-chain collapse to xid-free stubs
# src/backend/access/heap/pruneheap.c
# =========================================================================

# Prune+freeze entry (forward path)
break heap_page_prune_and_freeze

# Per-chain pruning: collapses a dead prefix, steps through stubs
break heap_prune_chain

# Find the first live tuple of a (possibly stubbed) chain; drives the
# root-redirect re-point that collapses back to classic HOT
break heap_prune_chain_find_live

# Apply the planned prune actions on the page (shared forward + redo path;
# writes the stub headers/forward links)
break heap_page_prune_execute

# =========================================================================
# 7. VACUUM — all-visible suppression for HOT-indexed chains and stubs
# src/backend/access/heap/vacuumlazy.c
# =========================================================================

# Decides all-visible; keeps a page non-all-visible if it carries a live
# HOT-indexed member, a redirect-to-SIU, or a collapse-survivor stub
break heap_page_would_be_all_visible

# =========================================================================
# 8. WAL — logging and replay (reuses existing UPDATE and prune/freeze
# records; no new record type). src/backend/access/heap/heapam*.c
# =========================================================================

# Log a heap update (the on-page heaptup carries the bitmap; flag is logged)
break log_heap_update

# Replay of UPDATE records (HOT and non-HOT)
break heap_xlog_update

# Replay of prune/freeze records (carries the stub (offset, forward) pairs)
break heap_xlog_prune_freeze

# =========================================================================
# 9. STATISTICS — per-relation HOT-indexed chain shape
# src/backend/access/heap/hot_indexed_stats.c
# =========================================================================

# pg_relation_hot_indexed_stats(regclass)
break pg_relation_hot_indexed_stats
18 changes: 18 additions & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Node modules
scripts/ai-review/node_modules/
# Note: package-lock.json should be committed for reproducible CI/CD builds

# Logs
scripts/ai-review/cost-log-*.json
scripts/ai-review/*.log

# OS files
.DS_Store
Thumbs.db

# Editor files
*.swp
*.swo
*~
.vscode/
.idea/
163 changes: 163 additions & 0 deletions .github/DEV_SETUP_FIX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Dev Setup Commit Fix - Summary

**Date:** 2026-03-10
**Issue:** Sync workflow was failing because "dev setup" commits were detected as pristine master violations

## Problem

The sync workflow was rejecting the "dev setup v19" commit (e5aa2da496c) because it modifies files outside `.github/`. The original logic only allowed `.github/`-only commits, but didn't account for personal development environment commits.

## Solution

Updated sync workflows to recognize commits with messages starting with "dev setup" (case-insensitive) as allowed on master, in addition to `.github/`-only commits.

## Changes Made

### 1. Updated Sync Workflows

**Files modified:**
- `.github/workflows/sync-upstream.yml` (automatic hourly sync)
- `.github/workflows/sync-upstream-manual.yml` (manual sync)

**New logic:**
```bash
# Check for "dev setup" commits
DEV_SETUP_COMMITS=$(git log --format=%s upstream/master..origin/master | grep -i "^dev setup" | wc -l)

# Allow merge if:
# - Only .github/ changes, OR
# - Has "dev setup" commits
if [ "$COMMITS_AHEAD" -gt 0 ] && [ "$NON_GITHUB_CHANGES" -gt 0 ]; then
if [ "$DEV_SETUP_COMMITS" -eq 0 ]; then
# FAIL: Code changes outside .github/ that aren't dev setup
exit 1
else
# OK: Dev setup commits are allowed
continue merge
fi
fi
```

### 2. Created Policy Documentation

**New file:** `.github/docs/pristine-master-policy.md`

Documents the "mostly pristine" master policy:
- ✅ `.github/` commits allowed (CI/CD configuration)
- ✅ "dev setup ..." commits allowed (personal development environment)
- ❌ Code changes not allowed (must use feature branches)

## Current Commit Order

```
master:
1. 9a2b895daa0 - Complete Phase 3: Windows builds + fix sync (newest)
2. 1e6379300f8 - Add CI/CD automation: hourly sync, Bedrock AI review
3. e5aa2da496c - dev setup v19
4. 03facc1211b - upstream commits... (oldest)
```

**All three local commits will now be preserved during sync:**
- Commit 1: Modifies `.github/` ✅
- Commit 2: Modifies `.github/` ✅
- Commit 3: Named "dev setup v19" ✅

## Testing

After committing these changes, the next hourly sync should:
1. Detect 3 commits ahead of upstream (including the fix commit)
2. Recognize that they're all allowed (`.github/` or "dev setup")
3. Successfully merge upstream changes
4. Create merge commit preserving all local commits

**Verify manually:**
```bash
# Trigger manual sync
# Actions → "Sync from Upstream (Manual)" → Run workflow

# Check logs for:
# "✓ Found 1 'dev setup' commit(s) - will merge"
# "✓ Successfully merged upstream with local configuration"
```

## Future Updates

When updating your development environment:

```bash
# Make changes
git add .clangd flake.nix .vscode/ .idea/

# IMPORTANT: Start commit message with "dev setup"
git commit -m "dev setup v20: Update IDE and LSP configuration"

git push origin master
```

The sync will recognize this and preserve it during merges.

**Naming patterns recognized:**
- `dev setup v20` ✅
- `Dev setup: Update tools` ✅
- `DEV SETUP - New config` ✅
- `development environment changes` ❌ (doesn't start with "dev setup")

## Benefits

1. **No manual sync resolution needed** for dev environment updates
2. **Simpler workflow** - dev setup stays on master where it's convenient
3. **Clear policy** - documented what's allowed vs what requires feature branches
4. **Automatic detection** - sync workflow handles it all automatically

## What to Commit

```bash
git add .github/workflows/sync-upstream.yml
git add .github/workflows/sync-upstream-manual.yml
git add .github/docs/pristine-master-policy.md
git add .github/DEV_SETUP_FIX.md

git commit -m "Fix sync to allow 'dev setup' commits on master

The sync workflow was failing because the 'dev setup v19' commit
modifies files outside .github/. Updated workflows to recognize
commits with messages starting with 'dev setup' as allowed on master.

Changes:
- Detect 'dev setup' commits by message pattern
- Allow merge if commits are .github/ OR dev setup
- Update merge messages to reflect preserved changes
- Document pristine master policy

This allows personal development environment commits (IDE configs,
debugging tools, shell aliases, etc.) on master without violating
the pristine mirror policy.

See .github/docs/pristine-master-policy.md for details"

git push origin master
```

## Next Sync Expected Behavior

```
Before:
Upstream: A---B---C---D (latest upstream)
Master: A---B---C---X---Y---Z (X=CI/CD, Y=CI/CD, Z=dev setup)

Status: 3 commits ahead, 1 commit behind

After:
Master: A---B---C---X---Y---Z---M
\ /
D-------/

Where M = Merge commit preserving all local changes
```

All three local commits (CI/CD + dev setup) preserved! ✅

---

**Status:** Ready to commit and test
**Documentation:** See `.github/docs/pristine-master-policy.md`
Loading
Loading