Skip to content
Open
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
12 changes: 8 additions & 4 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def greet(name):
# [SEC C START] Math helpers
def add(a, b):
return a + b

def multiply(a, b):
return a * b
# SEC C filler 001
# SEC C filler 002
# SEC C filler 003
Expand Down Expand Up @@ -156,7 +159,8 @@ def compute_version():
# [SEC E END]

# [SEC F START] Flags
FEATURE_X = False
FEATURE_X = True
FEATURE_Y = False
# SEC F filler 001
# SEC F filler 002
# SEC F filler 003
Expand Down Expand Up @@ -190,8 +194,8 @@ def compute_version():
# [SEC F END]

# [SEC G START] IO helpers
def write_file(p, text, mode="w"):
open(p, mode).write(text)
def write_file(p, text):
open(p, "w").write(text)
# SEC G filler 001
# SEC G filler 002
# SEC G filler 003
Expand Down Expand Up @@ -226,7 +230,7 @@ def write_file(p, text, mode="w"):

# [SEC H START] Main
if __name__ == "__main__":
print(greet("MAIN"))
print(greet("world"))
# SEC H filler 001
# SEC H filler 002
# SEC H filler 003
Expand Down
11 changes: 7 additions & 4 deletions handbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ version: 1
- main is protected
- feature branches from main
- rebase before merge
- PRs must reference a ticket
- Merge via squash
<!-- Ch3 filler 001 -->
<!-- Ch3 filler 002 -->
<!-- Ch3 filler 003 -->
Expand Down Expand Up @@ -144,10 +146,10 @@ version: 1
<!-- Ch4 filler 030 -->

# Chapter 5: Release Process
- bump version (semver)
- tag release
- version bump via tool
- tag &amp; sign release
- publish artifacts
- smoke test in staging
- canary 10% for 1h
<!-- Ch5 filler 001 -->
<!-- Ch5 filler 002 -->
<!-- Ch5 filler 003 -->
Expand Down Expand Up @@ -181,6 +183,8 @@ version: 1

# Chapter 6: Incident Response
- SEV1 page immediately
- RCA start within 48h
- Postmortem by end of week
- Initial RCA within 24h
- Full postmortem within 72h
<!-- Ch6 filler 001 -->
Expand Down Expand Up @@ -251,7 +255,6 @@ version: 1
# Chapter 8: FAQ
- Q: Who owns releases? A: Dev Infra
- Q: What’s the SLA? A: 99.9%
- Q: Do we support LTS? A: 12 months
<!-- Ch8 filler 001 -->
<!-- Ch8 filler 002 -->
<!-- Ch8 filler 003 -->
Expand Down
19 changes: 9 additions & 10 deletions pipeline.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

-- [STAGE 1 START] prepare users
CREATE TEMP TABLE t_users AS
-- main adds constraint
-- (simulated) ALTER TABLE t_users ADD PRIMARY KEY (id);
SELECT id, name, active
FROM users
WHERE deleted = false;
Expand Down Expand Up @@ -43,8 +41,8 @@ WHERE deleted = false;
CREATE TEMP TABLE t_active AS
SELECT id, name
FROM t_users
WHERE active = true AND name IS NOT NULL
LIMIT 100;
WHERE active = true AND name <> ''
ORDER BY name;
-- S2 filler 001
-- S2 filler 002
-- S2 filler 003
Expand Down Expand Up @@ -116,9 +114,10 @@ LEFT JOIN purchases p ON p.user_id = a.id;

-- [STAGE 4 START] aggregate revenue
CREATE TEMP TABLE t_rev AS
SELECT id, SUM(amount * 1.05) AS revenue -- main applies uplift
SELECT id, SUM(amount) AS revenue -- feature keeps raw sum
FROM t_join
GROUP BY id;
GROUP BY id
HAVING SUM(amount) > 0; -- feature adds HAVING
-- S4 filler 001
-- S4 filler 002
-- S4 filler 003
Expand Down Expand Up @@ -152,11 +151,11 @@ GROUP BY id;
-- [STAGE 4 END]

-- [STAGE 5 START] write outputs
INSERT INTO reporting.users_daily (id, name, revenue, dt)
SELECT j.id, j.name, r.revenue, CURRENT_DATE
INSERT INTO reporting.users_daily (id, name, revenue, yyyymm)
SELECT j.id, j.name, r.revenue, TO_CHAR(CURRENT_DATE, 'YYYYMM')
FROM t_join j
JOIN t_rev r USING (id);
-- main keeps dt as DATE partition
-- feature writes to yyyymm column instead of dt
-- S5 filler 001
-- S5 filler 002
-- S5 filler 003
Expand Down Expand Up @@ -190,7 +189,7 @@ JOIN t_rev r USING (id);
-- [STAGE 5 END]

-- [STAGE 6 START] finalize
VACUUM ANALYZE;
ANALYZE VERBOSE; -- feature alternative finalization
-- S6 filler 001
-- S6 filler 002
-- S6 filler 003
Expand Down