From 495bb5fad56bfffc5b3c971360fd688cc9aab629 Mon Sep 17 00:00:00 2001 From: Paul Reinlein Date: Thu, 29 Jan 2026 15:52:40 -0500 Subject: [PATCH] Extract Git out of skills and add new skill --- .claude/skills/lading-optimize-hunt/SKILL.md | 143 ++++++------------ .../assets/db/cache-inline.yaml | 1 - .../assets/db/datadog-logs-buffer-reuse.yaml | 2 - .../assets/db/dogstatsd-buffer-reuse.yaml | 1 - .../db/fluent-on-demand-serialization.yaml | 3 - .../db/syslog-to_bytes-reusable-buffer.yaml | 3 - .../skills/lading-optimize-rescue/SKILL.md | 59 +++----- .../skills/lading-optimize-review/SKILL.md | 103 +++++-------- .../lading-optimize-review/assets/db.yaml | 4 +- .../opt-fluent-on-demand-serialization.yaml | 3 +- .../assets/db/opt-payload-cache-inline.yaml | 4 +- .../skills/lading-optimize-submit/SKILL.md | 133 ++++++++++++++++ .../assets/commit-template.txt | 0 .../skills/lading-optimize-validate/SKILL.md | 36 +---- 14 files changed, 252 insertions(+), 243 deletions(-) create mode 100644 .claude/skills/lading-optimize-submit/SKILL.md rename .claude/skills/{lading-optimize-hunt => lading-optimize-submit}/assets/commit-template.txt (100%) diff --git a/.claude/skills/lading-optimize-hunt/SKILL.md b/.claude/skills/lading-optimize-hunt/SKILL.md index 30bfe341f..45d09a6c8 100644 --- a/.claude/skills/lading-optimize-hunt/SKILL.md +++ b/.claude/skills/lading-optimize-hunt/SKILL.md @@ -87,103 +87,84 @@ Otherwise, check pending hunt issues or pick from hot subsystems: --- -## Phase 3: Implement +## Phase 3: Establish Baseline -```bash -git checkout main && git pull -git checkout -b opt/- -``` +**CRITICAL: Capture baseline metrics BEFORE making any code changes.** + +### Stage 1: Micro-benchmark Baseline -Make ONE change. After validating with benchmarks (Phase 4), commit using the template in `assets/commit-template.txt`: +Use `cargo criterion` for micro-benchmarks. ```bash -# Example: -git commit -m "opt: buffer reuse in syslog serialization +cargo criterion 2>&1 | tee /tmp/criterion-baseline.log +``` -Replaced per-iteration format!() with reusable Vec buffer. +**Note:** Criterion stores baseline data automatically for later comparison. -Target: lading_payload/src/syslog.rs::Syslog5424::to_bytes -Technique: buffer-reuse +### Stage 2: Macro-benchmark Baseline -Micro-benchmarks: - syslog_100MiB: +42.0% throughput (481 -> 683 MiB/s) +Choose a config file that exercises your target code path: -Macro-benchmarks (payloadtool): - Time: -14.5% (8.3 ms -> 7.1 ms) - Memory: -35.8% (6.17 MiB -> 3.96 MiB) - Allocations: -49.3% (67,688 -> 34,331) +```bash +# Common configs: ci/fingerprints/{json,syslog,dogstatsd}/lading.yaml +CONFIG=ci/fingerprints/json/lading.yaml +cargo build --release --bin payloadtool +hyperfine --warmup 3 --runs 10 --export-json /tmp/baseline.json \ + "./target/release/payloadtool $CONFIG" -Co-Authored-By: Claude Sonnet 4.5 -" +./target/release/payloadtool "$CONFIG" --memory-stats 2>&1 | tee /tmp/baseline-mem.txt ``` -**Note:** -- First line must be ≤50 characters (Git best practice) -- Replace `{MODEL}` with the actual Claude model being used (e.g., "Claude Sonnet 4.5", "Claude Opus 4.5"). +**Baseline captured. Now proceed to implementation.** --- -## Phase 4: Benchmark - -**Two-stage gate: micro THEN macro. Both must show improvement.** +## Phase 4: Implement -### CRITICAL: Use Separate Worktree for Baseline +Make ONE change. Keep it focused and minimal. -**NEVER use `git stash`/`git checkout` to switch between baseline and optimized.** This causes confusion and errors. Instead, use a separate git worktree: +Before proceeding, ALL changes must pass: ```bash -# One-time setup: create a baseline worktree (do this once per repo) -git worktree add ../lading-baseline main - -# The baseline worktree is at ../lading-baseline -# Your optimization work stays in the current directory +ci/validate ``` +**No exceptions. If ci/validate fails, fix the issue before continuing.** + +--- + +## Phase 5: Re-benchmark and Compare + +**Two-stage gate: micro THEN macro. Both must show improvement.** + ### Stage 1: Micro-benchmarks (inner loops) -Use `cargo criterion` for micro-benchmarks. Run in each worktree and compare output: +Re-run the same criterion benchmarks with your changes: ```bash -# In baseline worktree (../lading-baseline) -cd ../lading-baseline -cargo criterion 2>&1 | tee /tmp/criterion-baseline.log - -# In optimization worktree (your current directory) -cd /path/to/your/optimization/branch cargo criterion 2>&1 | tee /tmp/criterion-optimized.log - -# Compare results manually - look for "change:" lines showing improvement/regression -# Example output: "time: [1.2345 ms 1.2456 ms 1.2567 ms] change: [-5.1234% -4.5678% -4.0123%]" ``` -**Note:** Criterion automatically compares against the last run in that worktree and reports percentage changes. +Note: Criterion automatically compares against the last run and reports percentage changes. + +Compare results manually - look for "change:" lines showing improvement/regression + +Example output looks like: `time: [1.2345 ms 1.2456 ms 1.2567 ms] change: [-5.1234% -4.5678% -4.0123%]` #### Micro Decision Point | Result | Action | |--------|--------| | Time improved >=5% | Proceed to Stage 2 | -| No change or regression | Record FAILURE, next target | - -**If micro-benchmark shows no improvement, STOP. Move to next target.** +| No change or regression | Process to Phase 8 and record FAILURE | ### Stage 2: Macro-benchmarks (end-to-end payloadtool) -Only run this if Stage 1 showed improvement. +Only run this if Stage 1 showed improvement. Use the SAME config as baseline: ```bash -# Choose a config file (e.g., ci/fingerprints/json/lading.yaml) +# Use same CONFIG as Phase 3 CONFIG=ci/fingerprints/json/lading.yaml - -# In baseline worktree -cd ../lading-baseline -cargo build --release --bin payloadtool -hyperfine --warmup 3 --export-json /tmp/baseline.json \ - "./target/release/payloadtool $CONFIG" -./target/release/payloadtool "$CONFIG" --memory-stats 2>&1 | tee /tmp/baseline-mem.txt - -# In optimization worktree -cd /path/to/your/optimization/branch cargo build --release --bin payloadtool hyperfine --warmup 3 --export-json /tmp/optimized.json \ "./target/release/payloadtool $CONFIG" @@ -194,21 +175,21 @@ hyperfine --warmup 3 --export-json /tmp/optimized.json \ | Result | Action | |--------|--------| -| Time improved >=5% | Proceed to `/lading-optimize-review` | -| Memory reduced >=10% | Proceed to `/lading-optimize-review` | -| Allocations reduced >=20% | Proceed to `/lading-optimize-review` | -| No change or regression | Record FAILURE (micro win, macro loss), next target | +| Time improved >=5% | Proceed to Phase 6 | +| Memory reduced >=10% | Proceed to Phase 6 | +| Allocations reduced >=20% | Proceed to Phase 6 | +| No change or regression | Process to Phase 8 and record FAILURE (micro win, macro loss) | | **ci/validate fails** | Might be a **BUG** | | **Determinism broken** | Might be a **BUG** | -**All three gates must pass to proceed to review:** +**All three gates must pass to proceed:** 1. Micro-benchmark shows improvement (>=5% time) 2. Macro-benchmark shows improvement (>=5% time OR >=10% memory OR >=20% allocations) 3. ci/validate passes (correctness preserved) --- -## Phase 5: Handle Bug Discovery +## Phase 6: Handle Bug Discovery If during hunting you discover a bug (not an optimization): @@ -225,36 +206,19 @@ This skill will: ### After Validation -Return here and record as BUG_FOUND in Phase 7, then **continue hunting** - don't stop. +Return here and record as BUG_FOUND in Phase 8, then **continue hunting** - don't stop. --- -## Phase 6: Validate (MANDATORY) +## Phase 7: Review -Before proceeding to review, ALL changes must pass: +Invoke the review process: `/lading-optimize-review` -```bash -ci/validate -``` - -**No exceptions. If ci/validate fails, fix the issue before continuing.** - -### Kani Proofs (When Touching Critical Code) - -If your optimization touches `lading_throttle` or `lading_payload`: - -```bash -ci/kani lading_throttle # If throttle was modified -ci/kani lading_payload # If payload was modified -``` - -Kani is slow and may not compile complex code. If it fails: -1. Document why Kani couldn't run -2. Ensure comprehensive property tests exist instead +**Only consider this a valid optimization if the review passes.** --- -## Phase 7: Record & Continue +## Phase 8: Record the results ### MANDATORY: Update db.yaml @@ -276,7 +240,6 @@ target: technique: status: success date: -branch: measurements: time: <-X% or ~> memory: <-X% or ~> @@ -308,12 +271,6 @@ lessons: | ``` -### Immediately Continue - -``` -Target completed -> Back to Phase 1 -> Pick new target -> Never stop -``` - --- ## Usage diff --git a/.claude/skills/lading-optimize-hunt/assets/db/cache-inline.yaml b/.claude/skills/lading-optimize-hunt/assets/db/cache-inline.yaml index 35f62fe2f..a2baa3179 100644 --- a/.claude/skills/lading-optimize-hunt/assets/db/cache-inline.yaml +++ b/.claude/skills/lading-optimize-hunt/assets/db/cache-inline.yaml @@ -2,7 +2,6 @@ target: lading_payload/src/block.rs:Cache methods technique: inline status: success date: 2026-01-20 -branch: opt/payload-cache-inline measurements: time: -7.2% memory: ~ diff --git a/.claude/skills/lading-optimize-hunt/assets/db/datadog-logs-buffer-reuse.yaml b/.claude/skills/lading-optimize-hunt/assets/db/datadog-logs-buffer-reuse.yaml index 38eb9514b..b0e35e88c 100644 --- a/.claude/skills/lading-optimize-hunt/assets/db/datadog-logs-buffer-reuse.yaml +++ b/.claude/skills/lading-optimize-hunt/assets/db/datadog-logs-buffer-reuse.yaml @@ -2,8 +2,6 @@ target: lading_payload/src/datadog_logs.rs::DatadogLog::to_bytes technique: buffer-reuse status: success date: 2026-01-21 -branch: opt/datadog-logs-buffer-reuse -commit: 1ffd10f measurements: micro: datadog_logs_100MiB_time: +5.41% diff --git a/.claude/skills/lading-optimize-hunt/assets/db/dogstatsd-buffer-reuse.yaml b/.claude/skills/lading-optimize-hunt/assets/db/dogstatsd-buffer-reuse.yaml index 53d00c2d8..995210eb2 100644 --- a/.claude/skills/lading-optimize-hunt/assets/db/dogstatsd-buffer-reuse.yaml +++ b/.claude/skills/lading-optimize-hunt/assets/db/dogstatsd-buffer-reuse.yaml @@ -2,7 +2,6 @@ target: dogstatsd.rs:to_bytes_unframed,to_bytes_length_prefix_framed technique: buffer-reuse status: success date: 2026-01-14 -branch: opt/dogstatsd-buffer-reuse measurements: micro_benchmarks: dogstatsd_all_1MiB: "-3% time" diff --git a/.claude/skills/lading-optimize-hunt/assets/db/fluent-on-demand-serialization.yaml b/.claude/skills/lading-optimize-hunt/assets/db/fluent-on-demand-serialization.yaml index 26bc84ee7..0f56b633a 100644 --- a/.claude/skills/lading-optimize-hunt/assets/db/fluent-on-demand-serialization.yaml +++ b/.claude/skills/lading-optimize-hunt/assets/db/fluent-on-demand-serialization.yaml @@ -2,9 +2,6 @@ target: lading_payload/src/fluent.rs::to_bytes technique: on-demand-serialization status: success date: 2026-01-22 -branch: opt/fluent-on-demand-serialization -commit: a14a569 - measurements: micro_benchmarks: - size: 1 MiB diff --git a/.claude/skills/lading-optimize-hunt/assets/db/syslog-to_bytes-reusable-buffer.yaml b/.claude/skills/lading-optimize-hunt/assets/db/syslog-to_bytes-reusable-buffer.yaml index 561772f2c..acbdc0a27 100644 --- a/.claude/skills/lading-optimize-hunt/assets/db/syslog-to_bytes-reusable-buffer.yaml +++ b/.claude/skills/lading-optimize-hunt/assets/db/syslog-to_bytes-reusable-buffer.yaml @@ -2,9 +2,6 @@ target: lading_payload/src/syslog.rs::Syslog5424::to_bytes technique: reusable-buffer-eliminate-allocations status: success date: 2026-01-15 -branch: opt/syslog-eliminate-allocations -commit: d90086c - measurements: micro_benchmarks: - size: 1 MiB diff --git a/.claude/skills/lading-optimize-rescue/SKILL.md b/.claude/skills/lading-optimize-rescue/SKILL.md index 1739cb2b6..63cc635bd 100644 --- a/.claude/skills/lading-optimize-rescue/SKILL.md +++ b/.claude/skills/lading-optimize-rescue/SKILL.md @@ -11,7 +11,7 @@ Salvage optimization work done without proper benchmarks. Generate evidence, val | Outcome | Value | Action | |---------|-------|--------| -| **Change validated** | Real improvement proven | KEEP, include in rescued branch | +| **Change validated** | Real improvement proven | KEEP in working directory | | **Change invalidated** | No improvement | DISCARD, record lesson | | **Bug discovered** | Correctness issue found | Invoke `/lading-optimize-validate` | @@ -27,11 +27,7 @@ Run `/lading-preflight` first. ## Phase 1: Audit -```bash -git diff --name-only origin/main...HEAD | grep '\.rs$' -``` - -For each change, categorize: +Examine the changes in your working directory. Identify all modified files and categorize each change: - Preallocation (`Vec::with_capacity`, `String::with_capacity`) - Avoiding clones (borrowing instead of owned) - Moving allocations out of loops @@ -64,17 +60,9 @@ For each change, categorize: ## Phase 3: Generate Evidence -### CRITICAL: Use Separate Worktree for Baseline - -**NEVER use `git stash`/`git checkout` to switch between baseline and optimized.** This causes confusion and errors. Instead, use a separate git worktree: - -```bash -# One-time setup: create a baseline worktree (do this once per repo) -git worktree add ../lading-baseline main +### Establish Baseline for Comparison -# The baseline worktree is at ../lading-baseline -# Your optimization work stays in the current directory -``` +**Baseline must be from unmodified code.** You'll need to capture baseline metrics before your changes, then measure again with your changes applied. ### For payloadtool (end-to-end): @@ -82,15 +70,13 @@ git worktree add ../lading-baseline main # Choose a config file (e.g., ci/fingerprints/json/lading.yaml) CONFIG=ci/fingerprints/json/lading.yaml -# In baseline worktree -cd ../lading-baseline +# Baseline (without changes) cargo build --release --bin payloadtool hyperfine --warmup 3 --runs 30 --export-json /tmp/baseline.json \ "./target/release/payloadtool $CONFIG" ./target/release/payloadtool "$CONFIG" --memory-stats 2>&1 | tee /tmp/baseline-mem.txt -# In optimization worktree -cd /path/to/your/optimization/branch +# With changes applied cargo build --release --bin payloadtool hyperfine --warmup 3 --runs 30 --export-json /tmp/optimized.json \ "./target/release/payloadtool $CONFIG" @@ -99,21 +85,19 @@ hyperfine --warmup 3 --runs 30 --export-json /tmp/optimized.json \ ### For inner loops (criterion): -Use `cargo criterion` for micro-benchmarks. Run in each worktree and compare output: +Use `cargo criterion` for micro-benchmarks. Run before and after changes: ```bash -# In baseline worktree -cd ../lading-baseline +# Baseline (without changes) cargo criterion 2>&1 | tee /tmp/criterion-baseline.log -# In optimization worktree -cd /path/to/your/optimization/branch +# With changes applied cargo criterion 2>&1 | tee /tmp/criterion-optimized.log # Compare results manually - look for "change:" lines showing improvement/regression ``` -**Note:** Criterion automatically compares against the last run in that worktree and reports percentage changes. +**Note:** Criterion automatically compares against the previous run and reports percentage changes. ### Create Benchmarks If Missing @@ -182,22 +166,17 @@ If rescue uncovers a bug instead of an optimization: After validation: 1. Bug recorded in validate's assets/db.yaml (via /lading-optimize-validate) 2. Record rescue as BUG_FOUND in Phase 7 -3. The bug fix becomes part of rescued branch (with tests!) +3. The bug fix remains in working directory (with tests!) --- ## Phase 6: Reconstruct -```bash -git checkout main -git checkout -b opt/-rescued -``` - -Apply only: +Keep only: - **KEEP** changes (validated optimizations with benchmark proof) - **BUG_FOUND** changes (with tests from /lading-optimize-validate) -Discard everything else. +Discard everything else from your working directory. ### Mandatory Before Finishing @@ -205,7 +184,7 @@ Discard everything else. ci/validate ``` -**No exceptions. Rescued branch must pass ci/validate.** +**No exceptions. Rescued changes must pass ci/validate.** --- @@ -219,16 +198,14 @@ ci/validate **assets/db.yaml entry:** ```yaml entries: - - original_branch: - rescued_as: + - id: status: - file: assets/db/.yaml + file: assets/db/.yaml ``` -**assets/db/.yaml:** +**assets/db/.yaml:** ```yaml -original_branch: -rescued_as: +id: date: statistics: audited: diff --git a/.claude/skills/lading-optimize-review/SKILL.md b/.claude/skills/lading-optimize-review/SKILL.md index 3056ff548..e3f582f43 100644 --- a/.claude/skills/lading-optimize-review/SKILL.md +++ b/.claude/skills/lading-optimize-review/SKILL.md @@ -36,7 +36,7 @@ cat .claude/skills/lading-optimize-hunt/assets/db.yaml ``` **Check for:** -- Same branch name already reviewed -> REJECT as "DUPLICATE" +- Same optimization already reviewed -> REJECT as "DUPLICATE" - Same file + technique already approved -> REJECT as "DUPLICATE" --- @@ -55,56 +55,28 @@ ci/validate ## Phase 2: Measurement -### CRITICAL: Use Separate Worktree for Baseline +**Review existing benchmark data.** The optimization should already have benchmark results. If missing, request them or REJECT. -**NEVER use `git checkout` to switch between baseline and optimized.** This causes confusion and errors. Instead, use a separate git worktree: +**The optimization being reviewed MUST provide benchmark data.** Review should focus on analyzing existing data, not generating new benchmarks. -```bash -# One-time setup: create a baseline worktree (do this once per repo) -git worktree add ../lading-baseline main - -# The baseline worktree is at ../lading-baseline -# Your optimization work stays in the current directory -``` - -### For payloadtool (end-to-end): - -```bash -# Choose a config file (e.g., ci/fingerprints/json/lading.yaml) -CONFIG=ci/fingerprints/json/lading.yaml - -# In baseline worktree -cd ../lading-baseline -cargo build --release --bin payloadtool -hyperfine --warmup 3 --runs 30 --export-json /tmp/old.json \ - "./target/release/payloadtool $CONFIG" -./target/release/payloadtool "$CONFIG" --memory-stats 2>&1 | tee /tmp/old-mem.txt - -# In optimization worktree -cd /path/to/your/optimization/branch -cargo build --release --bin payloadtool -hyperfine --warmup 3 --runs 30 --export-json /tmp/new.json \ - "./target/release/payloadtool $CONFIG" -./target/release/payloadtool "$CONFIG" --memory-stats 2>&1 | tee /tmp/new-mem.txt -``` - -### For inner loops (criterion): - -Use `cargo criterion` for micro-benchmarks. Run in each worktree and compare output: +### Expected Benchmark Data -```bash -# In baseline worktree -cd ../lading-baseline -cargo criterion 2>&1 | tee /tmp/criterion-baseline.log - -# In optimization worktree -cd /path/to/your/optimization/branch -cargo criterion 2>&1 | tee /tmp/criterion-optimized.log +The optimization should include: -# Compare results manually - look for "change:" lines showing improvement/regression -``` +**Micro-benchmarks (criterion):** +- Benchmark name and throughput change +- Example: `syslog_100MiB: +42.0% throughput (481 -> 683 MiB/s)` -**Note:** Criterion automatically compares against the last run in that worktree and reports percentage changes. +**Macro-benchmarks (payloadtool with hyperfine):** +- Time change with absolute values +- Memory change with absolute values +- Allocation count change with absolute values +- Example: + ``` + Time: -14.5% (8.3 ms -> 7.1 ms) + Memory: -35.8% (6.17 MiB -> 3.96 MiB) + Allocations: -49.3% (67,688 -> 34,331) + ``` ### Statistical Requirements - Minimum 30 runs for hyperfine (`--runs 30`) @@ -127,10 +99,10 @@ cargo criterion 2>&1 | tee /tmp/criterion-optimized.log ## Phase 3: Five-Persona Review ### 1. Duplicate Hunter (Checks for Redundant Work) -- [ ] Branch not already in reviews.yaml +- [ ] Optimization not already in reviews.yaml - [ ] File + technique combo not already approved - [ ] No substantially similar optimization exists -- [ ] If duplicate found -> REJECT with "DUPLICATE: see " +- [ ] If duplicate found -> REJECT with "DUPLICATE: see " ### 2. Skeptic (Demands Proof) - [ ] Hot path verified via profiling (not just guessed) @@ -193,9 +165,9 @@ ci/kani lading_payload | Outcome | Votes | Action | |---------|-------|--------| -| **APPROVED** | 5/5 APPROVE | Merge, record success | -| **REJECTED** | Any REJECT | Record lesson, delete branch | -| **DUPLICATE** | Duplicate Hunter REJECT | Record as DUPLICATE, delete branch | +| **APPROVED** | 5/5 APPROVE | Record success | +| **REJECTED** | Any REJECT | Record lesson | +| **DUPLICATE** | Duplicate Hunter REJECT | Record as DUPLICATE | | **BUG FOUND** | Correctness issue | Invoke `/lading-optimize-validate` | ### When Bug Is Found @@ -226,14 +198,16 @@ Then return here to record the finding as BUG_FOUND in Phase 6. **assets/db.yaml entry:** ```yaml entries: - - branch: + - id: verdict: - file: assets/db/.yaml + file: assets/db/.yaml ``` -**assets/db/.yaml** for APPROVED: +**assets/db/.yaml** for APPROVED: ```yaml -branch: +id: +target: +technique: verdict: approved date: votes: @@ -252,9 +226,11 @@ lessons: | ``` -**assets/db/.yaml** for REJECTED: +**assets/db/.yaml** for REJECTED: ```yaml -branch: +id: +target: +technique: verdict: rejected date: votes: @@ -269,19 +245,22 @@ lessons: | ``` -**assets/db/.yaml** for DUPLICATE: +**assets/db/.yaml** for DUPLICATE: ```yaml -branch: +id: +target: +technique: verdict: duplicate date: -duplicate_of: +duplicate_of: reason: | ``` -**assets/db/.yaml** for BUG_FOUND: +**assets/db/.yaml** for BUG_FOUND: ```yaml -branch: +id: +target: verdict: bug_found date: validation_file: diff --git a/.claude/skills/lading-optimize-review/assets/db.yaml b/.claude/skills/lading-optimize-review/assets/db.yaml index 47b4d4812..c4b6256e3 100644 --- a/.claude/skills/lading-optimize-review/assets/db.yaml +++ b/.claude/skills/lading-optimize-review/assets/db.yaml @@ -1,7 +1,7 @@ entries: - - branch: opt/fluent-on-demand-serialization + - id: fluent-on-demand-serialization verdict: approved file: assets/db/opt-fluent-on-demand-serialization.yaml - - branch: opt/payload-cache-inline + - id: payload-cache-inline verdict: approved file: assets/db/opt-payload-cache-inline.yaml diff --git a/.claude/skills/lading-optimize-review/assets/db/opt-fluent-on-demand-serialization.yaml b/.claude/skills/lading-optimize-review/assets/db/opt-fluent-on-demand-serialization.yaml index 51e250719..ae337afdc 100644 --- a/.claude/skills/lading-optimize-review/assets/db/opt-fluent-on-demand-serialization.yaml +++ b/.claude/skills/lading-optimize-review/assets/db/opt-fluent-on-demand-serialization.yaml @@ -1,7 +1,6 @@ -branch: opt/fluent-on-demand-serialization +id: fluent-on-demand-serialization verdict: approved date: 2026-01-22 -commit: a14a569 target: lading_payload/src/fluent.rs::to_bytes technique: on-demand-serialization diff --git a/.claude/skills/lading-optimize-review/assets/db/opt-payload-cache-inline.yaml b/.claude/skills/lading-optimize-review/assets/db/opt-payload-cache-inline.yaml index ad8141c38..f744a7b14 100644 --- a/.claude/skills/lading-optimize-review/assets/db/opt-payload-cache-inline.yaml +++ b/.claude/skills/lading-optimize-review/assets/db/opt-payload-cache-inline.yaml @@ -1,6 +1,8 @@ -branch: opt/payload-cache-inline +id: payload-cache-inline verdict: approved date: 2026-01-20 +target: lading_payload/src/block.rs:Cache methods +technique: inline votes: duplicate_hunter: approve skeptic: approve diff --git a/.claude/skills/lading-optimize-submit/SKILL.md b/.claude/skills/lading-optimize-submit/SKILL.md new file mode 100644 index 000000000..18b109883 --- /dev/null +++ b/.claude/skills/lading-optimize-submit/SKILL.md @@ -0,0 +1,133 @@ +--- +name: lading-optimize-submit +description: Full optimization workflow with git branch creation, commits, and optional PR. Wraps /lading-optimize-hunt with git automation. +--- + +# Optimization Submit Workflow + +**Complete optimization workflow with git automation.** This skill wraps `/lading-optimize-hunt` and handles: +- Git branch creation +- Baseline benchmarking +- Code changes +- Re-benchmarking with changes +- Git commit with formatted results +- Optional push and PR creation + +--- + +## Phase 0: Pre-flight + +Run `/lading-preflight` first to ensure environment is ready. + +--- + +## Phase 1: Prepare Git Environment + +```bash +# Ensure clean state on main +git checkout main && git pull + +# Verify clean working directory +git status +``` + +**STOP if working directory is dirty.** Commit or stash changes before proceeding. + +--- + +## Phase 2: Hunt + +Run `/lading-optimize-hunt`. + +--- + +## Phase 3: Create Optimization Branch + +Create a new branch and add the changes. +```bash +# Create descriptive branch name +# Format: opt/- +# Examples: +# opt/payload-cache-prealloc +# opt/throttle-avoid-clone +# opt/syslog-buffer-reuse + +git checkout -b opt/- +git add . +``` + +Using the template in `assets/commit-template.txt`, commit the changes: + +```bash +# Example: +git commit -m "opt: buffer reuse in syslog serialization + +Replaced per-iteration format!() with reusable Vec buffer. + +Target: lading_payload/src/syslog.rs::Syslog5424::to_bytes +Technique: buffer-reuse + +Micro-benchmarks: + syslog_100MiB: +42.0% throughput (481 -> 683 MiB/s) + +Macro-benchmarks (payloadtool): + Time: -14.5% (8.3 ms -> 7.1 ms) + Memory: -35.8% (6.17 MiB -> 3.96 MiB) + Allocations: -49.3% (67,688 -> 34,331) + +Co-Authored-By: Claude Sonnet 4.5 +" +``` + +**Note:** +- First line must be ≤50 characters (Git best practice) +- Replace {MODEL} with the actual Claude model being used (e.g., "Claude Sonnet 4.5", "Claude Opus 4.5"). + +--- + +## Phase 4: Push and Create PR (Optional) + +```bash +# Push branch to remote +git push -u origin opt/- + +# Create PR using gh CLI +gh pr create \ + --title "opt: " \ + --body "$(cat <<'EOF' +## Summary + + +## Benchmark Results + +### Micro-benchmarks +- : + +### Macro-benchmarks (payloadtool) +- Time: <-X%> ( ms -> ms) +- Memory: <-X%> ( MiB -> MiB) +- Allocations: <-X%> ( -> ) + +## Validation +- [x] ci/validate passes +- [x] Kani proofs pass (or N/A: ) +- [x] Determinism verified + +Ready for `/lading-optimize-review`. + +🤖 Generated with [Claude Code](https://claude.com/claude-code) +EOF +)" +``` + +--- + +## Usage + +``` +/lading-optimize-submit +``` + +**This skill provides the full git workflow. Use `/lading-optimize-hunt` if you want manual control over git operations.** + +--- diff --git a/.claude/skills/lading-optimize-hunt/assets/commit-template.txt b/.claude/skills/lading-optimize-submit/assets/commit-template.txt similarity index 100% rename from .claude/skills/lading-optimize-hunt/assets/commit-template.txt rename to .claude/skills/lading-optimize-submit/assets/commit-template.txt diff --git a/.claude/skills/lading-optimize-validate/SKILL.md b/.claude/skills/lading-optimize-validate/SKILL.md index 45a900e60..b3e9a5452 100644 --- a/.claude/skills/lading-optimize-validate/SKILL.md +++ b/.claude/skills/lading-optimize-validate/SKILL.md @@ -187,17 +187,11 @@ capacity_at_least_requested ### 3.3 Verify Test Fails Before Fix -```bash -# Checkout code BEFORE fix -git stash -git checkout origin/main +**Important:** Ensure the test fails on buggy code before applying the fix. You may need to temporarily revert your fix to verify. -# Run the new test - MUST FAIL +```bash +# Run the new test - should FAIL on buggy code ci/test - -# Return to fix branch -git checkout - -git stash pop ``` **If test passes on buggy code, the test doesn't reproduce the bug. Rewrite it.** @@ -209,7 +203,6 @@ git stash pop ### 4.1 Verify Test Passes After Fix ```bash -# On the fix branch ci/test ``` @@ -244,27 +237,7 @@ diff /tmp/run1.txt /tmp/run2.txt # Must be identical ## Phase 5: Document and Record -### 5.1 Commit Message Format - -```bash -git commit -m "$(cat <<'EOF' -fix(lading_payload): correct off-by-one in capacity calculation - -Bug: calculate_capacity returned size-1 instead of size -Fix: Changed < to <= in boundary check - -Test: Property test output_length_equals_requested fails before, passes after -Kani: Proof capacity_never_underflows added (or: Kani not feasible - timeout) - -Discovered-by: /lading-optimize-hunt -Validated-by: /lading-optimize-validate - -Co-Authored-By: Claude Opus 4.5 -EOF -)" -``` - -### 5.2 MANDATORY: Update db.yaml +### MANDATORY: Update db.yaml 1. Add entry to `assets/db.yaml` index 2. Create detailed file in `assets/db/` directory @@ -285,7 +258,6 @@ file: function: category: discovered_by: -original_branch: date: bug_description: |