1. Semver gate before merging shared client code
Use case. A shared SDK can be used by hundreds of downstream services. A breaking schema change must force a major bump, not auto-derive from commit tags, so release automation never publishes an incompatible minor.
# breaking_changes is a list from RFC/contract analyzer.
function bump_decision(breaking_count, additive_count) {
if breaking_count > 0 {
return {"bump": "major", "reason": "BREAKING_CONTRACT"}
}
if additive_count > 0 {
return {"bump": "minor", "reason": "BACKWARD_COMPATIBLE_FEATURE"}
}
return {"bump": "patch", "reason": "NO_API_CHANGE"}
}
print "BUMP={bump_decision(1, 3).bump}"
Save as developer-productivity_01.pea; check pea fmt --check developer-productivity_01.pea && pea check developer-productivity_01.pea; run pea run developer-productivity_01.pea.
2. Flaky test quarantine after repeated failure
Use case. A flaky service test fails 1 in 5 runs and blocks every PR. Quarantine only after enough inconsistent signals, and keep it out of the release gate until a dedicated fix raises its pass rate.
# host returns {passes, failures} for last 20 CI shards.
const MIN_RUNS = 10
const FLAKY_FLOOR = 0.8
function should_quarantine(passes, failures) {
let total = passes + failures
if total < MIN_RUNS {
return {"action": "MONITOR", "reason": "INSUFFICIENT_RUNS"}
}
let pass_rate = passes / total
if pass_rate < FLAKY_FLOOR {
return {"action": "QUARANTINE", "reason": "FLAKY", "pass_rate": pass_rate}
}
return {"action": "KEEP_GATE", "reason": "STABLE", "pass_rate": pass_rate}
}
print "FLAKY={should_quarantine(14, 6).action}"
Save as developer-productivity_02.pea; check pea fmt --check developer-productivity_02.pea && pea check developer-productivity_02.pea; run pea run developer-productivity_02.pea.
3. CI cache key determinism guard
Use case. A wrong cache key restores stale dependencies and compiles the wrong world. Reject ambiguous keys up front so cache hits only happen on identical lockfile, toolchain and OS tuple.
# key parts are strings already normalised by CI.
function cache_status(lockfile_hash, toolchain, os_name) {
if lockfile_hash == "" or toolchain == "" or os_name == "" {
return {"hit": false, "reason": "INCOMPLETE_KEY"}
}
return {"hit": true, "reason": "EXACT_MATCH", "key": lockfile_hash + ":" + toolchain + ":" + os_name}
}
print "CACHE={cache_status("sha-a1b2c3", "node-20.11", "linux-x64").reason}"
Save as developer-productivity_03.pea; check pea fmt --check developer-productivity_03.pea && pea check developer-productivity_03.pea; run pea run developer-productivity_03.pea.
4. Dependency CVE policy for CI supply chain
Use case. A build must not silently ship a vulnerable transitive dependency. Classify CVEs into fail/warn/ignore based on reachability, exploit maturity and fix availability.
# reachability and exploit are host-classified.
const BLOCKING = ["RCE", "AUTH_BYPASS", "PRIV_ESC"]
function cve_gate(cvss, reachability, exploit_known) {
if reachability == "REACHABLE" and exploit_known {
return {"action": "BLOCK", "reason": "ACTIVE_EXPLOIT"}
}
if cvss >= 9.0 {
return {"action": "BLOCK", "reason": "CRITICAL"}
}
if cvss >= 7.0 {
return {"action": "WARN", "reason": "HIGH_REVIEW"}
}
return {"action": "ACCEPT", "reason": "LOW_RISK"}
}
print "CVE={cve_gate(9.8, "REACHABLE", true).action}"
Save as developer-productivity_04.pea; check pea fmt --check developer-productivity_04.pea && pea check developer-productivity_04.pea; run pea run developer-productivity_04.pea.
5. CODEOWNERS critical path review router
Use case. Changes around payments require billing engineering review, not just any senior engineer. Route automatically from path and migration class so rubber-stamping cannot bypass ownership.
# path globs evaluated by host; migration_type short-circuits.
const CRITICAL = ["payments/", "billing/", "ledger/"]
let path = "payments/charge.ts"
let reviewer = "default-owner"
let i = 0
while i < len(CRITICAL) {
if CRITICAL[i] in path { reviewer = "payments-reviewers" }
i += 1
}
print "REVIEWER={reviewer}"
Save as developer-productivity_05.pea; check pea fmt --check developer-productivity_05.pea && pea check developer-productivity_05.pea; run pea run developer-productivity_05.pea.
6. Flaky environment teardown quarantine
Use case. Preview environments that cannot be torn down cost real money and leak source. Kill them after lease expiry and unresolved health checks, and report owner rather than silently reaping in-use previews.
# age_minutes and healthy are host-observed.
const TTL_MIN = 1440
function cleanup_decision(age_minutes, healthy, has_open_prs) {
if has_open_prs and healthy {
return {"action": "KEEP", "reason": "ACTIVE"}
}
if age_minutes > TTL_MIN {
return {"action": "DELETE", "reason": "EXPIRED"}
}
return {"action": "MONITOR", "reason": "WITHIN_TTL"}
}
print "PREVIEW={cleanup_decision(1600, false, false).action}"
Save as developer-productivity_06.pea; check pea fmt --check developer-productivity_06.pea && pea check developer-productivity_06.pea; run pea run developer-productivity_06.pea.
7. Build farm slot allocation fairness
Use case. One team submits giant monorepo jobs that starve everyone else. Enforce per-team weights and minimum guarantees so capacity is shared predictably instead of first-come-first-served chaos.
# weights are relative share across active teams.
const WEIGHTS = {"core": 50, "platform": 30, "docs": 20}
function slot_weight(team) {
if team in WEIGHTS { return WEIGHTS[team] }
return 5
}
print "WEIGHT={slot_weight("docs")}"
Save as developer-productivity_07.pea; check pea fmt --check developer-productivity_07.pea && pea check developer-productivity_07.pea; run pea run developer-productivity_07.pea.
8. Database migration lint for destructive DDL
Use case. A drop/column rename in staging can still corrupt production if accidentally promoted. Reject migrations that fail backward compatibility unless the release declares a two-phase change with explicit approval.
# operations are strings from parsed migration.
const DESTRUCTIVE = ["DROP_TABLE", "DROP_COLUMN", "RENAME_COLUMN"]
function migration_gate(ops, approved_two_phase) {
let destructive = false
let i = 0
while i < len(ops) {
if ops[i] in DESTRUCTIVE { destructive = true }
i += 1
}
if destructive and not approved_two_phase {
return {"ok": false, "reason": "DESTRUCTIVE_DDL"}
}
return {"ok": true, "reason": "SAFE_OR_APPROVED"}
}
print "MIGRATION={migration_gate(["ADD_COLUMN", "DROP_INDEX"], false).ok}"
Save as developer-productivity_08.pea; check pea fmt --check developer-productivity_08.pea && pea check developer-productivity_08.pea; run pea run developer-productivity_08.pea.
9. Test selection by changed path risk
Use case. Docs edits should not rerun payment chaos tests; payment edits must. Compute a risk tier from changed paths and route to the right test bucket deterministically on every PR.
# changed_paths are already lowercased.
const RISKY = ["payments", "ledger", "auth", "config"]
let sample = ["docs/readme.md", "payments/refund.ts"]
let i = 0
let tier = "fast"
while i < len(sample) {
let j = 0
while j < len(RISKY) {
if RISKY[j] in sample[i] { tier = "critical" }
j += 1
}
i += 1
}
print "TIER={tier}"
Save as developer-productivity_09.pea; check pea fmt --check developer-productivity_09.pea && pea check developer-productivity_09.pea; run pea run developer-productivity_09.pea.
10. Release branch prompt for unreleased dependency changes
Use case. A deploy can be blocked by a new package major version with no lockfile review. Detect when a merged PR touched dependency declarations without an attached compatibility note and block promotion.
# dep_match flags parser hits; note_present from PR body.
function promotion_gate(dep_changed, note_present) {
if not dep_changed {
return {"ok": true, "reason": "NO_DEP_CHANGE"}
}
if note_present {
return {"ok": true, "reason": "NOTE_ATTACHED"}
}
return {"ok": false, "reason": "DEPENDENCY_NEEDS_REVIEW"}
}
print "PROMOTE={promotion_gate(true, false).ok}"
Save as developer-productivity_10.pea; check pea fmt --check developer-productivity_10.pea && pea check developer-productivity_10.pea; run pea run developer-productivity_10.pea.
← Back to the Code Library