From cb35cc6ffad190b502b2e987e200ed181f407e48 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 29 Sep 2026 20:04:24 +0000 Subject: [PATCH 1/4] Add temporary coverage review of the topic briefs Lists missing subtopics per brief ranked P1-P3, trim candidates, ownership gaps, and duplicates for manual review. Delete the file before merging. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FADC1PgtXHNSjrM55y3LdW --- coverage-review.md | 575 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 575 insertions(+) create mode 100644 coverage-review.md diff --git a/coverage-review.md b/coverage-review.md new file mode 100644 index 0000000..5975be5 --- /dev/null +++ b/coverage-review.md @@ -0,0 +1,575 @@ +# Brief coverage review + +Temporary working file (2026-09-29): tick the items to act on, then delete this file before merging. Nothing in `docs/` has changed. + +**Legend** + +- **P1**: commonly asked and missing (or only implied). Add first. +- **P2**: comes up in senior or deep-dive rounds. Worth a bullet or a short concept. +- **P3**: niche or role-specific. Add only if it matches the roles you target. +- **new** = new `###` concept in the *section* named · **extend** = add bullets to an existing concept · **cut / merge** = trim candidates. +- Each item carries the proposed facts so it can be judged on its own. Versions and numbers come from memory; re-verify them when writing the prose. +- Where a new concept would push a section past 8 concepts, the item says what to merge or split. + +## Summary + +| Brief | Concepts | Verdict | Biggest gaps (P1) | +|---|---|---|---| +| Algorithms | 35 | Solid core | input-size heuristics, heap patterns, Kadane, random sampling | +| Databases | 39 | Strong PostgreSQL/InnoDB internals | join pitfalls, "why isn't my index used", Redis memory, document stores | +| Distributed Systems | 38 | Strong, at the section limit | delivery guarantees, CDC, monotonic clocks, Kafka partition changes | +| Networking | 22 | Good, smallest brief | failure signatures, TCP loss recovery, routing tables, client IP behind proxies | +| Operating Systems | 28 | Good | process states, atomic file replace, CAS/ABA, memory hierarchy | +| System Design | 37 | Strong; 11 sections | Little's law, percentile/cardinality pitfalls, multi-region/DR, video streaming | +| Go | 32 | Strong runtime; some tooling trivia | JSON gotchas, nil maps, context cancel, work stealing | +| JavaScript | 32 | Good; stdlib listings; 12 sections | async ordering, `fetch` semantics, hidden classes | +| Python | 32 | Strong | spawn/pickling, shared class attributes, numeric gotchas, recursion limit | +| Rust | 33 | Strong; "Unsafe and FFI" has no FFI | overflow and casts, Eq/Ord/Hash, layout/niches, `tokio::spawn` bounds | +| Solidity | 36 | Very thorough; longest file; version trivia | clones, admin keys and governance, ERC-1271 checks, slippage | +| TypeScript | 28 | Good | runtime validation, `{}`/`object`, function assignability | +| Backend | 30 | Good | schema evolution, multi-tenancy, time handling | +| Frontend | 36 | Good | effect data fetching, state snapshots, browser storage, error boundaries | +| Security | 40 | Strong | CORS simple requests, CSPRNG, password reset, resource-exhaustion attacks | +| AWS | 24 | Good, compact | ALB vs NLB, cross-account access, S3/CloudFront access, cost drivers | +| DevOps | 33 | Good | Pod security, `count` vs `for_each`, HPA mechanics, incident response | +| AI Engineering | 38 | Strong on serving and RAG | training pipeline, parallelism and GPU memory, filtered vector search | +| Ethereum | 26 | Good | precompiles, RPC block tags and reorgs, SNARK vs STARK, EIP-7702 risks | + +## Cross-cutting + +### New briefs to consider + +- [ ] **P1 if your loop has a low-level design round**: `ood.md` (Fundamentals). SOLID with one concrete violation each (Square/Rectangle for LSP), composition over inheritance, the GoF patterns interviewers name (strategy, observer, decorator, adapter, factory, builder, state, command, chain of responsibility; singleton pitfalls), dependency injection, the LLD interview flow (use cases → entities → interfaces → state and concurrency), classic prompts (parking lot, elevator, vending machine, expense splitting). +- [ ] P2 if targeting JVM roles: `java.md`. JVM memory areas, G1 vs ZGC (generational ZGC default since JDK 23), JMM (`volatile`, happens-before, safe publication), virtual threads (JDK 21) and pinning (fixed for `synchronized` in JDK 24), `HashMap` internals (treeify at 8), the `equals`/`hashCode` contract. +- [ ] P3: split `devops.md` into `kubernetes.md` + `devops.md` if the Kubernetes additions below push it past 10 sections (Kubernetes is already 4 of 8). +- [ ] P3 if targeting data roles: `data.md`. Batch vs stream (Lambda/Kappa), Spark shuffle and skew, columnar files (Parquet) and table formats (Iceberg, Delta), orchestration and idempotent backfills. +- Not recommended: a separate concurrency brief. It's covered across os, golang, and rust; add CAS/ABA to os.md instead. + +### Ownership gaps + +No file owns these yet; add a row to the AGENTS.md ownership table with each. + +- [ ] Change data capture → distributed (stream processing); referenced from database, system, backend (all three already mention CDC). +- [ ] Little's law and capacity math → system; referenced from os (thread pools) and backend (pool sizing). +- [ ] Monotonic vs wall-clock time → distributed (clocks); referenced from os and golang. +- [ ] Schema evolution and compatibility (Protobuf, Avro, JSON) → backend; referenced from distributed (event schemas). +- [ ] Timestamps and time zones → backend for app rules; database owns `timestamptz` behavior. +- [ ] Disaster recovery tiers → system; aws lists only the AWS services. +- [ ] Browser storage APIs → frontend; security keeps the token-storage guidance. + +### Duplicates + +- [ ] solidity `Oracle integration` bullet 1 repeats ethereum `Oracle manipulation` bullet 1 (owner: ethereum). Keep only the link in solidity. +- [ ] backend `File uploads` bullet 1 repeats system `CDN and object storage` bullet 2 (presigned URLs, metadata only). Keep one. +- [ ] aws `KMS and envelope encryption` bullet 1 re-explains envelope encryption (owner: security). Keep the AWS-specific facts: `GenerateDataKey` and the 4 KB `Encrypt` limit. +- [ ] distributed `Effectively-once processing` would overlap the proposed Delivery guarantees concept. Merge them. + +### Structure + +- [ ] javascript has 12 sections (guide: 5–10), eight with 2 concepts. Merge Scope and closures + `this` and prototypes + Coercion and equality into "Language semantics", and fold Metaprogramming into Recent language additions. +- [ ] system has 11 sections. Fold Rate limiting into Traffic and edge, and Architecture into Reliability and operations. +- [ ] Many sections have only 2 concepts (guide: 3–8). The *new* items below fill several: backend Service calls, devops CI/CD, ai Fine-tuning, ethereum Consensus, rust Unsafe and FFI, typescript Typing patterns, security Supply chain. Merge the rest where they stay thin. +- [ ] Growth budget: the file lists 72 P1, 108 P2, and 51 P3 items. Every P1 + P2 *new* item would add 114 concepts (55 from P1 alone) to today's 619; the cut/merge items remove about 24 whole concepts plus many bullets. Pairing each add with a trim in the same brief keeps skimming and quizzes fast. + +## Fundamentals + +### Algorithms + +Solid on arrays, DP, and graphs. Missing the problem-solving heuristics and a few patterns that come up constantly in coding rounds. + +**Add** + +- [ ] P1 · new · *Complexity and problem solving* › **Input size → target complexity**: at ~10⁸ simple operations per second, n ≤ 10 → O(n!), n ≤ 20 → O(2ⁿ), n ≤ 500 → O(n³), n ≤ 5,000 → O(n²), n ≤ 10⁶ → O(n log n), beyond → O(n) or O(log n). Reading the constraints picks the algorithm. +- [ ] P1 · new · *Data structures* › **Heap patterns**: **k-way merge** of k sorted lists with a size-k min-heap, O(n log k); **two heaps** (max-heap for the lower half, min-heap for the upper) give a running median in O(log n) per insert; lazy deletion for removals. +- [ ] P1 · new · *Arrays and sequences* › **Maximum subarray (Kadane)**: `cur = max(x, cur + x)`, `best = max(best, cur)`, O(n) time and O(1) space; circular variant = max(best, total − minimum subarray) unless every value is negative. The section reaches 8 concepts. +- [ ] P1 · new · *Sorting and selection* (rename "Sorting, selection, and sampling") › **Random sampling and shuffling**: **reservoir sampling** keeps the i-th item with probability k/i (one pass, O(k) memory, unknown stream length); **Fisher–Yates** swaps `a[i]` with `a[rand(0..i)]`; drawing from the whole array at each step is biased. +- [ ] P2 · extend · **Recurrence patterns** with the **Master theorem**: `T(n) = aT(n/b) + f(n)`; compare f(n) with n^(log_b a): smaller → Θ(n^(log_b a)), equal → Θ(n^(log_b a) · log n), larger → Θ(f(n)). Replaces the two worked examples. +- [ ] P2 · extend · **Knapsack and one-dimensional DP**: coin change with coins in the outer loop counts **combinations**; with the amount in the outer loop it counts **permutations**. +- [ ] P2 · extend · **Shortest-path choices** table: 0/1 weights → **0-1 BFS** with a deque, O(V+E); all pairs → **Floyd–Warshall** O(V³) (negative edges fine; a negative diagonal entry means a negative cycle); Dijkstra skips stale heap entries (lazy deletion). +- [ ] P2 · new · *Trees and graphs* › **Cycle detection and bipartiteness**: directed → DFS with three colors (reaching a gray node = back edge = cycle); undirected → a visited neighbor that isn't the parent, or union-find; bipartite ⇔ BFS 2-coloring succeeds ⇔ no odd cycle. +- [ ] P2 · new · *Trees and graphs* › **Grid and multi-source BFS**: a grid is an implicit graph (4 or 8 neighbors), O(rows × cols); seed the queue with every source at distance 0 to get "distance to the nearest X" in one pass. +- [ ] P2 · extend · **Tree traversal and BST ordering**: validate a BST with inherited (min, max) bounds, not parent–child comparisons; lowest common ancestor from post-order return values, or **binary lifting** for O(log n) repeated queries. +- [ ] P2 · extend · **Comparison sorts** with what standard libraries use: Python and Java objects **Timsort** (stable), Java primitives dual-pivot quicksort, C++ `std::sort` introsort (unstable), Go pdqsort (unstable, since 1.19), Rust `sort` driftsort / `sort_unstable` ipnsort (since 1.81), JavaScript stable since ES2019. +- [ ] P2 · extend · **Binary search boundaries**: in a rotated sorted array one half is always sorted; check whether the target lies in it. Duplicates degrade the worst case to O(n). +- [ ] P2 · extend · **Quickselect and top-k**: **3-way partition** (Dutch national flag: `<`, `=`, `>` regions in one pass) keeps quicksort and quickselect fast with many duplicates. +- [ ] P3 · new · *Trees and graphs* › **Strongly connected components**: Tarjan (one DFS with low-links) or Kosaraju (DFS on the graph, then on its reverse), O(V+E); the condensation is a DAG. +- [ ] P3 · new · *Greedy, backtracking, and hardness* › **Number theory toolkit**: Euclid's gcd O(log min(a, b)), fast modular exponentiation O(log e), sieve of Eratosthenes O(n log log n), modular inverse via Fermat when the modulus is prime. +- [ ] P3 · extend · **LRU cache** with LFU in O(1): frequency → doubly linked list of keys, plus a pointer to the minimum frequency. + +**Trim** + +- [ ] cut · **Time and space bounds** bullet 1's opening ("state the input size…"): generic advice. Keep the Ω(k) output-size point. +- [ ] cut · **Recurrence patterns** bullets 1–2: two textbook recurrences, superseded by the Master theorem. +- [ ] cut · **LRU cache** bullet 2: library API listing (low confidence; handy mid-interview). + +### Databases + +Strong on PostgreSQL and InnoDB internals. Weaker on everyday SQL pitfalls, index diagnosis, and non-relational breadth (no document store). + +**Add** + +- [ ] P1 · new · *SQL gotchas* › **Join pitfalls**: a condition on the right table in `WHERE` turns a `LEFT JOIN` into an inner join, so put it in `ON`; joining two one-to-many children multiplies rows and inflates `SUM`/`COUNT` (aggregate each in a subquery first); `EXISTS`/`NOT EXISTS` are semi/anti-joins and never duplicate rows. +- [ ] P1 · new · *Query execution and tuning* › **Why an index isn't used**: low selectivity (the planner prefers a sequential scan when many rows match), leading-wildcard `LIKE '%x'` (needs a trigram GIN index), `LIKE 'x%'` needs C collation or `text_pattern_ops`, implicit casts, `OR` across columns, stale statistics. Scan types: Seq, Index, Index Only, **Bitmap Heap** (combines several indexes). Absorbs **Reading EXPLAIN ANALYZE**. +- [ ] P1 · new · *Non-relational stores* › **Redis eviction, expiry, and messaging**: `maxmemory-policy` defaults to **`noeviction`**, so writes fail when memory is full; caches use `allkeys-lru`/`allkeys-lfu`, while `volatile-*` evicts only keys with a TTL; expired keys are removed lazily on access plus by periodic sampling; pub/sub is fire-and-forget, Streams add persistence, consumer groups, and acks. +- [ ] P1 · new · *Non-relational stores* › **Document stores (MongoDB)**: embed what's read together, reference unbounded or shared data; **16 MB** document limit; write concern `w: "majority"` (default since 5.0), since `w: 1` can lose acknowledged writes on failover; multi-document transactions (4.0 for replica sets, 4.2 sharded) are costly, so design for single-document atomicity. +- [ ] P2 · new · *Transactions and isolation* › **Implementing serializability**: actual serial execution (Redis, VoltDB: one thread, short transactions), **two-phase locking** (readers and writers block each other; MySQL `SERIALIZABLE`, SQL Server), **SSI** (optimistic, aborts on dangerous conflicts; PostgreSQL, CockroachDB). +- [ ] P2 · extend · **Anomalies × isolation levels** table: add lost-update and write-skew columns and a snapshot-isolation row, so PostgreSQL RR vs MySQL RR read off one matrix; then shorten the two engine concepts. +- [ ] P2 · new · *Schema design* › **Timestamps and time zones**: `timestamptz` stores a UTC instant and converts on display; `timestamp` (no zone) silently changes meaning when the session zone changes; `now()` is the transaction start time, `clock_timestamp()` the actual time. App-level rules go in backend. +- [ ] P2 · new · *SQL gotchas* › **Hierarchies and recursive CTEs**: `WITH RECURSIVE` = anchor + recursive term (`UNION`, or the `CYCLE` clause in PostgreSQL 14+, stops cycles); models: adjacency list (simple writes), materialized path/`ltree` (fast subtree reads), closure table (all ancestor pairs; fast reads, heavy writes). +- [ ] P2 · extend · **Physical vs logical replication**: an inactive **replication slot** retains WAL until the disk fills (`max_slot_wal_keep_size`, PostgreSQL 13+); long queries on a hot standby get canceled by replay conflicts unless `hot_standby_feedback` is on, which bloats the primary. +- [ ] P2 · extend · **Surrogate keys**: sequences are non-transactional, so rollbacks leave **gaps** and IDs don't follow commit order; gapless invoice numbers need a counter row updated under a lock. +- [ ] P2 · extend · **Upsert**: `ON CONFLICT DO NOTHING ... RETURNING` returns nothing for existing rows; `MERGE` (PostgreSQL 15+) isn't a concurrency-safe upsert, since concurrent inserts can still raise unique violations. +- [ ] P2 · new · *MVCC and locking* › **Slow COUNT(*)**: PostgreSQL checks each row's visibility, so `COUNT(*)` scans (an index-only scan helps while the visibility map is current); dashboards use `pg_class.reltuples` estimates or a counter table. +- [ ] P2 · new · *Schema design* › **JSONB vs columns**: JSONB for sparse or variable attributes, GIN (`jsonb_path_ops`) for containment queries; no per-key statistics (bad estimates), and updating one key rewrites the whole value, so promote hot keys to columns. +- [ ] P3 · new · *Storage engines and durability* › **Buffer pool vs page cache**: InnoDB's buffer pool takes ~50–80% of RAM with `O_DIRECT`; PostgreSQL's `shared_buffers` ~25%, relying on the OS page cache (double buffering); TOAST stores values over ~2 KB compressed and out of line. +- [ ] P3 · extend · **Write-ahead log**: relaxed durability (`synchronous_commit = off`, `innodb_flush_log_at_trx_commit = 2`) loses the last moments of commits on a crash but never corrupts data. +- [ ] P3 · extend · **PostgreSQL MVCC**: `VACUUM FULL` rewrites the table under `ACCESS EXCLUSIVE`; `pg_repack` rebuilds it online. +- [ ] P3 · extend · **Connection pooling**: prepared statements may switch to a generic plan after five executions (`plan_cache_mode`), which can be far worse for skewed values. + +**Trim** + +- [ ] cut · **Redis persistence and licensing** bullet 3: license history is trivia; at most "Valkey is the drop-in open-source fork". +- [ ] cut · **OLTP vs OLAP** bullet 1: definition-level. Keep the column-store bullet. +- [ ] merge · **InnoDB MVCC** (one bullet) into **MySQL InnoDB isolation**. +- [ ] merge · **Deep pagination cost** (one bullet) into the new index concept; backend owns pagination. +- [ ] merge · **Materialized views** (one bullet) into **OLTP vs OLAP** or the denormalization bullet in **Normalization**. + +### Distributed Systems + +Strong and dense. At the 10-section limit, so additions go inside existing sections. + +**Add** + +- [ ] P1 · new · *Transactions across services* › **Delivery guarantees** (absorbs Effectively-once processing): at-most-once = ack or commit the offset **before** processing; at-least-once = after (a crash between effect and ack redelivers); exactly-once *delivery* is impossible, exactly-once *effect* = at-least-once + idempotent handling, or one transaction covering the effect and the offset. +- [ ] P1 · extend · **Physical clocks and TrueTime**: measure durations, timeouts, and leases with the **monotonic clock** (`CLOCK_MONOTONIC`, Go's `time.Since`, `performance.now()`); wall-clock time jumps on NTP steps, leap-second smearing, and VM migration. +- [ ] P1 · new · *Stream processing* › **Change data capture**: log-based CDC (Debezium) reads the WAL or binlog, so it sees every change in commit order, deletes included, with no dual writes; polling `updated_at` misses deletes and same-timestamp rows; start from a consistent snapshot, then stream from its log position; ordering holds per key. +- [ ] P1 · extend · **Kafka ordering and consumer groups**: adding partitions remaps `hash(key) % partitions` and **breaks per-key ordering** for existing keys, and the count can't be decreased, so size partitions up front; consumer **lag** is the health metric to alert on. +- [ ] P2 · new · *Partitioning* › **Rebalancing partitions**: `hash % N` moves almost every key when N changes; either a **fixed, large number of partitions** moved whole between nodes (Kafka, Elasticsearch, Couchbase) or **dynamic splitting** of large ranges (HBase, MongoDB, CockroachDB, Spanner); automatic rebalancing during a failure can cascade. +- [ ] P2 · new · *Consensus and coordination* › **Coordination services**: ZooKeeper ephemeral nodes and etcd leases vanish with the session, tying membership and locks to liveness; watches notify on change; a lock = sequential node + watching only the predecessor (no herd effect); ZooKeeper reads come from any replica and can be stale (`sync()` first), etcd reads are linearizable by default. +- [ ] P2 · extend · **Raft**: **Pre-Vote** stops a node rejoining after a partition from bumping the term and deposing a healthy leader; typical timing is a ~100 ms heartbeat and ~1 s election timeout (etcd defaults). +- [ ] P2 · new · *Stream processing* › **Exactly-once in stream processors**: Flink injects checkpoint **barriers** (Chandy–Lamport style) and snapshots operator state together with source offsets; end-to-end exactly-once needs a replayable source and a transactional (two-phase commit) or idempotent sink; transactional output becomes visible only when the checkpoint commits. +- [ ] P2 · extend · **Two-phase commit**: when each participant is itself a consensus group (Spanner runs 2PC over Paxos groups), a coordinator crash no longer blocks; XA across heterogeneous systems still does. +- [ ] P3 · extend · **Session guarantees**: consistent prefix reads (writes are seen in the order they happened); breaks when partitions replicate independently. +- [ ] P3 · extend · **Quorums**: `W + R > N` alone isn't linearizable; a concurrent write can be seen by one read and missed by a later one unless readers repair before returning. +- [ ] P3 · extend · **Multi-leader and leaderless**: give each record a **home region** that takes its writes, avoiding conflicts; move the home when a region fails. +- [ ] P3 · new · *Failure handling* › **Metastable failures**: a trigger (spike, cache flush) pushes a system into an overload that retries and timeouts sustain after the trigger is gone; recovery needs explicit load shedding, and retry budgets and bounded queues prevent it. +- [ ] P3 · extend · **Failure detection**: gossip spreads membership and metadata to all N nodes in O(log N) rounds (Cassandra, Serf). + +**Trim** + +- [ ] merge · **Window types** (one bullet) into **Event time and watermarks**; frees a slot in Stream processing for CDC. +- [ ] merge · **Effectively-once processing** into the Delivery guarantees concept above. + +### Networking + +The smallest brief (5 sections, 22 concepts). Good fundamentals, light on troubleshooting and routing. + +**Add** + +- [ ] P1 · new · *End to end* › **Connection failure signatures**: **refused** = RST (host reachable, nothing listening); **timeout** = SYN dropped (firewall, security group, dead host), and Linux retries a SYN for ~**127 s** by default, so set connect timeouts; **reset by peer** mid-stream = the peer crashed or a middlebox hit its idle timeout; a proxy's **502** = upstream refused or reset, **504** = upstream too slow. +- [ ] P1 · new · *TCP* › **Retransmission and loss recovery**: the RTO comes from smoothed RTT, with a Linux floor of **200 ms** (initial 1 s) and doubling per retry, so one lost packet on a quiet connection adds ≥ 200 ms (a classic p99 spike); **fast retransmit** after 3 duplicate ACKs; SACK names exactly which segments are missing. +- [ ] P1 · new · *IP and routing* › **Routing tables**: the most specific route wins (**longest prefix match**: `/32` beats `/24` beats `0.0.0.0/0`); the default route points at the gateway; ARP resolves the next hop's MAC on the local link, so MACs change per hop while IPs stay end to end unless NAT rewrites them. +- [ ] P1 · new · *HTTP versions* (rename "HTTP") › **Client IP behind proxies**: L7 proxies append `X-Forwarded-For`, and clients can forge the earlier entries, so trust only those added by your own proxies (count from the right); L4 load balancers preserve the source IP or pass it with the **PROXY protocol**; rate limits and audit logs depend on getting this right. +- [ ] P2 · new · *TCP* › **Connection states for debugging** (table): SYN_SENT (no SYN-ACK: filtered?), SYN_RECV (half-open: SYN flood?), ESTABLISHED, FIN_WAIT_2 (peer hasn't closed), CLOSE_WAIT (your app hasn't closed), TIME_WAIT (you closed first). Absorbs the CLOSE_WAIT bullet from **Teardown and TIME_WAIT**. +- [ ] P2 · extend · **Handshake and connection queues**: the listen backlog is capped by `net.core.somaxconn` (4096 since Linux 5.4); `SO_REUSEPORT` lets several processes bind one port, each with its own kernel-balanced accept queue (Nginx, Envoy). +- [ ] P2 · extend · **Resolution path**: Kubernetes Pods resolve with `ndots:5`, so an external name with fewer dots first tries every search domain (several wasted lookups per call); use FQDNs with a trailing dot or lower `ndots`. +- [ ] P2 · extend · **NAT**: NAT traversal. STUN learns the public mapping for UDP hole punching; symmetric NATs defeat it, so WebRTC falls back to a **TURN** relay (ICE tries candidates in order). +- [ ] P3 · new · *IP and routing* › **L3/L4 load distribution**: ECMP hashes flows across equal-cost paths; L4 balancers use consistent hashing (Maglev) so flows survive balancer changes; direct server return sends responses straight from the backends. +- [ ] P3 · extend · **Loading a URL**: light in fiber covers ~200 km per ms, about 1 ms of RTT per 100 km, so a transatlantic round trip costs ~70 ms whatever the bandwidth. +- [ ] P3 · extend · **HTTP/2**: Rapid Reset (2023). Clients open and immediately cancel streams to exhaust servers; servers now cap resets per connection. + +**Trim** + +- [ ] merge · **UDP**: definition-level. Move "DNS, VoIP, games, QUIC" into **HTTP/3 and QUIC** or **Head-of-line blocking**. +- [ ] cut · **HTTP/1.1** bullet 2's history (domain sharding, sprite sheets). Keep "~6 connections per host". +- [ ] merge · **Debugging tools**: a tool list. Fold it into the failure-signatures concept as symptom → tool. + +### Operating Systems + +Good coverage of memory and I/O. Missing process states, a safe file-replace pattern, lock-free basics, and latency intuition. + +**Add** + +- [ ] P1 · extend · **Durability and fsync**: **atomic file replace**. Write a temp file → `fsync` it → `rename` it over the target (atomic on POSIX) → `fsync` the directory; readers see the old or the new file, never a torn one. +- [ ] P1 · new · *Processes and threads* › **Process states** (table): R (running or runnable), S (interruptible sleep), **D** (uninterruptible, usually disk or NFS I/O; even `SIGKILL` waits, and it counts in load average), Z (zombie), T (stopped). +- [ ] P1 · new · *Synchronization* › **Atomics, CAS, and the ABA problem**: compare-and-swap loops build lock-free structures and mutex fast paths; **ABA** = a value goes A → B → A and a stale CAS succeeds, fixed with version-tagged pointers or safe reclamation (hazard pointers, epochs); under heavy contention CAS loops thrash the cache line; x86 is TSO, ARM weakly ordered (orderings in [rust.md](rust.md)). +- [ ] P1 · new · *Performance analysis* › **Memory hierarchy latencies**: L1 ~1 ns, L2 ~4 ns, L3 ~10–40 ns, DRAM ~100 ns, NVMe read ~10–100 µs; sequential access and contiguous layouts (arrays over linked lists, struct-of-arrays) win through prefetching and cache lines. system.md keeps its short interview list. +- [ ] P2 · new · *Processes and threads* › **IPC mechanisms**: pipes (one-way byte stream), Unix domain sockets (two-way, faster than loopback TCP, pass file descriptors via `SCM_RIGHTS`), shared memory + a lock (no copies), signals (no payload); the Docker and containerd APIs listen on Unix sockets. +- [ ] P2 · new · *Memory* › **Heap allocators and RSS growth**: `malloc` serves large requests (≥ 128 KB by default) with `mmap` and small ones from arenas; glibc creates up to 8 arenas per core on 64-bit, so multi-threaded services fragment and RSS only grows; `MALLOC_ARENA_MAX=2`, or jemalloc/tcmalloc/mimalloc. Memory already has 8 concepts: merge **Page faults** into **Virtual memory and the TLB** to make room. +- [ ] P2 · extend · **CPU quotas and throttling**: pool sizing. CPU-bound ≈ number of cores (or the quota); blocking I/O ≈ cores × (1 + wait/compute), or derive it from **Little's law** (see system.md). +- [ ] P3 · new · *Files and I/O* › **File locks**: `flock` locks a whole file per open file description; POSIX `fcntl` locks are per process and **released when any descriptor to the file closes**; both are advisory. +- [ ] P3 · new · *Files and I/O* › **Write-back and direct I/O**: dirty pages flush in the background past `dirty_background_ratio` and throttle writers at `dirty_ratio`, so a bulk write can stall unrelated writes; `O_DIRECT` bypasses the page cache (databases with their own buffer pool). +- [ ] P3 · new · *Processes and threads* › **Process memory layout**: text, data/BSS, heap, mmap region (shared libraries, large allocations, thread stacks), stack with a guard page (overflow → `SIGSEGV`); ASLR randomizes the bases. +- [ ] P3 · new · *Performance analysis* › **Virtualization**: VMs (own kernel, hardware isolation) vs containers (shared kernel) vs microVMs (Firecracker, behind Lambda and Fargate) vs gVisor (user-space kernel); `st` time shows what the hypervisor takes. + +**Trim** + +- [ ] cut · **Processes vs threads** bullet 1: definition-level. Keep the `clone()` bullet, merged into **fork, exec, copy-on-write**. +- [ ] cut · **Priority inversion**: rarely asked outside real-time roles (low confidence; Mars Pathfinder is a good memory hook). +- [ ] cut · **Linux observability tools** bullet 1: a tool list. Keep the perf/eBPF/strace bullets, or turn the concept into a symptom → tool table. + +### System Design + +Strong building blocks and classic designs. Missing capacity math, metric aggregation pitfalls, multi-region/DR, and a couple of classic prompts. + +**Add** + +- [ ] P1 · extend · **Back-of-envelope conversions**: **Little's law** L = λ × W, so in-flight requests = throughput × latency (1,000 RPS × 200 ms = 200 concurrent requests → threads, connections, pool sizes). +- [ ] P1 · extend · **Observability**: percentiles **can't be averaged** across hosts or windows, so merge histograms and then take p99; **high-cardinality labels** (user ID, request ID) multiply Prometheus time series, so keep them in logs and traces. +- [ ] P1 · new · *Reliability and operations* › **Multi-region and disaster recovery**: tiers by RTO/RPO, from backup and restore (hours) → pilot light → warm standby → active-active (near zero); async cross-region replication means RPO > 0; active-active needs conflict handling or per-record home regions, plus global routing (GeoDNS, anycast); rehearse failover. Absorbs the RPO/RTO bullet from **Availability math**. +- [ ] P1 · new · *Classic designs: user-facing* › **Video streaming**: upload to object storage → transcoding DAG (split into chunks, encode in parallel) → renditions at several bitrates → **HLS/DASH** segments (2–10 s) plus a manifest → CDN; the player picks a rendition per segment (**adaptive bitrate**); pre-warm popular content at the edge. +- [ ] P2 · extend · **Load balancing**: **power of two choices**. Sample two backends and pick the less loaded: near-optimal balance without global state, and no herding onto the one server stale stats call "least loaded". +- [ ] P2 · new · *Classic designs: user-facing* › **Top-K and trending**: per-window counts in a stream processor; exact counts + a min-heap for moderate cardinality, **count-min sketch + heap** for huge key spaces; merging per-partition top-k is approximate, so fetch k′ > k per partition; sharded counters for view and like counts. +- [ ] P2 · new · *Classic designs: data and infrastructure* › **Distributed key-value store**: the Dynamo-style synthesis. Consistent hashing + virtual nodes, N replicas with W/R quorums, hinted handoff, Merkle anti-entropy, vector clocks or LWW, gossip membership; each piece links to distributed.md. +- [ ] P2 · new · *Data storage choices* › **Replication vs erasure coding**: 3× replication survives 2 losses at 200% overhead; Reed–Solomon 6+3 survives 3 losses at 50% overhead, but reads and repairs touch many nodes, so it suits cold and blob storage (S3, HDFS EC). +- [ ] P2 · new · *Reliability and operations* › **Blast-radius reduction**: **cell-based architecture** (independent full stacks, each serving a slice of customers); **shuffle sharding** (each customer gets a random subset of workers, so one poison tenant rarely shares all of another's); static stability (keep serving when the control plane is down). +- [ ] P3 · new · *Asynchronous processing* › **Lambda vs Kappa architecture**: Lambda = batch layer (complete, recomputable) + speed layer (fresh, approximate), two codebases to keep in sync; Kappa = one streaming pipeline that reprocesses by replaying the log into a new output. +- [ ] P3 · extend · **CDN and object storage**: an origin shield collapses edge misses into one origin fetch; normalize the cache key (drop tracking parameters); `stale-while-revalidate` and `stale-if-error` at the edge. +- [ ] P3 · new · *Classic designs: data and infrastructure* › **Order matching**: one single-threaded matching engine per symbol with an in-memory order book (price-time priority), fed by a sequencer and an event log for recovery and replicas (fintech and crypto loops). +- [ ] P3 · extend · **Back-of-envelope conversions**: 2¹⁰ ≈ 10³, 2²⁰ ≈ 10⁶, 2³⁰ ≈ 10⁹, 2⁴⁰ ≈ 10¹². + +**Trim** + +- [ ] cut · **Leaderboard** bullet 2: Redis command deprecation trivia. +- [ ] cut · **SQL vs NoSQL** bullet 1: definition-level. +- [ ] cut · **Monolith vs microservices** bullets 1–2: well-known pros and cons. Keep "modular monolith by default" and Conway's law. + +## Languages + +### Go + +Strong runtime and concurrency coverage. Missing several everyday gotchas; a few tooling and syntax items are low value. + +**Add** + +- [ ] P1 · new · *Standard library gotchas* › **encoding/json gotchas**: numbers decode into `any` as **float64**, so IDs above 2⁵³ lose precision (`Decoder.UseNumber`); a nil slice encodes as `null`, an empty one as `[]`; unexported fields are silently skipped; `omitempty` never omits a struct, `omitzero` (1.24) does; unknown fields are ignored unless `DisallowUnknownFields`. +- [ ] P1 · extend · **Maps**: reading a nil map returns zero values, but **writing panics**, so `make` it first (a nil slice, by contrast, works with `append`). +- [ ] P1 · extend · **context.Context**: every `WithCancel`/`WithTimeout`/`WithDeadline` returns a `cancel` you must call (`defer cancel()`), or the child and its timer live until the parent ends; `go vet` reports it (`lostcancel`). +- [ ] P1 · extend · **Scheduler (GMP)**: each P has a local run queue (256 goroutines) plus a `runnext` slot; an idle P **steals half** of another P's queue; the global queue is checked every 61st scheduling round for fairness. +- [ ] P2 · new · *Standard library gotchas* › **time gotchas**: `time.Time` carries a location and a monotonic reading, so compare with `Equal`, not `==`, and don't use it as a map key; `time.Since` uses the monotonic clock; bare integers are nanoseconds (`time.Sleep(5)` sleeps 5 ns). +- [ ] P2 · new · *Standard library gotchas* › **Graceful shutdown**: `signal.NotifyContext` for SIGTERM → `srv.Shutdown(ctx)` stops accepting and waits for in-flight requests, but not for hijacked connections (WebSockets); `net/http` recovers a handler panic per request, but a panic in a goroutine you started kills the process. +- [ ] P2 · extend · **Error wrapping**: `%w` makes the wrapped error part of your API (callers can match it), `%v` hides it; sentinel (`io.EOF`) vs typed (`*fs.PathError`) vs opaque errors; `:=` inside a block shadows the outer `err`. +- [ ] P2 · extend · **Garbage collector**: **GC assist**. Goroutines that allocate during a cycle are drafted into marking, so allocation-heavy paths see latency spikes; background marking targets ~25% of `GOMAXPROCS`. +- [ ] P2 · new · *Modules and tooling* › **Static binaries and cgo**: `CGO_ENABLED=0` gives a fully static binary (for `scratch` or distroless images); with cgo, DNS may go through libc's resolver (`netgo` vs `netcgo`); cgo calls cost tens of nanoseconds and occupy a thread; cross-compile with `GOOS`/`GOARCH`. +- [ ] P3 · extend · **Method sets and embedding**: use pointer receivers when methods mutate, the struct is large, or it holds a `sync.Mutex`; don't mix receiver kinds on one type. +- [ ] P3 · new · *Types and interfaces* › **Package initialization**: imported packages initialize first, then package-level variables in dependency order, then `init()` functions in file order; keep `init` free of I/O. + +**Trim** + +- [ ] cut · **Newer language features**: syntax trivia (`min`/`max`, range over int, generic type aliases). Keep `new(expr)` at most. +- [ ] cut · **Toolchains and tools**: `GOTOOLCHAIN`, `tool` directives, and `go fix` modernizers are rarely asked. +- [ ] cut · **Routing, JSON, logging** bullets 2–3: json/v2's status keeps moving and "`log/slog` exists" is trivia. Replace them with the encoding/json gotchas concept. +- [ ] cut · **Test tooling** bullet 1: table-driven tests and `t.Run`/`t.Parallel`/`t.Cleanup` are basics. +- [ ] cut · **Cleanups, weak pointers, interning**: niche runtime APIs (low confidence). + +### JavaScript + +Good language-semantics coverage, but light on async ordering and engine internals; several concepts are standard-library listings, and 12 sections exceed the guide. + +**Add** + +- [ ] P1 · new · *Async* › **async/await ordering**: the `Promise` executor runs **synchronously**; `.then` callbacks and the code after `await` always run as microtasks, even for resolved values; inside `try`, `return promise` bypasses the `catch`, so write `return await`; an `async` function always returns a new promise. +- [ ] P1 · new · *Async* › **fetch semantics**: `fetch` rejects only on network failure; HTTP 4xx/5xx resolve with `res.ok === false`; the body can be read once (`res.clone()` to reuse it); there's no default timeout (`AbortSignal.timeout`). +- [ ] P1 · new · *Memory* › **Hidden classes and inline caches**: V8 gives objects built with the same properties in the same order a shared hidden class (shape); property-access sites cache shapes: monomorphic is fast, more than 4 shapes goes **megamorphic**; initialize every field in the constructor and avoid `delete` on hot objects. +- [ ] P2 · new · *Coercion and equality* › **Strings and Unicode**: strings are UTF-16, so `'😀'.length === 2` and indexing can split a surrogate pair; `for...of` and spread iterate code points; user-perceived characters need `Intl.Segmenter`; `normalize('NFC')` before comparing. +- [ ] P2 · new · *Coercion and equality* › **Object vs Map**: object keys are strings or symbols (numbers coerce), ordered integer-like keys ascending, then strings by insertion, then symbols; `Map` keeps any key type in insertion order, has `size`, and handles frequent adds and deletes better; `JSON.stringify` turns a `Map` into `{}`. +- [ ] P2 · new · *Node.js runtime* › **EventEmitter gotchas**: listeners run **synchronously** in registration order; an `'error'` event without a listener **throws** and crashes the process; more than 10 listeners logs a leak warning; `events.once()` returns a promise. +- [ ] P2 · extend · **Microtasks vs macrotasks**: nested `setTimeout` is clamped to ≥ **4 ms** after 5 levels; hidden tabs throttle timers to once per second, and Chrome can throttle chained timers to once per minute after 5 minutes hidden. +- [ ] P2 · extend · **Type-check quirks**: `Array.prototype.sort` is stable since ES2019 and sorts in place (`toSorted` copies); `??` replaces only `null`/`undefined`, while `||` also replaces `0` and `''`. +- [ ] P2 · extend · **CommonJS vs ESM**: in an import cycle ESM sees uninitialized bindings (TDZ `ReferenceError`), CommonJS a partially filled `exports` object. +- [ ] P3 · extend · **Typed arrays**: browsers expose `SharedArrayBuffer` only to cross-origin-isolated pages (COOP `same-origin` + COEP `require-corp`). + +**Trim / restructure** + +- [ ] cut · **Array and object helpers**: standard-library listing (`toSorted`, `with`, `groupBy`). +- [ ] cut · **Promise helpers**: API listing (`withResolvers`, `try`). +- [ ] cut · **Sets and iterators** bullet 1: Set method list. Keep the lazy iterator-helpers bullet. +- [ ] cut · **Temporal** bullet 2: browser support status goes stale within months. +- [ ] cut · **Workers, cluster, child processes** bullet 3: `spawn` vs `exec` basics. +- [ ] restructure · 12 sections → ≤ 10 (see Cross-cutting › Structure). + +### Python + +Strong on the runtime, object model, and asyncio. Missing a few classic gotchas and the server and deployment angle. + +**Add** + +- [ ] P1 · extend · **multiprocessing start methods**: with `spawn`/`forkserver` (defaults on macOS since 3.8 and on Linux since 3.14) children **re-import the main module**, so guard entry code with `if __name__ == "__main__":`; arguments and results must pickle (no lambdas, local functions, or open sockets). +- [ ] P1 · new · *Gotchas* › **Shared class attributes**: a mutable class attribute (`items = []` in the class body) is shared by every instance; `self.items.append(x)` mutates the shared list, while `self.items = [...]` creates an instance attribute that shadows it. +- [ ] P1 · new · *Gotchas* › **Numeric gotchas**: `//` and `%` floor toward −∞ (`-7 // 2 == -4`, `-7 % 2 == 1`), unlike C, Java, Go, and JavaScript; `round()` rounds half to even (`round(2.5) == 2`); ints never overflow; use `decimal.Decimal` for money. +- [ ] P1 · new · *Gotchas* › **Recursion depth**: the default limit is **1000** (`RecursionError`) and there's no tail-call optimization, so deep DFS or memoized recursion needs an explicit stack or a careful `sys.setrecursionlimit`. +- [ ] P2 · new · *Concurrency* › **WSGI vs ASGI servers**: WSGI (Flask, Django) handles one request per worker thread or process; ASGI (FastAPI, Starlette) runs an event loop per worker; Gunicorn pre-forks workers, and refcount updates dirty the copy-on-write pages; `gc.freeze()` (3.7) before forking and **immortal objects** (3.12, PEP 683) keep them shared. +- [ ] P2 · new · *Concurrency* › **contextvars**: a `ContextVar` carries request-scoped state; each asyncio task runs in a **copy** of the context taken at creation, making it the async-safe replacement for thread-locals. +- [ ] P2 · extend · **Descriptors** (or new **Attribute lookup**): `obj.x` checks data descriptors on the type → the instance `__dict__` → non-data descriptors and class attributes → `__getattr__` (only on failure); `__getattribute__` runs on every access. +- [ ] P2 · extend · **Context managers and exceptions**: `raise New() from err` sets `__cause__`, implicit chaining sets `__context__`; `return` or `break` in `finally` swallows the exception (SyntaxWarning since 3.14, PEP 765). +- [ ] P2 · extend · **dict and set internals**: `defaultdict` **inserts** the key on any missing-key read, so `if d[k]:` grows the dict; use `k in d` or `.get`. +- [ ] P2 · extend · **Threads vs processes vs asyncio**: `concurrent.futures` executors are the high-level API for threads and processes; `asyncio.Semaphore` bounds concurrency; `asyncio.timeout()` (3.11) sets deadlines. +- [ ] P3 · extend · **Gradual typing and protocols**: `TypeIs` (3.13) narrows both branches, `TypeGuard` only the true one; runtime validation needs Pydantic or similar, since dataclasses don't validate. + +**Trim** + +- [ ] cut · **Refcounting and the cyclic GC** bullet 2: patch-release GC history won't be asked. +- [ ] cut · **Mutation during iteration** bullet 2: "dict order since 3.7" repeats dict internals. +- [ ] merge · **Late-binding closures** (one bullet) into **Mutable default arguments** (same `i=i` fix) or **Scope and `UnboundLocalError`**. +- [ ] cut · **Specializing interpreter and JIT** bullet 2: the JIT is off by default (low confidence). +- [ ] restructure · merge Recent language features + Typing (2 concepts each). + +### Rust + +Strong on ownership, traits, and async. Missing numeric semantics, the standard trait contracts, layout, and any actual FFI content. + +**Add** + +- [ ] P1 · new · *Error handling* › **Integer overflow and casts**: overflow **panics in debug and wraps in release** (unless `overflow-checks = true`), so state intent with `checked_`, `wrapping_`, `saturating_`, or `overflowing_`; `as` truncates between integer types and saturates float → int (NaN → 0). +- [ ] P1 · new · *Traits and generics* › **Eq, Ord, and Hash**: `PartialEq`/`PartialOrd` allow incomparable values (NaN), `Eq`/`Ord` promise a total order; `f64` implements neither, nor `Hash`, so it can't key a `HashMap` or use `.sort()` (use `total_cmp` or an ordered wrapper); `Hash` must agree with `Eq`; derived `Ord` compares fields in declaration order. +- [ ] P1 · new · *Smart pointers and memory* › **Layout and niche optimization**: `Option<&T>`, `Option>`, and `Option` are the size of the inner type (the null or zero niche encodes `None`); the default `repr(Rust)` may reorder fields, `repr(C)` is for FFI; `&str`, `&[T]`, and `&dyn Trait` are two words; an enum is its largest variant plus a tag. +- [ ] P1 · extend · **Futures and executors**: `tokio::spawn` needs a `Send + 'static` future, so move owned data or `Arc` clones in; Tokio's default runtime is multi-threaded work-stealing, and `current_thread` + `LocalSet` runs non-`Send` futures; `JoinSet` manages groups of tasks. +- [ ] P2 · new · *Unsafe and FFI* › **FFI boundaries**: `#[repr(C)]` types and `extern "C"` functions; `CString`/`CStr` for NUL-terminated strings (a pointer from a temporary `CString` dangles); a panic escaping an `extern "C"` function **aborts since 1.81** (UB before), so use `extern "C-unwind"` or `catch_unwind`; bindgen and cbindgen generate the bindings. +- [ ] P2 · new · *Lifetimes* › **Variance and PhantomData**: `&'a T` is covariant; `&'a mut T` is **invariant** in `T` (otherwise a shorter-lived reference could be written through it); `Cell` is invariant; `PhantomData` declares ownership and variance for types that hold raw pointers. +- [ ] P2 · new · *Smart pointers and memory* › **Collections gotchas**: `HashMap` hashes with randomly keyed SipHash-1-3, which resists HashDoS but is slow, so swap in FxHash or ahash for trusted keys; the `entry` API avoids a double lookup; `BTreeMap` for ordered iteration and ranges; `swap_remove` is O(1). +- [ ] P2 · extend · **Borrow rules and NLL**: borrows split across struct fields but not slice indices (`split_at_mut`, or `get_disjoint_mut` since 1.86); closures capture disjoint fields since edition 2021. +- [ ] P2 · extend · **Static vs dynamic dispatch**: a closed set of variants → enum + `match` (exhaustive, no allocation); an open set → `dyn Trait`; trait upcasting (`&dyn Sub` → `&dyn Super`) since 1.86. +- [ ] P3 · extend · **Interior mutability** table: `LazyLock`/`LazyCell` (1.80) replace `lazy_static` and `once_cell::Lazy`. +- [ ] P3 · new · *Macros and Cargo* › **Tests and release builds**: unit tests in `#[cfg(test)] mod tests` reach private items, `tests/` sees only the public API, doc tests run too; release profile knobs (`lto`, `codegen-units = 1`, `panic = "abort"`); debug builds can be 10–100× slower, so benchmark in release. + +**Trim** + +- [ ] cut · **Iterators** bullet 2: `iter`/`iter_mut`/`into_iter` basics. +- [ ] cut · **String vs &str** bullet 1: basics. Keep the no-indexing and char-boundary panic bullet. +- [ ] cut · **Lock files and editions** bullet 2's version note ("edition 2024 since 1.85"). Keep what edition 2024 changes. +- [ ] merge · **Async closures** (one bullet) into **Futures and executors** or **Fn, FnMut, FnOnce**. + +### Solidity + +The most thorough brief (254 lines). Few additions; trimming version trivia matters more here. + +**Add** + +- [ ] P1 · new · *Gas optimization* (deployment cost) or *Upgradeability* › **Clones and factories**: an **EIP-1167 minimal proxy** (45 bytes of runtime code delegating to a fixed implementation) makes deploying many instances cheap; `CREATE2` + salt gives addresses known before deployment; clones can't be upgraded and need an initializer; bind the salt to the deployer and parameters so a front-runner can't claim the address with other arguments. +- [ ] P1 · extend · **Access control** with admin keys and governance: `Ownable2Step` makes the new owner accept, so a typo can't brick ownership; admin actions go through a **timelock** (plus a multisig) that gives users an exit window; flash-loan governance attacks (Beanstalk, April 2022, ~$182M) are stopped by snapshotting voting power at proposal creation (`ERC20Votes` checkpoints) and by voting delays. +- [ ] P1 · extend · **Signature replay and malleability**: to accept signatures from smart-contract wallets (Safe, ERC-4337, 7702-delegated EOAs), verify through **`SignatureChecker`** (ECDSA or ERC-1271 `isValidSignature`); ERC-6492 wraps signatures from wallets not yet deployed. +- [ ] P1 · new · *Security* › **Front-running and slippage**: public-mempool transactions can be front-run or sandwiched, so swap and liquidity functions take a `minAmountOut` and a `deadline` chosen off-chain (never derived on-chain from the manipulable spot price); commit-reveal for bids and games. MEV mechanics live in ethereum.md. Security reaches 9 concepts: split it into *Security* (reentrancy, access, signatures, randomness, DoS) and *Integration risks* (tokens, oracles, front-running, rounding). +- [ ] P2 · new · *Gas optimization* › **Merkle allowlists**: store one root instead of a mapping and verify proofs with OpenZeppelin `MerkleProof`; **double-hash the leaves** so a 64-byte internal node can't pass as a leaf (second preimage); record claims in a bitmap to block double claims. +- [ ] P2 · extend · **Proxy storage and initializers**: legacy **storage gaps** (`uint256[50] __gap`) in upgradeable base contracts; shrink the gap by the slots you add. ERC-7201 namespaces replace them. +- [ ] P3 · new · *Security* › **Emergency controls**: `Pausable` with a guardian role, per-window outflow limits (bridges, lending) to cap losses during an exploit; pausing is itself a centralization risk to disclose. + +**Trim** (keep the mechanism, drop the release number) + +- [ ] cut · **Modifiers** bullet 4: `virtual` modifier deprecation (0.8.31). +- [ ] cut · **Libraries and user-defined types**: the `global` (0.8.13) and operator-binding (0.8.19) version details. +- [ ] cut · **Transient and relocated storage** bullet 3: `layout at` (0.8.29/0.8.35) is niche. +- [ ] cut · **Error types** bullet 4: the 0.8.26 vs 0.8.27 split for `require(cond, Error())`. +- [ ] cut · **Assembly gotchas** bullet 2's deprecated-comment clause, and **Gas optimization patterns** bullet 5's 0.8.22 note. +- [ ] cut · **Code size limit** bullet 3: EIP-7954 and Glamsterdam are still moving; re-add once shipped. +- [ ] cut · **Oracle integration** bullet 1: duplicate of ethereum.md (owner). +- [ ] cut · **Randomness and block data** bullet 4: the timestamp slot detail is minor. + +### TypeScript + +Good type-system depth. The biggest gap is the runtime boundary (types vanish), plus two assignability surprises. + +**Add** + +- [ ] P1 · new · *Typing patterns* › **Runtime validation at boundaries**: types are erased, so `JSON.parse`, `res.json()`, env vars, and `as` casts yield unchecked data; parse with a schema library (Zod, Valibot, ArkType) and derive the type from the schema (`z.infer`) so the two can't drift; type untrusted input as `unknown`, not `any`. +- [ ] P1 · new · *Type system semantics* › **`{}`, `object`, and index signatures**: **`{}` means any non-nullish value** (strings and numbers included), not "empty object"; `object` = any non-primitive; `Record` is a truly empty object; an index signature makes every key "present" unless `noUncheckedIndexedAccess` is on. +- [ ] P1 · new · *Type system semantics* › **Function assignability**: a function returning a value is assignable to one returning `void` (so `arr.forEach(x => out.push(x))` compiles); a function with fewer parameters is assignable to one with more (callbacks may ignore arguments). +- [ ] P2 · new · *Declarations and runtime features* › **`private` vs `#private`**: TS `private`, `protected`, and `readonly` are compile-time only, visible at runtime and reachable via `obj['x']`; ECMAScript `#x` is engine-enforced and hidden from `Object.keys` and JSON. +- [ ] P2 · new · *Narrowing* (rename "Narrowing and widening") › **Literal widening**: `let x = 'a'` is `string`, `const x = 'a'` is `'a'`; object literal properties widen (`{ kind: 'a' }` → `{ kind: string }`) unless `as const`, `satisfies`, or a contextual type applies; the usual cause of "string is not assignable to 'a' | 'b'". +- [ ] P2 · extend · **Conditional types**: `C` distributes over an empty union and yields `never`, so test with `[T] extends [never]`; `infer U extends string` (4.7) constrains the inferred type. +- [ ] P2 · extend · **The `strict` family**: `useUnknownInCatchVariables` (in `strict` since 4.4) types `catch (e)` as `unknown`; narrow with `instanceof Error` before reading `.message`. +- [ ] P2 · extend · **Custom type guards**: a hand-written `x is T` isn't verified, so a wrong predicate lies to the compiler just like `as`. +- [ ] P2 · new · *Compilation and tooling* › **Project references and build speed**: `composite` projects built with `tsc -b` compile a monorepo incrementally in dependency order; slow checks come from huge unions, deep conditional types, and large inferred literals (`--extendedDiagnostics`, `--generateTrace`). + +**Trim** + +- [ ] merge · **Structural typing** (one definition-level bullet) into **Branded types**, which exists because of it. +- [ ] cut · **TypeScript 7 native compiler** bullet 2: tooling compatibility status will change within months. +- [ ] merge · **Exhaustiveness with `never`** (one bullet) into **Control-flow narrowing** (low confidence). + +## Web + +### Backend + +Good API and reliability patterns. Missing schema evolution, tenancy, time handling, and service-to-service auth. + +**Add** + +- [ ] P1 · new · *API design* › **Schema evolution**: **backward compatible** = new readers read old data, **forward compatible** = old readers read new data; Protobuf: never reuse or renumber a field (mark it `reserved`), adding fields is safe, proto3 has no `required`, unknown fields survive round trips; Avro + Schema Registry enforces BACKWARD/FORWARD/FULL modes; JSON consumers must ignore unknown fields (tolerant reader). +- [ ] P1 · new · *Data access* › **Multi-tenancy models**: shared tables with a `tenant_id` (cheapest; every query must filter, so enforce it with PostgreSQL **row-level security**, which the table owner bypasses unless `FORCE ROW LEVEL SECURITY`) → schema per tenant → database per tenant (strongest isolation, per-tenant restore, most operations work); move noisy tenants to their own shard. +- [ ] P1 · new · *Data access* › **Time handling**: store and send instants in UTC (RFC 3339 with an offset); for future local-time events (meetings, schedules) store the local time + an **IANA zone**, since offsets and DST rules change; a DST switch skips or repeats local times, so a 02:30 cron runs twice or never. +- [ ] P2 · new · *Service calls* › **Service-to-service authentication**: mTLS with workload identities (SPIFFE, a mesh), OAuth client credentials (short-lived JWTs with `aud`), or signed requests (HMAC, AWS SigV4); API keys are long-lived bearer secrets, so store them hashed, give them a scannable prefix, and rotate them. Mechanisms in security.md. +- [ ] P2 · extend · **Timeouts and deadline propagation**: a short connect timeout (~1 s) separate from the read or overall timeout; propagate the W3C `traceparent` header along with the deadline. +- [ ] P2 · new · *Lifecycle and config* › **Service internals**: hexagonal architecture (ports and adapters) keeps the domain free of framework and database imports; a DDD **aggregate** is the consistency and transaction boundary (one aggregate per transaction, others referenced by ID); **bounded contexts** map to service boundaries. +- [ ] P3 · new · *API design* › **Batch endpoints**: per-item results (207 Multi-Status or a result array), per-item idempotency, and a maximum batch size. +- [ ] P3 · extend · **Integration tests with real dependencies**: prefer fakes (working in-memory implementations) over mocks for stateful dependencies; mocks couple tests to call sequences. + +**Trim** + +- [ ] cut · **Resource modeling**: REST naming basics. +- [ ] cut · **Configuration and secrets**: 12-factor generics. Keep "validate config at startup" at most. +- [ ] cut · **File uploads** bullet 1: duplicates system.md. Keep the multipart/resumable bullet. +- [ ] cut · **Queue vs direct call**: system.md's **Queue semantics** covers it (low confidence). + +### Frontend + +Good breadth. Missing the React data-fetching and state-update gotchas that interviews probe, plus browser storage. + +**Add** + +- [ ] P1 · new · *React hooks pitfalls* › **Data fetching in effects**: responses can arrive out of order, so ignore stale ones in cleanup (an `ignore` flag or `AbortController`); effect-based fetching causes **waterfalls** (parent fetch → child mounts → child fetch), so hoist fetching to route loaders or a query library; Strict Mode fires the request twice in development. +- [ ] P1 · new · *React rendering model* › **State snapshots and keys**: state is a **snapshot** per render, so `setCount(count + 1)` twice adds 1 while `setCount(c => c + 1)` twice adds 2; changing a component's `key` resets its state; `useRef` holds mutable values without re-rendering. +- [ ] P1 · new · *Caching* › **Browser storage**: cookies (~4 KB, sent with every request), `localStorage` (~5 MB per origin, **synchronous**, strings only), `sessionStorage` (per tab), **IndexedDB** (async, large, structured, available in workers), the Cache API (for service workers); any XSS can read all of them (tokens in security.md). +- [ ] P1 · new · *React rendering model* › **Error boundaries**: they catch render and lifecycle errors in a subtree and show a fallback; still written as **class components** (or `react-error-boundary`); they don't catch errors in event handlers or async code. +- [ ] P2 · new · *React hooks pitfalls* › **useLayoutEffect vs useEffect**: `useEffect` runs after paint; `useLayoutEffect` runs after DOM mutation but **before paint**, for measuring layout without flicker, at the cost of blocking paint. +- [ ] P2 · extend · **Core Web Vitals**: rankings use **field data** (CrUX, p75 over 28 days, mobile and desktop separately); a page-load Lighthouse run is lab data and can't measure INP, so it reports TBT as a proxy. +- [ ] P2 · new · *Performance* › **Long lists**: **virtualize** (render only the visible rows: TanStack Virtual, react-window) beyond a few hundred complex rows; keep stable keys for infinite scroll. +- [ ] P2 · new · *State management* › **Context performance** (replaces **Where state lives**): every consumer re-renders when the provider `value` changes identity, so memoize it, split state and dispatch into separate contexts, or use a store with selectors (`useSyncExternalStore`). +- [ ] P2 · new · *Performance* › **Web fonts**: `font-display: swap` shows fallback text instead of invisible text but causes a swap shift; `size-adjust` and metric overrides reduce that CLS; preload the one critical font; subset and self-host. +- [ ] P2 · extend · **Semantic HTML and ARIA**: dynamic messages (toasts, form errors) need an **`aria-live`** region; every input needs a programmatic label; test with axe and a keyboard. +- [ ] P3 · new · *State management* › **Signals**: fine-grained reactivity (Solid, Preact, Vue, Angular signals) updates only the dependents without a VDOM diff; a TC39 Signals proposal exists. +- [ ] P3 · extend · **Service workers** (or new **bfcache**): the back/forward cache restores pages instantly; `unload` listeners make a page ineligible, so use `pagehide`. +- [ ] P3 · new · *Accessibility* (rename "Accessibility and testing") › **Frontend testing**: Testing Library queries by role and label (tests behavior and rewards accessible markup); MSW mocks the network layer; Playwright covers end-to-end flows. + +**Trim** + +- [ ] cut · **CSS layout and specificity** bullet 1: flexbox vs grid basics. +- [ ] cut · **Modern CSS features**: feature listing and Baseline status. Keep container queries and `:has()`. +- [ ] cut · **View transitions** bullet 2: Baseline status details go stale. +- [ ] cut · **Where state lives**: generic advice (replaced by Context performance). +- [ ] cut · **Controlled vs uncontrolled inputs**: basic React (low confidence). + +### Security + +Strong. Missing a few browser-policy nuances, randomness, account recovery, and denial-of-service classes. Server-side attacks would reach 9 concepts: split it into *Injection* (SQL, command/template/XXE, deserialization, prototype pollution) and *Server-side request and resource attacks* (SSRF, smuggling, path traversal, resource exhaustion, race conditions, file uploads). + +**Add** + +- [ ] P1 · extend · **CORS**: **simple requests** (GET, HEAD, or POST with form or `text/plain` bodies and no custom headers) go out without a preflight, and the server acts on them even when the browser hides the response, so CORS is no CSRF defense; everything else preflights with `OPTIONS`, cached by `Access-Control-Max-Age`. +- [ ] P1 · new · *Cryptography* › **Secure randomness**: tokens, IDs, nonces, and reset codes need a **CSPRNG** (`crypto.getRandomValues`/`randomBytes`, Python `secrets`, Go `crypto/rand`); `Math.random`, `random`, and `math/rand` are predictable from a few outputs; use ≥ 128 bits for unguessable tokens. +- [ ] P1 · new · *Authentication and sessions* › **Password reset and recovery**: single-use, short-lived, high-entropy tokens stored **hashed**; revoke other sessions after a reset; identical responses whether or not the account exists; build reset links from a configured origin, not the `Host` header (host-header poisoning); recovery is often the weakest login path (SIM swap, support desk). +- [ ] P1 · new · *Server-side attacks* › **Resource-exhaustion attacks**: **ReDoS** (catastrophic backtracking on patterns like `(a+)+$`; use linear-time engines such as RE2 or Go's `regexp`, or timeouts), decompression and zip bombs (cap the output size), XML billion laughs, hash flooding (randomized hash seeds), unbounded JSON or GraphQL depth. +- [ ] P2 · extend · **CSRF**: "same-site" means same scheme + **registrable domain** (eTLD+1), so `evil.example.com` is same-site with `app.example.com` and SameSite doesn't stop attacks from a compromised or user-controlled subdomain; `Lax` still sends cookies on top-level GET navigations, so never change state on GET. +- [ ] P2 · new · *TLS* › **SNI, ALPN, ECH**: **SNI** carries the hostname in the ClientHello, so one IP serves many certificates and L4 proxies can route TLS without terminating it; **ALPN** negotiates `h2`/`http/1.1` in the handshake; **ECH** encrypts the inner ClientHello, hiding SNI from the network. +- [ ] P2 · new · *TLS* › **Certificate lifecycle**: the CA/Browser Forum (2025) cuts the maximum certificate lifetime to 200 days (March 2026), 100 days (2027), and **47 days (2029)**, so automate with ACME; revocation checking is weak (Let's Encrypt shut down OCSP in 2025), so short lifetimes do the work; monitor Certificate Transparency logs for your domains. +- [ ] P2 · extend · **Browser token storage**: current guidance for SPAs is a **BFF**: the backend runs the OAuth flow and keeps the tokens, and the browser gets only an `HttpOnly` session cookie. +- [ ] P2 · new · *Cryptography* › **Cipher modes and broken hashes**: **ECB** leaks patterns (equal blocks → equal ciphertext); CBC without a MAC enables **padding-oracle** decryption; use an AEAD (AES-GCM, ChaCha20-Poly1305); MD5 and SHA-1 are broken for collisions. +- [ ] P2 · new · *Supply chain* › **Secrets management**: prefer short-lived, dynamically issued credentials (Vault, cloud IAM) over static keys; scan commits and block pushes containing secrets; a leaked secret must be rotated, since deleting the commit doesn't un-leak it; env vars leak through `/proc//environ`, crash dumps, and child processes. +- [ ] P2 · new · *Server-side attacks* › **Race-condition attacks**: limit-overrun bugs, such as redeeming a coupon or withdrawing twice with parallel requests (HTTP/2's single-packet attack lands them within ~1 ms); fix with atomic conditional updates, unique constraints, or row locks. +- [ ] P2 · extend · **XSS**: frameworks escape text, but `dangerouslySetInnerHTML`, `v-html`, `innerHTML`, `javascript:` URLs in `href`, and template `|safe` filters bypass it; **Trusted Types** make DOM sinks reject plain strings. +- [ ] P2 · new · *Server-side attacks* › **File upload handling**: check the type by content (magic bytes), not the extension or `Content-Type`; store files outside the web root under generated names; serve user files from a separate sandbox domain with `Content-Disposition: attachment` and `nosniff`; re-encode images. +- [ ] P3 · new · *Browser-side attacks* › **Web cache poisoning and deception**: an unkeyed header (`X-Forwarded-Host`) reflected into a cached page poisons it for everyone; cache deception tricks a CDN into caching a private page under a static-looking path (`/account/x.css`). +- [ ] P3 · new · *Browser-side attacks* › **Subdomain takeover**: a dangling CNAME to a deleted cloud resource lets an attacker claim it, and the subdomain is same-site for your cookies. +- [ ] P3 · extend · **OAuth 2.0 vs OIDC**: SAML still dominates enterprise SSO; XML signature-wrapping bugs are its classic flaw. + +**Trim** + +- [ ] cut · **Encoding vs encryption vs hashing**: definition-level table. +- [ ] merge · **Clickjacking** into **Content Security Policy** (`frame-ancestors`) (low confidence). +- [ ] cut · **OWASP Top 10:2025**: keep only if you expect "name the list" questions (low confidence). + +## Infrastructure + +### AWS + +Compact and accurate. Missing the load balancer choice, cross-account access, S3 and CloudFront access control, and where the money goes. + +**Add** + +- [ ] P1 · new · *Networking* › **ALB vs NLB** (table): ALB is L7 (host, path, and header routing; WebSockets; gRPC; OIDC auth; WAF); NLB is L4 TCP/UDP/TLS with a **static IP per AZ**, preserves the client IP, supports TLS passthrough and very high throughput, and fronts PrivateLink services; GWLB is for inline appliances; cross-zone balancing is on for ALB and off by default for NLB (cross-AZ charges). +- [ ] P1 · new · *Identity and access* › **Cross-account access**: within one account, an allow in the identity **or** the resource policy suffices (KMS key policies and role trust policies excepted); across accounts **both** sides must allow; third parties assume your role with an **`sts:ExternalId`** condition (confused deputy); `aws:PrincipalOrgID` limits resource policies to your organization. +- [ ] P1 · new · *Storage and databases* › **S3 access and CloudFront**: new buckets block public access and disable ACLs ("bucket owner enforced") since April 2023, and encrypt with SSE-S3 since January 2023; serve private buckets through CloudFront with **Origin Access Control**; signed URLs or cookies for private content at the edge. +- [ ] P1 · extend · **Capacity and cost guardrails** (or new **Cost drivers**): NAT gateway data processing (~$0.045/GB; add S3/DynamoDB gateway endpoints), **cross-AZ traffic** (~$0.01/GB each way), internet egress, CloudWatch Logs ingestion; Savings Plans and RIs (up to ~72% off for 1–3 year commitments), Spot (up to ~90% off), Graviton (~20% cheaper). +- [ ] P2 · extend · **Managed database behavior**: **RDS Proxy** pools connections for Lambda bursts (each concurrent environment opens its own) and shortens failover; read replicas are asynchronous. +- [ ] P2 · new · *Events and workflows* › **Streams with Lambda**: Kinesis and DynamoDB Streams deliver in order per shard, so one failing record **blocks the shard** until it expires; set `BisectBatchOnFunctionError`, `MaximumRetryAttempts`, and an on-failure destination; a Kinesis shard takes 1 MB/s or 1,000 records/s in and 2 MB/s out; DynamoDB Streams keep 24 h; async Lambda invocations retry twice. +- [ ] P2 · new · *Compute* › **EC2 Auto Scaling**: target tracking (hold a metric such as requests per target) over step or scheduled policies; a health check grace period; lifecycle hooks for bootstrap and drain; warm pools for fast scale-out; T instances drop to baseline CPU when their credits run out (`unlimited` mode bills instead). +- [ ] P2 · extend · **DynamoDB partitions and indexes**: conditional writes (`ConditionExpression`, a version attribute) for optimistic locking and create-if-absent; on-demand vs provisioned capacity; single-table design keys items by access pattern. +- [ ] P2 · new · *Identity and access* › **Multi-account structure**: Organizations and OUs; SCPs cap member accounts' permissions (not the management account's); IAM Identity Center for human SSO; separate accounts per environment or workload as blast-radius and billing boundaries. +- [ ] P2 · extend · **Infrastructure changes and secrets**: Parameter Store's standard tier is free (4 KB values, no managed rotation); Secrets Manager charges per secret and adds rotation and cross-Region replication. +- [ ] P3 · extend · **Public and private subnets**: AZ names (`us-east-1a`) map to different physical AZs per account; align across accounts with AZ IDs (`use1-az1`). +- [ ] P3 · new · *Operations* › **Disaster recovery services**: the tiers live in system.md; here the AWS pieces: AWS Backup, S3 cross-Region replication, Aurora Global Database (typically < 1 s lag), DynamoDB global tables, Route 53 failover. +- [ ] P3 · new · *Networking* › **EKS Pod networking**: the VPC CNI gives every Pod a VPC IP, which exhausts subnets; use prefix delegation or secondary CIDRs. + +**Trim** + +- [ ] cut · **ECS service mechanics**: definitions (task definition, service). +- [ ] cut · **Lambda limits and concurrency** bullet 2: Managed Instances' 90-minute limit is new and niche (low confidence). +- [ ] cut · **Capacity and cost guardrails** bullet 2: Budgets vs Cost Explorer trivia. +- [ ] cut · **KMS and envelope encryption** bullet 1's re-explanation (owner: security). Keep `GenerateDataKey` and the 4 KB limit. + +### DevOps + +Good Kubernetes and Terraform coverage. Missing workload security, a key Terraform gotcha, autoscaling mechanics, and the delivery and incident practices DevOps interviews ask about. Kubernetes operations already has 8 concepts: move ServiceAccounts, ConfigMaps and Secrets, and NetworkPolicy into a new *Kubernetes security* section (with Pod security below), and Packaging and extension into *Kubernetes architecture*. + +**Add** + +- [ ] P1 · new · *Kubernetes security* › **Pod security**: Pod Security Admission levels (privileged, baseline, **restricted**) per namespace, since PodSecurityPolicy was removed in 1.25; `securityContext`: `runAsNonRoot`, `readOnlyRootFilesystem`, `allowPrivilegeEscalation: false`, drop all capabilities, `seccompProfile: RuntimeDefault`; Kyverno or OPA Gatekeeper for custom policy. +- [ ] P1 · new · *Terraform* › **count vs for_each**: `count` addresses resources by index, so removing one element shifts every later index and **recreates** those resources; `for_each` keys them by stable map or set keys. +- [ ] P1 · extend · **Autoscaling**: HPA utilization is a percentage of **requests**, so without requests there's no CPU-based scaling; scale-down waits out a 5-minute stabilization window; **KEDA** scales on queue length or events, down to zero; Karpenter provisions right-sized nodes and consolidates underused ones. +- [ ] P1 · new · *Deployment and release* › **Incident response**: roles (incident commander, communications, operations); **mitigate first** (roll back, flip a flag), find the root cause later; a blameless postmortem with a timeline, contributing factors, and owned action items; track MTTD and MTTR; link runbooks from alerts. +- [ ] P2 · new · *CI/CD and GitOps* › **DORA metrics**: deployment frequency, lead time for changes, change failure rate, failed-deployment recovery time; high performers improve speed and stability together; recent reports add rework rate. +- [ ] P2 · extend · **Deployment strategies** table: **shadow** (mirror live traffic to the new version and discard its responses; watch for side effects); A/B tests split by user for product metrics, not safety; Argo Rollouts and Flagger automate canary analysis. +- [ ] P2 · new · *Kubernetes workloads* › **Jobs and CronJobs**: `backoffLimit`, `activeDeadlineSeconds`, `ttlSecondsAfterFinished`; `concurrencyPolicy: Forbid` prevents overlapping runs; schedules use the controller's time zone (usually UTC) unless `timeZone` (GA 1.27) is set. +- [ ] P2 · new · *Kubernetes operations* › **Cluster upgrades**: control plane first, one minor version at a time; kubelets may lag the API server by up to 3 minor versions (since 1.28); drain nodes (PDBs apply) or roll new node groups; check for removed APIs first; each minor release gets ~14 months of patches. +- [ ] P2 · new · *Kubernetes operations* › **Quotas and priority**: `ResourceQuota` caps a namespace's total requests, limits, and object counts; `LimitRange` sets defaults for Pods without requests; `PriorityClass` lets critical Pods **preempt** others when the cluster is full. +- [ ] P2 · extend · **CI pipeline practices**: `pull_request_target` workflows that check out PR code run it with secrets (a "pwn request"); least-privilege `GITHUB_TOKEN`; OIDC to the cloud instead of stored keys; no untrusted PRs on self-hosted runners. +- [ ] P3 · new · *Deployment and release* › **Chaos engineering**: state a steady-state hypothesis, inject a failure (instance, AZ, latency) with a small blast radius, and compare against SLOs; game days rehearse incident response. +- [ ] P3 · new · *Terraform* › **Mutable vs immutable infrastructure**: configuration management (Ansible) patches servers in place and drifts; immutable images (Packer, containers) replace them. + +**Trim** + +- [ ] cut · **Container networking and storage**: Docker basics (`EXPOSE` vs `-p`, volumes vs bind mounts). +- [ ] cut · **Modules, workspaces, licensing** bullet 3: license history. Keep "OpenTofu is the open fork" (low confidence). +- [ ] cut · **Node components** bullet 3: kube-proxy modes by version (low confidence). +- [ ] cut · **Workload types**: definition-level for Kubernetes users. Keep "never run a bare Pod" (low confidence). + +## Domains + +### AI Engineering + +Strong on inference, serving, RAG, and agents. Missing how models are trained (including reasoning models), multi-GPU serving, and filtered retrieval. LLM fundamentals already has 8 concepts: move **Structured output** and **Tool calling** into *Tools and integration* to make room. + +**Add** + +- [ ] P1 · new · *Fine-tuning* (rename "Training and fine-tuning") › **Training pipeline**: **pretraining** (next-token prediction on trillions of tokens; Chinchilla-optimal is ≈ 20 tokens per parameter, and modern models train far past it to be cheaper at inference) → SFT → preference tuning (RLHF, DPO) → **RL with verifiable rewards** (math and code graded automatically, e.g., GRPO), which is how reasoning models learn long chains of thought. +- [ ] P1 · new · *Inference and serving* › **Model parallelism and GPU memory**: memory ≈ weights + KV cache + activations; **tensor parallelism** splits each layer across GPUs (needs NVLink-class links, so within a node); **pipeline parallelism** splits layers across nodes (pipeline bubbles); data parallelism replicates for throughput; **disaggregated serving** runs prefill and decode on separate GPU pools. +- [ ] P1 · extend · **Vector index types**: **filtered search**. Post-filtering the top-k returns too few hits for selective filters, and pre-filtering breaks HNSW graph connectivity; use filter-aware engines or partition indexes by tenant. +- [ ] P2 · new · *LLM fundamentals* › **Positional encoding**: attention is order-blind; **RoPE** rotates query and key vectors by position so scores depend on relative distance; longer contexts come from RoPE scaling (position interpolation, YaRN) plus long-context training, and quality degrades past the trained length. +- [ ] P2 · new · *Fine-tuning* › **Distillation**: train a small student on a large teacher's outputs or logits for most of the quality at a fraction of the serving cost (also how small reasoning models are made); fine-tuning can cause catastrophic forgetting, which LoRA limits by freezing the base. +- [ ] P2 · extend · **Eval sets and metrics**: **pass@k** for code and agent tasks (the probability that at least one of k samples passes); precision/recall (PR-AUC when labels are imbalanced) for classifier-style checks; public benchmarks suffer from contamination. +- [ ] P2 · new · *Retrieval and RAG* › **Query transformation**: rewrite follow-ups into standalone queries; **HyDE** embeds a hypothetical answer instead of the question; decompose multi-hop questions; extract metadata filters (dates, product) from the query. +- [ ] P2 · extend · **Prompt injection**: jailbreaks (the user attacks the model's policy) vs prompt injection (third-party content attacks your application) are different threat models with different defenses. +- [ ] P2 · extend · **Batching and PagedAttention**: bigger batches raise tokens/s per GPU but also time per output token, so the latency SLO sets the batch size. +- [ ] P3 · new · *LLM fundamentals* › **Attention variants**: sliding-window attention, multi-head latent attention (DeepSeek; compresses the KV cache), and state-space or linear-attention hybrids (Mamba) with constant memory per token. +- [ ] P3 · extend · **Embeddings and similarity**: Matryoshka embeddings truncate to fewer dimensions; int8 or binary quantized vectors shrink the index 4–32×, then the top candidates are rescored at full precision. +- [ ] P3 · new · *Evaluation* › **Classic ML basics** (only for ML-adjacent roles): bias–variance and overfitting, regularization, train/validation/test splits and leakage, ROC-AUC vs PR-AUC. + +**Trim** + +- [ ] cut · **Browser automation as a fallback**: generic. Move "approve irreversible submits" into **Human approval gates**. +- [ ] cut · **Model routing and caching** bullet 3: "measure cost per completed task" is generic (low confidence). +- [ ] cut · **Stop conditions** bullet 2: generic (low confidence). + +### Ethereum + +Good protocol coverage. Missing precompiles, node and RPC practicalities, ZK proof systems, and EIP-7702's risks. + +**Add** + +- [ ] P1 · new · *EVM* › **Precompiles**: fixed low addresses for cryptography too costly in bytecode: `0x01` ecrecover, `0x02` SHA-256, `0x05` modexp, `0x06`–`0x08` BN254 add/mul/pairing (SNARK verifiers), `0x0a` KZG point evaluation (EIP-4844), **BLS12-381** (Pectra, EIP-2537), **P-256** verification (Fusaka, EIP-7951; passkey wallets); they have no code, so `extcodesize` is 0. +- [ ] P1 · new · *Accounts and transactions* › **RPC block tags and reorgs**: `latest` can reorg, **`safe`** (justified) rarely does, and **`finalized`** can't without slashing ⅓ of the stake; `eth_call` simulates against a block; `eth_estimateGas` binary-searches and can underestimate state-dependent paths, so add headroom; indexers store block hashes and roll back on reorg, or index only finalized blocks. +- [ ] P1 · new · *Scaling* › **ZK proof systems**: **SNARKs** (Groth16, PLONK) have small proofs, cheap L1 verification via BN254 pairings, and often a trusted setup; **STARKs** need no trusted setup, are hash-based (plausibly post-quantum), and have larger proofs, often wrapped in a SNARK for L1; zkEVM types trade Ethereum equivalence against proving cost. +- [ ] P1 · extend · **Account abstraction**: EIP-7702 risks. One authorization signature hands the EOA to the delegate's code (a phishing target); an authorization with `chain_id = 0` is valid on **every chain**; the delegate's storage lives in the EOA, so switching delegates can collide layouts (use namespaced storage). +- [ ] P2 · new · *Consensus (PoS)* › **Execution and consensus clients**: since the Merge a node = execution client (Geth, Nethermind, Besu, Erigon, Reth) + consensus client (Prysm, Lighthouse, Teku, Nimbus, Lodestar) linked by the authenticated **Engine API**; a bug in a client with > ⅔ of the stake could finalize an invalid chain, hence client diversity; full vs archive nodes. +- [ ] P2 · extend · **Transaction lifecycle**: a replacement needs the same nonce and ≥ 10% higher fees (Geth's default; 100% for blob transactions); private RPCs (Flashbots Protect) skip the public mempool. +- [ ] P2 · new · *Scaling* › **L2 fees and messaging**: an L2 fee = L2 execution + the **L1 data fee** (blob or calldata cost, usually the larger part); deposits through the canonical bridge can be force-included; withdrawals wait for the fraud window or a validity proof; L2BEAT stages 0–2 grade how much users rely on a security council vs proofs. +- [ ] P2 · new · *Consensus (PoS)* › **Validator lifecycle**: deposit → activation queue → active → exit queue → withdrawable (the churn limit rate-limits entries and exits); withdrawal credentials `0x01` (balance above 32 ETH swept) vs `0x02` compounding (Pectra); liquid staking (stETH) and restaking (EigenLayer) add contract and slashing risk. +- [ ] P2 · new · *Consensus (PoS)* › **Network upgrades** (table): Merge (Sep 2022, PoS) → Shapella (Apr 2023, withdrawals) → Dencun (Mar 2024, blobs, transient storage, EIP-6780) → Pectra (May 2025, 7702, 7251, 7623, BLS) → Fusaka (Dec 2025, PeerDAS, 7825, P-256) → Glamsterdam (planned: ePBS, block-level access lists). +- [ ] P2 · new · *DeFi and MEV* › **Bridge designs**: canonical rollup bridges (inherit L1 security, slow withdrawals), external validator or multisig bridges (fast, trust a committee, e.g., Ronin), light-client and ZK bridges, liquidity networks and intents (fast; LPs front the funds). +- [ ] P3 · new · *Signatures and standards* › **Wallet keys**: BIP-39 mnemonic → BIP-32 HD tree → path `m/44'/60'/0'/0/i`; MPC wallets split one key for threshold signing, vs multisig (on-chain M-of-N, visible, deployed per chain). +- [ ] P3 · extend · **Blobs and PeerDAS**: blob gas has its own EIP-1559-style base fee with a per-block target and max; EIP-7918 (Fusaka) ties the blob base fee floor to the execution base fee. +- [ ] P3 · new · *DeFi and MEV* › **Stablecoin designs**: fiat-backed (USDC; the issuer can freeze), overcollateralized crypto-backed (DAI), algorithmic (UST's 2022 death spiral). + +**Trim** + +- [ ] cut · **Bridge exploits**: historical hack list. Keep one lesson per incident, or fold it into Bridge designs (low confidence). +- [ ] cut · **Account model** bullet 1: definition-level for Ethereum roles (low confidence). From 94050d1043d9eb182a22fbebca62e6ab5d95ada1 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 30 Sep 2026 02:30:25 +0000 Subject: [PATCH 2/4] Apply P1 coverage-review items to the topic briefs Add the 72 commonly asked gaps from coverage-review.md across all 19 briefs (56 new concepts), split Solidity Security into Security and Integration risks, add a Kubernetes security section in DevOps, raise the suggested section limit to 20, and record new concept owners in the AGENTS.md ownership table. The review file now ticks the P1 items and drops the Java suggestions. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FADC1PgtXHNSjrM55y3LdW --- AGENTS.md | 10 +- coverage-review.md | 193 ++++++++++++++++++------------------- docs/topics/ai.md | 17 +++- docs/topics/algorithms.md | 33 ++++++- docs/topics/aws.md | 33 +++++++ docs/topics/backend.md | 20 ++++ docs/topics/database.md | 28 +++++- docs/topics/devops.md | 42 ++++++-- docs/topics/distributed.md | 22 ++++- docs/topics/ethereum.md | 28 ++++++ docs/topics/frontend.md | 30 ++++++ docs/topics/golang.md | 16 ++- docs/topics/javascript.md | 21 ++++ docs/topics/networking.md | 31 +++++- docs/topics/os.md | 35 +++++++ docs/topics/python.md | 23 ++++- docs/topics/rust.md | 21 ++++ docs/topics/security.md | 22 +++++ docs/topics/solidity.md | 44 ++++++--- docs/topics/system.md | 27 +++++- docs/topics/typescript.md | 18 ++++ 21 files changed, 575 insertions(+), 139 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index fcd7931..c2801ac 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -51,7 +51,7 @@ What experienced Go engineers forget before an interview, grouped by subtopic. - **Bold** the term or number worth memorizing — at most 3 per concept, not counting tables. - **Versions**: note when behavior changed ("since Go 1.22", "Python 3.14+", "Pectra, May 2025"). - **Cross-topic**: the owner file covers a concept in full; another file may overlap briefly from its own angle and links to the owner: `see [security.md](security.md)` (rules in Topic ownership). Link to files, not anchors (the strict build validates anchors; only use one if you've checked the slug). -- Suggested size: 5–10 sections, 3–8 concepts each. Shorter is better if nothing is lost. +- Suggested size: 5–20 sections, 3–8 concepts each. Shorter is better if nothing is lost. ### What to include @@ -78,15 +78,15 @@ Each concept has one owner file that covers it in full. Other files may overlap | Concept | Owner | Referenced from | |---|---|---| -| Consistency models, replication theory, consensus, clocks, delivery semantics, sagas, CRDTs | distributed | database, system, backend | +| Consistency models, replication theory, consensus, clocks (monotonic vs wall), delivery semantics, sagas, CRDTs, CDC | distributed | database, system, backend, os, golang | | Retries, backoff, circuit breakers, backpressure, tail latency | distributed | backend, system | | Isolation levels, MVCC, indexes, WAL, DB replication setup, pooling | database | backend, system | -| Caching strategies, rate-limiting algorithms, load balancing, CDN, observability (SLI/SLO) | system | backend, devops | -| REST/gRPC/GraphQL, pagination, idempotency keys, outbox, graceful shutdown, N+1 | backend | system, database | +| Caching strategies, rate-limiting algorithms, load balancing, CDN, observability (SLI/SLO), capacity math (Little's law), multi-region and DR tiers | system | backend, devops, os, aws | +| REST/gRPC/GraphQL, pagination, idempotency keys, outbox, graceful shutdown, N+1, schema evolution, multi-tenancy, time handling | backend | system, database, distributed | | AuthN, sessions, OAuth/OIDC, JWT, XSS, CSRF, CORS, clickjacking, crypto, TLS | security | backend, frontend | | Containers, Kubernetes, cloud, IaC, deployment strategies, zero-downtime migrations | devops | backend, database | | Browser event loop, JS language semantics | javascript | frontend, typescript | -| Rendering strategies, browser pipeline, Web Vitals, HTTP caching in the browser, React | frontend | javascript | +| Rendering strategies, browser pipeline, Web Vitals, HTTP caching in the browser, browser storage, React | frontend | javascript, security | | asyncio event loop | python | — | | TCP/UDP, HTTP versions, QUIC, DNS, IP addressing, NAT, MTU, BGP/anycast | networking | backend, system, devops | | Processes, signals, scheduling, virtual memory, OOM, file descriptors, epoll/io_uring, fsync, locks | os | devops, database, golang | diff --git a/coverage-review.md b/coverage-review.md index 5975be5..6afbf77 100644 --- a/coverage-review.md +++ b/coverage-review.md @@ -1,6 +1,8 @@ # Brief coverage review -Temporary working file (2026-09-29): tick the items to act on, then delete this file before merging. Nothing in `docs/` has changed. +Temporary working file (2026-09-29): tick the items to act on, then delete this file before merging. + +**Status (2026-09-30):** all 72 P1 items are applied (619 → 675 concepts) and ticked below; notes in *italics* say where placement differs from the proposal. The section limit in AGENTS.md is now 5–20. P2, P3, and trim items are untouched. **Legend** @@ -17,12 +19,12 @@ Temporary working file (2026-09-29): tick the items to act on, then delete this |---|---|---|---| | Algorithms | 35 | Solid core | input-size heuristics, heap patterns, Kadane, random sampling | | Databases | 39 | Strong PostgreSQL/InnoDB internals | join pitfalls, "why isn't my index used", Redis memory, document stores | -| Distributed Systems | 38 | Strong, at the section limit | delivery guarantees, CDC, monotonic clocks, Kafka partition changes | +| Distributed Systems | 38 | Strong | delivery guarantees, CDC, monotonic clocks, Kafka partition changes | | Networking | 22 | Good, smallest brief | failure signatures, TCP loss recovery, routing tables, client IP behind proxies | | Operating Systems | 28 | Good | process states, atomic file replace, CAS/ABA, memory hierarchy | -| System Design | 37 | Strong; 11 sections | Little's law, percentile/cardinality pitfalls, multi-region/DR, video streaming | +| System Design | 37 | Strong | Little's law, percentile/cardinality pitfalls, multi-region/DR, video streaming | | Go | 32 | Strong runtime; some tooling trivia | JSON gotchas, nil maps, context cancel, work stealing | -| JavaScript | 32 | Good; stdlib listings; 12 sections | async ordering, `fetch` semantics, hidden classes | +| JavaScript | 32 | Good; stdlib listings | async ordering, `fetch` semantics, hidden classes | | Python | 32 | Strong | spawn/pickling, shared class attributes, numeric gotchas, recursion limit | | Rust | 33 | Strong; "Unsafe and FFI" has no FFI | overflow and casts, Eq/Ord/Hash, layout/niches, `tokio::spawn` bounds | | Solidity | 36 | Very thorough; longest file; version trivia | clones, admin keys and governance, ERC-1271 checks, slippage | @@ -40,36 +42,34 @@ Temporary working file (2026-09-29): tick the items to act on, then delete this ### New briefs to consider - [ ] **P1 if your loop has a low-level design round**: `ood.md` (Fundamentals). SOLID with one concrete violation each (Square/Rectangle for LSP), composition over inheritance, the GoF patterns interviewers name (strategy, observer, decorator, adapter, factory, builder, state, command, chain of responsibility; singleton pitfalls), dependency injection, the LLD interview flow (use cases → entities → interfaces → state and concurrency), classic prompts (parking lot, elevator, vending machine, expense splitting). -- [ ] P2 if targeting JVM roles: `java.md`. JVM memory areas, G1 vs ZGC (generational ZGC default since JDK 23), JMM (`volatile`, happens-before, safe publication), virtual threads (JDK 21) and pinning (fixed for `synchronized` in JDK 24), `HashMap` internals (treeify at 8), the `equals`/`hashCode` contract. -- [ ] P3: split `devops.md` into `kubernetes.md` + `devops.md` if the Kubernetes additions below push it past 10 sections (Kubernetes is already 4 of 8). +- [ ] P3: split `devops.md` into `kubernetes.md` + `devops.md` if Kubernetes keeps growing (it is now 5 of 9 sections). - [ ] P3 if targeting data roles: `data.md`. Batch vs stream (Lambda/Kappa), Spark shuffle and skew, columnar files (Parquet) and table formats (Iceberg, Delta), orchestration and idempotent backfills. - Not recommended: a separate concurrency brief. It's covered across os, golang, and rust; add CAS/ABA to os.md instead. ### Ownership gaps -No file owns these yet; add a row to the AGENTS.md ownership table with each. +No file owned these; each is now named in the AGENTS.md ownership table (merged into the existing owner rows). -- [ ] Change data capture → distributed (stream processing); referenced from database, system, backend (all three already mention CDC). -- [ ] Little's law and capacity math → system; referenced from os (thread pools) and backend (pool sizing). -- [ ] Monotonic vs wall-clock time → distributed (clocks); referenced from os and golang. -- [ ] Schema evolution and compatibility (Protobuf, Avro, JSON) → backend; referenced from distributed (event schemas). -- [ ] Timestamps and time zones → backend for app rules; database owns `timestamptz` behavior. -- [ ] Disaster recovery tiers → system; aws lists only the AWS services. -- [ ] Browser storage APIs → frontend; security keeps the token-storage guidance. +- [x] Change data capture → distributed (stream processing); referenced from database, system, backend (all three already mention CDC). +- [x] Little's law and capacity math → system; referenced from os (thread pools) and backend (pool sizing). +- [x] Monotonic vs wall-clock time → distributed (clocks); referenced from os and golang. +- [x] Schema evolution and compatibility (Protobuf, Avro, JSON) → backend; referenced from distributed (event schemas). +- [x] Timestamps and time zones → backend for app rules; database owns `timestamptz` behavior. +- [x] Disaster recovery tiers → system; aws lists only the AWS services. +- [x] Browser storage APIs → frontend; security keeps the token-storage guidance. ### Duplicates - [ ] solidity `Oracle integration` bullet 1 repeats ethereum `Oracle manipulation` bullet 1 (owner: ethereum). Keep only the link in solidity. - [ ] backend `File uploads` bullet 1 repeats system `CDN and object storage` bullet 2 (presigned URLs, metadata only). Keep one. - [ ] aws `KMS and envelope encryption` bullet 1 re-explains envelope encryption (owner: security). Keep the AWS-specific facts: `GenerateDataKey` and the 4 KB `Encrypt` limit. -- [ ] distributed `Effectively-once processing` would overlap the proposed Delivery guarantees concept. Merge them. +- [x] distributed `Effectively-once processing` would overlap the proposed Delivery guarantees concept. Merge them. *Done: replaced by Delivery guarantees.* ### Structure -- [ ] javascript has 12 sections (guide: 5–10), eight with 2 concepts. Merge Scope and closures + `this` and prototypes + Coercion and equality into "Language semantics", and fold Metaprogramming into Recent language additions. -- [ ] system has 11 sections. Fold Rate limiting into Traffic and edge, and Architecture into Reliability and operations. -- [ ] Many sections have only 2 concepts (guide: 3–8). The *new* items below fill several: backend Service calls, devops CI/CD, ai Fine-tuning, ethereum Consensus, rust Unsafe and FFI, typescript Typing patterns, security Supply chain. Merge the rest where they stay thin. -- [ ] Growth budget: the file lists 72 P1, 108 P2, and 51 P3 items. Every P1 + P2 *new* item would add 114 concepts (55 from P1 alone) to today's 619; the cut/merge items remove about 24 whole concepts plus many bullets. Pairing each add with a trim in the same brief keeps skimming and quizzes fast. +- Section counts: no brief exceeds the new 20-section limit (javascript has 12, system 11), so no merges are needed for that reason. +- [ ] Many sections have only 2 concepts (guide: 3–8). The P1 items filled backend Service calls, ai Training and fine-tuning, and rust Error handling; *new* P2 items would fill devops CI/CD, ethereum Consensus, rust Unsafe and FFI, and security Supply chain. Merge the rest where they stay thin. +- [ ] Growth budget: P1 added 56 concepts (619 → 675). The remaining 107 P2 and 51 P3 items include 59 *new* P2 concepts; the cut/merge items remove about 24 whole concepts plus many bullets. Pairing each add with a trim in the same brief keeps skimming and quizzes fast. ## Fundamentals @@ -79,17 +79,17 @@ Solid on arrays, DP, and graphs. Missing the problem-solving heuristics and a fe **Add** -- [ ] P1 · new · *Complexity and problem solving* › **Input size → target complexity**: at ~10⁸ simple operations per second, n ≤ 10 → O(n!), n ≤ 20 → O(2ⁿ), n ≤ 500 → O(n³), n ≤ 5,000 → O(n²), n ≤ 10⁶ → O(n log n), beyond → O(n) or O(log n). Reading the constraints picks the algorithm. -- [ ] P1 · new · *Data structures* › **Heap patterns**: **k-way merge** of k sorted lists with a size-k min-heap, O(n log k); **two heaps** (max-heap for the lower half, min-heap for the upper) give a running median in O(log n) per insert; lazy deletion for removals. -- [ ] P1 · new · *Arrays and sequences* › **Maximum subarray (Kadane)**: `cur = max(x, cur + x)`, `best = max(best, cur)`, O(n) time and O(1) space; circular variant = max(best, total − minimum subarray) unless every value is negative. The section reaches 8 concepts. -- [ ] P1 · new · *Sorting and selection* (rename "Sorting, selection, and sampling") › **Random sampling and shuffling**: **reservoir sampling** keeps the i-th item with probability k/i (one pass, O(k) memory, unknown stream length); **Fisher–Yates** swaps `a[i]` with `a[rand(0..i)]`; drawing from the whole array at each step is biased. +- [x] P1 · new · *Complexity and problem solving* › **Input size → target complexity**: at ~10⁸ simple operations per second, n ≤ 10 → O(n!), n ≤ 20 → O(2ⁿ), n ≤ 500 → O(n³), n ≤ 5,000 → O(n²), n ≤ 10⁶ → O(n log n), beyond → O(n) or O(log n). Reading the constraints picks the algorithm. +- [x] P1 · new · *Data structures* › **Heap patterns**: **k-way merge** of k sorted lists with a size-k min-heap, O(n log k); **two heaps** (max-heap for the lower half, min-heap for the upper) give a running median in O(log n) per insert; lazy deletion for removals. +- [x] P1 · new · *Arrays and sequences* › **Maximum subarray (Kadane)**: `cur = max(x, cur + x)`, `best = max(best, cur)`, O(n) time and O(1) space; circular variant = max(best, total − minimum subarray) unless every value is negative. The section reaches 8 concepts. +- [x] P1 · new · *Sorting and selection* (rename "Sorting, selection, and sampling") › **Random sampling and shuffling**: **reservoir sampling** keeps the i-th item with probability k/i (one pass, O(k) memory, unknown stream length); **Fisher–Yates** swaps `a[i]` with `a[rand(0..i)]`; drawing from the whole array at each step is biased. - [ ] P2 · extend · **Recurrence patterns** with the **Master theorem**: `T(n) = aT(n/b) + f(n)`; compare f(n) with n^(log_b a): smaller → Θ(n^(log_b a)), equal → Θ(n^(log_b a) · log n), larger → Θ(f(n)). Replaces the two worked examples. - [ ] P2 · extend · **Knapsack and one-dimensional DP**: coin change with coins in the outer loop counts **combinations**; with the amount in the outer loop it counts **permutations**. - [ ] P2 · extend · **Shortest-path choices** table: 0/1 weights → **0-1 BFS** with a deque, O(V+E); all pairs → **Floyd–Warshall** O(V³) (negative edges fine; a negative diagonal entry means a negative cycle); Dijkstra skips stale heap entries (lazy deletion). - [ ] P2 · new · *Trees and graphs* › **Cycle detection and bipartiteness**: directed → DFS with three colors (reaching a gray node = back edge = cycle); undirected → a visited neighbor that isn't the parent, or union-find; bipartite ⇔ BFS 2-coloring succeeds ⇔ no odd cycle. - [ ] P2 · new · *Trees and graphs* › **Grid and multi-source BFS**: a grid is an implicit graph (4 or 8 neighbors), O(rows × cols); seed the queue with every source at distance 0 to get "distance to the nearest X" in one pass. - [ ] P2 · extend · **Tree traversal and BST ordering**: validate a BST with inherited (min, max) bounds, not parent–child comparisons; lowest common ancestor from post-order return values, or **binary lifting** for O(log n) repeated queries. -- [ ] P2 · extend · **Comparison sorts** with what standard libraries use: Python and Java objects **Timsort** (stable), Java primitives dual-pivot quicksort, C++ `std::sort` introsort (unstable), Go pdqsort (unstable, since 1.19), Rust `sort` driftsort / `sort_unstable` ipnsort (since 1.81), JavaScript stable since ES2019. +- [ ] P2 · extend · **Comparison sorts** with what standard libraries use: Python **Timsort** (stable), C++ `std::sort` introsort (unstable), Go pdqsort (unstable, since 1.19), Rust `sort` driftsort / `sort_unstable` ipnsort (since 1.81), JavaScript stable since ES2019. - [ ] P2 · extend · **Binary search boundaries**: in a rotated sorted array one half is always sorted; check whether the target lies in it. Duplicates degrade the worst case to O(n). - [ ] P2 · extend · **Quickselect and top-k**: **3-way partition** (Dutch national flag: `<`, `=`, `>` regions in one pass) keeps quicksort and quickselect fast with many duplicates. - [ ] P3 · new · *Trees and graphs* › **Strongly connected components**: Tarjan (one DFS with low-links) or Kosaraju (DFS on the graph, then on its reverse), O(V+E); the condensation is a DAG. @@ -108,10 +108,10 @@ Strong on PostgreSQL and InnoDB internals. Weaker on everyday SQL pitfalls, inde **Add** -- [ ] P1 · new · *SQL gotchas* › **Join pitfalls**: a condition on the right table in `WHERE` turns a `LEFT JOIN` into an inner join, so put it in `ON`; joining two one-to-many children multiplies rows and inflates `SUM`/`COUNT` (aggregate each in a subquery first); `EXISTS`/`NOT EXISTS` are semi/anti-joins and never duplicate rows. -- [ ] P1 · new · *Query execution and tuning* › **Why an index isn't used**: low selectivity (the planner prefers a sequential scan when many rows match), leading-wildcard `LIKE '%x'` (needs a trigram GIN index), `LIKE 'x%'` needs C collation or `text_pattern_ops`, implicit casts, `OR` across columns, stale statistics. Scan types: Seq, Index, Index Only, **Bitmap Heap** (combines several indexes). Absorbs **Reading EXPLAIN ANALYZE**. -- [ ] P1 · new · *Non-relational stores* › **Redis eviction, expiry, and messaging**: `maxmemory-policy` defaults to **`noeviction`**, so writes fail when memory is full; caches use `allkeys-lru`/`allkeys-lfu`, while `volatile-*` evicts only keys with a TTL; expired keys are removed lazily on access plus by periodic sampling; pub/sub is fire-and-forget, Streams add persistence, consumer groups, and acks. -- [ ] P1 · new · *Non-relational stores* › **Document stores (MongoDB)**: embed what's read together, reference unbounded or shared data; **16 MB** document limit; write concern `w: "majority"` (default since 5.0), since `w: 1` can lose acknowledged writes on failover; multi-document transactions (4.0 for replica sets, 4.2 sharded) are costly, so design for single-document atomicity. +- [x] P1 · new · *SQL gotchas* › **Join pitfalls**: a condition on the right table in `WHERE` turns a `LEFT JOIN` into an inner join, so put it in `ON`; joining two one-to-many children multiplies rows and inflates `SUM`/`COUNT` (aggregate each in a subquery first); `EXISTS`/`NOT EXISTS` are semi/anti-joins and never duplicate rows. +- [x] P1 · new · *Query execution and tuning* › **Why an index isn't used**: low selectivity (the planner prefers a sequential scan when many rows match), leading-wildcard `LIKE '%x'` (needs a trigram GIN index), `LIKE 'x%'` needs C collation or `text_pattern_ops`, implicit casts, `OR` across columns, stale statistics. Scan types: Seq, Index, Index Only, **Bitmap Heap** (combines several indexes). Absorbs **Reading EXPLAIN ANALYZE**. +- [x] P1 · new · *Non-relational stores* › **Redis eviction, expiry, and messaging**: `maxmemory-policy` defaults to **`noeviction`**, so writes fail when memory is full; caches use `allkeys-lru`/`allkeys-lfu`, while `volatile-*` evicts only keys with a TTL; expired keys are removed lazily on access plus by periodic sampling; pub/sub is fire-and-forget, Streams add persistence, consumer groups, and acks. +- [x] P1 · new · *Non-relational stores* › **Document stores (MongoDB)**: embed what's read together, reference unbounded or shared data; **16 MB** document limit; write concern `w: "majority"` (default since 5.0), since `w: 1` can lose acknowledged writes on failover; multi-document transactions (4.0 for replica sets, 4.2 sharded) are costly, so design for single-document atomicity. - [ ] P2 · new · *Transactions and isolation* › **Implementing serializability**: actual serial execution (Redis, VoltDB: one thread, short transactions), **two-phase locking** (readers and writers block each other; MySQL `SERIALIZABLE`, SQL Server), **SSI** (optimistic, aborts on dangerous conflicts; PostgreSQL, CockroachDB). - [ ] P2 · extend · **Anomalies × isolation levels** table: add lost-update and write-skew columns and a snapshot-isolation row, so PostgreSQL RR vs MySQL RR read off one matrix; then shorten the two engine concepts. - [ ] P2 · new · *Schema design* › **Timestamps and time zones**: `timestamptz` stores a UTC instant and converts on display; `timestamp` (no zone) silently changes meaning when the session zone changes; `now()` is the transaction start time, `clock_timestamp()` the actual time. App-level rules go in backend. @@ -136,14 +136,14 @@ Strong on PostgreSQL and InnoDB internals. Weaker on everyday SQL pitfalls, inde ### Distributed Systems -Strong and dense. At the 10-section limit, so additions go inside existing sections. +Strong and dense. **Add** -- [ ] P1 · new · *Transactions across services* › **Delivery guarantees** (absorbs Effectively-once processing): at-most-once = ack or commit the offset **before** processing; at-least-once = after (a crash between effect and ack redelivers); exactly-once *delivery* is impossible, exactly-once *effect* = at-least-once + idempotent handling, or one transaction covering the effect and the offset. -- [ ] P1 · extend · **Physical clocks and TrueTime**: measure durations, timeouts, and leases with the **monotonic clock** (`CLOCK_MONOTONIC`, Go's `time.Since`, `performance.now()`); wall-clock time jumps on NTP steps, leap-second smearing, and VM migration. -- [ ] P1 · new · *Stream processing* › **Change data capture**: log-based CDC (Debezium) reads the WAL or binlog, so it sees every change in commit order, deletes included, with no dual writes; polling `updated_at` misses deletes and same-timestamp rows; start from a consistent snapshot, then stream from its log position; ordering holds per key. -- [ ] P1 · extend · **Kafka ordering and consumer groups**: adding partitions remaps `hash(key) % partitions` and **breaks per-key ordering** for existing keys, and the count can't be decreased, so size partitions up front; consumer **lag** is the health metric to alert on. +- [x] P1 · new · *Transactions across services* › **Delivery guarantees** (absorbs Effectively-once processing): at-most-once = ack or commit the offset **before** processing; at-least-once = after (a crash between effect and ack redelivers); exactly-once *delivery* is impossible, exactly-once *effect* = at-least-once + idempotent handling, or one transaction covering the effect and the offset. +- [x] P1 · extend · **Physical clocks and TrueTime**: measure durations, timeouts, and leases with the **monotonic clock** (`CLOCK_MONOTONIC`, Go's `time.Since`, `performance.now()`); wall-clock time jumps on NTP steps, leap-second smearing, and VM migration. +- [x] P1 · new · *Stream processing* › **Change data capture**: log-based CDC (Debezium) reads the WAL or binlog, so it sees every change in commit order, deletes included, with no dual writes; polling `updated_at` misses deletes and same-timestamp rows; start from a consistent snapshot, then stream from its log position; ordering holds per key. +- [x] P1 · extend · **Kafka ordering and consumer groups**: adding partitions remaps `hash(key) % partitions` and **breaks per-key ordering** for existing keys, and the count can't be decreased, so size partitions up front; consumer **lag** is the health metric to alert on. - [ ] P2 · new · *Partitioning* › **Rebalancing partitions**: `hash % N` moves almost every key when N changes; either a **fixed, large number of partitions** moved whole between nodes (Kafka, Elasticsearch, Couchbase) or **dynamic splitting** of large ranges (HBase, MongoDB, CockroachDB, Spanner); automatic rebalancing during a failure can cascade. - [ ] P2 · new · *Consensus and coordination* › **Coordination services**: ZooKeeper ephemeral nodes and etcd leases vanish with the session, tying membership and locks to liveness; watches notify on change; a lock = sequential node + watching only the predecessor (no herd effect); ZooKeeper reads come from any replica and can be stale (`sync()` first), etcd reads are linearizable by default. - [ ] P2 · extend · **Raft**: **Pre-Vote** stops a node rejoining after a partition from bumping the term and deposing a healthy leader; typical timing is a ~100 ms heartbeat and ~1 s election timeout (etcd defaults). @@ -158,7 +158,7 @@ Strong and dense. At the 10-section limit, so additions go inside existing secti **Trim** - [ ] merge · **Window types** (one bullet) into **Event time and watermarks**; frees a slot in Stream processing for CDC. -- [ ] merge · **Effectively-once processing** into the Delivery guarantees concept above. +- [x] merge · **Effectively-once processing** into the Delivery guarantees concept above. ### Networking @@ -166,10 +166,10 @@ The smallest brief (5 sections, 22 concepts). Good fundamentals, light on troubl **Add** -- [ ] P1 · new · *End to end* › **Connection failure signatures**: **refused** = RST (host reachable, nothing listening); **timeout** = SYN dropped (firewall, security group, dead host), and Linux retries a SYN for ~**127 s** by default, so set connect timeouts; **reset by peer** mid-stream = the peer crashed or a middlebox hit its idle timeout; a proxy's **502** = upstream refused or reset, **504** = upstream too slow. -- [ ] P1 · new · *TCP* › **Retransmission and loss recovery**: the RTO comes from smoothed RTT, with a Linux floor of **200 ms** (initial 1 s) and doubling per retry, so one lost packet on a quiet connection adds ≥ 200 ms (a classic p99 spike); **fast retransmit** after 3 duplicate ACKs; SACK names exactly which segments are missing. -- [ ] P1 · new · *IP and routing* › **Routing tables**: the most specific route wins (**longest prefix match**: `/32` beats `/24` beats `0.0.0.0/0`); the default route points at the gateway; ARP resolves the next hop's MAC on the local link, so MACs change per hop while IPs stay end to end unless NAT rewrites them. -- [ ] P1 · new · *HTTP versions* (rename "HTTP") › **Client IP behind proxies**: L7 proxies append `X-Forwarded-For`, and clients can forge the earlier entries, so trust only those added by your own proxies (count from the right); L4 load balancers preserve the source IP or pass it with the **PROXY protocol**; rate limits and audit logs depend on getting this right. +- [x] P1 · new · *End to end* › **Connection failure signatures**: **refused** = RST (host reachable, nothing listening); **timeout** = SYN dropped (firewall, security group, dead host), and Linux retries a SYN for ~**127 s** by default, so set connect timeouts; **reset by peer** mid-stream = the peer crashed or a middlebox hit its idle timeout; a proxy's **502** = upstream refused or reset, **504** = upstream too slow. +- [x] P1 · new · *TCP* › **Retransmission and loss recovery**: the RTO comes from smoothed RTT, with a Linux floor of **200 ms** (initial 1 s) and doubling per retry, so one lost packet on a quiet connection adds ≥ 200 ms (a classic p99 spike); **fast retransmit** after 3 duplicate ACKs; SACK names exactly which segments are missing. +- [x] P1 · new · *IP and routing* › **Routing tables**: the most specific route wins (**longest prefix match**: `/32` beats `/24` beats `0.0.0.0/0`); the default route points at the gateway; ARP resolves the next hop's MAC on the local link, so MACs change per hop while IPs stay end to end unless NAT rewrites them. +- [x] P1 · new · *HTTP versions* (rename "HTTP") › **Client IP behind proxies**: L7 proxies append `X-Forwarded-For`, and clients can forge the earlier entries, so trust only those added by your own proxies (count from the right); L4 load balancers preserve the source IP or pass it with the **PROXY protocol**; rate limits and audit logs depend on getting this right. - [ ] P2 · new · *TCP* › **Connection states for debugging** (table): SYN_SENT (no SYN-ACK: filtered?), SYN_RECV (half-open: SYN flood?), ESTABLISHED, FIN_WAIT_2 (peer hasn't closed), CLOSE_WAIT (your app hasn't closed), TIME_WAIT (you closed first). Absorbs the CLOSE_WAIT bullet from **Teardown and TIME_WAIT**. - [ ] P2 · extend · **Handshake and connection queues**: the listen backlog is capped by `net.core.somaxconn` (4096 since Linux 5.4); `SO_REUSEPORT` lets several processes bind one port, each with its own kernel-balanced accept queue (Nginx, Envoy). - [ ] P2 · extend · **Resolution path**: Kubernetes Pods resolve with `ndots:5`, so an external name with fewer dots first tries every search domain (several wasted lookups per call); use FQDNs with a trailing dot or lower `ndots`. @@ -190,10 +190,10 @@ Good coverage of memory and I/O. Missing process states, a safe file-replace pat **Add** -- [ ] P1 · extend · **Durability and fsync**: **atomic file replace**. Write a temp file → `fsync` it → `rename` it over the target (atomic on POSIX) → `fsync` the directory; readers see the old or the new file, never a torn one. -- [ ] P1 · new · *Processes and threads* › **Process states** (table): R (running or runnable), S (interruptible sleep), **D** (uninterruptible, usually disk or NFS I/O; even `SIGKILL` waits, and it counts in load average), Z (zombie), T (stopped). -- [ ] P1 · new · *Synchronization* › **Atomics, CAS, and the ABA problem**: compare-and-swap loops build lock-free structures and mutex fast paths; **ABA** = a value goes A → B → A and a stale CAS succeeds, fixed with version-tagged pointers or safe reclamation (hazard pointers, epochs); under heavy contention CAS loops thrash the cache line; x86 is TSO, ARM weakly ordered (orderings in [rust.md](rust.md)). -- [ ] P1 · new · *Performance analysis* › **Memory hierarchy latencies**: L1 ~1 ns, L2 ~4 ns, L3 ~10–40 ns, DRAM ~100 ns, NVMe read ~10–100 µs; sequential access and contiguous layouts (arrays over linked lists, struct-of-arrays) win through prefetching and cache lines. system.md keeps its short interview list. +- [x] P1 · extend · **Durability and fsync**: **atomic file replace**. Write a temp file → `fsync` it → `rename` it over the target (atomic on POSIX) → `fsync` the directory; readers see the old or the new file, never a torn one. *Done as a separate concept,* Atomic file replace. +- [x] P1 · new · *Processes and threads* › **Process states** (table): R (running or runnable), S (interruptible sleep), **D** (uninterruptible, usually disk or NFS I/O; even `SIGKILL` waits, and it counts in load average), Z (zombie), T (stopped). +- [x] P1 · new · *Synchronization* › **Atomics, CAS, and the ABA problem**: compare-and-swap loops build lock-free structures and mutex fast paths; **ABA** = a value goes A → B → A and a stale CAS succeeds, fixed with version-tagged pointers or safe reclamation (hazard pointers, epochs); under heavy contention CAS loops thrash the cache line; x86 is TSO, ARM weakly ordered (orderings in [rust.md](rust.md)). +- [x] P1 · new · *Performance analysis* › **Memory hierarchy latencies**: L1 ~1 ns, L2 ~4 ns, L3 ~10–40 ns, DRAM ~100 ns, NVMe read ~10–100 µs; sequential access and contiguous layouts (arrays over linked lists, struct-of-arrays) win through prefetching and cache lines. system.md keeps its short interview list. - [ ] P2 · new · *Processes and threads* › **IPC mechanisms**: pipes (one-way byte stream), Unix domain sockets (two-way, faster than loopback TCP, pass file descriptors via `SCM_RIGHTS`), shared memory + a lock (no copies), signals (no payload); the Docker and containerd APIs listen on Unix sockets. - [ ] P2 · new · *Memory* › **Heap allocators and RSS growth**: `malloc` serves large requests (≥ 128 KB by default) with `mmap` and small ones from arenas; glibc creates up to 8 arenas per core on 64-bit, so multi-threaded services fragment and RSS only grows; `MALLOC_ARENA_MAX=2`, or jemalloc/tcmalloc/mimalloc. Memory already has 8 concepts: merge **Page faults** into **Virtual memory and the TLB** to make room. - [ ] P2 · extend · **CPU quotas and throttling**: pool sizing. CPU-bound ≈ number of cores (or the quota); blocking I/O ≈ cores × (1 + wait/compute), or derive it from **Little's law** (see system.md). @@ -214,10 +214,10 @@ Strong building blocks and classic designs. Missing capacity math, metric aggreg **Add** -- [ ] P1 · extend · **Back-of-envelope conversions**: **Little's law** L = λ × W, so in-flight requests = throughput × latency (1,000 RPS × 200 ms = 200 concurrent requests → threads, connections, pool sizes). -- [ ] P1 · extend · **Observability**: percentiles **can't be averaged** across hosts or windows, so merge histograms and then take p99; **high-cardinality labels** (user ID, request ID) multiply Prometheus time series, so keep them in logs and traces. -- [ ] P1 · new · *Reliability and operations* › **Multi-region and disaster recovery**: tiers by RTO/RPO, from backup and restore (hours) → pilot light → warm standby → active-active (near zero); async cross-region replication means RPO > 0; active-active needs conflict handling or per-record home regions, plus global routing (GeoDNS, anycast); rehearse failover. Absorbs the RPO/RTO bullet from **Availability math**. -- [ ] P1 · new · *Classic designs: user-facing* › **Video streaming**: upload to object storage → transcoding DAG (split into chunks, encode in parallel) → renditions at several bitrates → **HLS/DASH** segments (2–10 s) plus a manifest → CDN; the player picks a rendition per segment (**adaptive bitrate**); pre-warm popular content at the edge. +- [x] P1 · extend · **Back-of-envelope conversions**: **Little's law** L = λ × W, so in-flight requests = throughput × latency (1,000 RPS × 200 ms = 200 concurrent requests → threads, connections, pool sizes). +- [x] P1 · extend · **Observability**: percentiles **can't be averaged** across hosts or windows, so merge histograms and then take p99; **high-cardinality labels** (user ID, request ID) multiply Prometheus time series, so keep them in logs and traces. +- [x] P1 · new · *Reliability and operations* › **Multi-region and disaster recovery**: tiers by RTO/RPO, from backup and restore (hours) → pilot light → warm standby → active-active (near zero); async cross-region replication means RPO > 0; active-active needs conflict handling or per-record home regions, plus global routing (GeoDNS, anycast); rehearse failover. Absorbs the RPO/RTO bullet from **Availability math**. +- [x] P1 · new · *Classic designs: user-facing* › **Video streaming**: upload to object storage → transcoding DAG (split into chunks, encode in parallel) → renditions at several bitrates → **HLS/DASH** segments (2–10 s) plus a manifest → CDN; the player picks a rendition per segment (**adaptive bitrate**); pre-warm popular content at the edge. - [ ] P2 · extend · **Load balancing**: **power of two choices**. Sample two backends and pick the less loaded: near-optimal balance without global state, and no herding onto the one server stale stats call "least loaded". - [ ] P2 · new · *Classic designs: user-facing* › **Top-K and trending**: per-window counts in a stream processor; exact counts + a min-heap for moderate cardinality, **count-min sketch + heap** for huge key spaces; merging per-partition top-k is approximate, so fetch k′ > k per partition; sharded counters for view and like counts. - [ ] P2 · new · *Classic designs: data and infrastructure* › **Distributed key-value store**: the Dynamo-style synthesis. Consistent hashing + virtual nodes, N replicas with W/R quorums, hinted handoff, Merkle anti-entropy, vector clocks or LWW, gossip membership; each piece links to distributed.md. @@ -242,10 +242,10 @@ Strong runtime and concurrency coverage. Missing several everyday gotchas; a few **Add** -- [ ] P1 · new · *Standard library gotchas* › **encoding/json gotchas**: numbers decode into `any` as **float64**, so IDs above 2⁵³ lose precision (`Decoder.UseNumber`); a nil slice encodes as `null`, an empty one as `[]`; unexported fields are silently skipped; `omitempty` never omits a struct, `omitzero` (1.24) does; unknown fields are ignored unless `DisallowUnknownFields`. -- [ ] P1 · extend · **Maps**: reading a nil map returns zero values, but **writing panics**, so `make` it first (a nil slice, by contrast, works with `append`). -- [ ] P1 · extend · **context.Context**: every `WithCancel`/`WithTimeout`/`WithDeadline` returns a `cancel` you must call (`defer cancel()`), or the child and its timer live until the parent ends; `go vet` reports it (`lostcancel`). -- [ ] P1 · extend · **Scheduler (GMP)**: each P has a local run queue (256 goroutines) plus a `runnext` slot; an idle P **steals half** of another P's queue; the global queue is checked every 61st scheduling round for fairness. +- [x] P1 · new · *Standard library gotchas* › **encoding/json gotchas**: numbers decode into `any` as **float64**, so IDs above 2⁵³ lose precision (`Decoder.UseNumber`); a nil slice encodes as `null`, an empty one as `[]`; unexported fields are silently skipped; `omitempty` never omits a struct, `omitzero` (1.24) does; unknown fields are ignored unless `DisallowUnknownFields`. +- [x] P1 · extend · **Maps**: reading a nil map returns zero values, but **writing panics**, so `make` it first (a nil slice, by contrast, works with `append`). +- [x] P1 · extend · **context.Context**: every `WithCancel`/`WithTimeout`/`WithDeadline` returns a `cancel` you must call (`defer cancel()`), or the child and its timer live until the parent ends; `go vet` reports it (`lostcancel`). +- [x] P1 · extend · **Scheduler (GMP)**: each P has a local run queue (256 goroutines) plus a `runnext` slot; an idle P **steals half** of another P's queue; the global queue is checked every 61st scheduling round for fairness. - [ ] P2 · new · *Standard library gotchas* › **time gotchas**: `time.Time` carries a location and a monotonic reading, so compare with `Equal`, not `==`, and don't use it as a map key; `time.Since` uses the monotonic clock; bare integers are nanoseconds (`time.Sleep(5)` sleeps 5 ns). - [ ] P2 · new · *Standard library gotchas* › **Graceful shutdown**: `signal.NotifyContext` for SIGTERM → `srv.Shutdown(ctx)` stops accepting and waits for in-flight requests, but not for hijacked connections (WebSockets); `net/http` recovers a handler panic per request, but a panic in a goroutine you started kills the process. - [ ] P2 · extend · **Error wrapping**: `%w` makes the wrapped error part of your API (callers can match it), `%v` hides it; sentinel (`io.EOF`) vs typed (`*fs.PathError`) vs opaque errors; `:=` inside a block shadows the outer `err`. @@ -264,13 +264,13 @@ Strong runtime and concurrency coverage. Missing several everyday gotchas; a few ### JavaScript -Good language-semantics coverage, but light on async ordering and engine internals; several concepts are standard-library listings, and 12 sections exceed the guide. +Good language-semantics coverage, but light on async ordering and engine internals; several concepts are standard-library listings. **Add** -- [ ] P1 · new · *Async* › **async/await ordering**: the `Promise` executor runs **synchronously**; `.then` callbacks and the code after `await` always run as microtasks, even for resolved values; inside `try`, `return promise` bypasses the `catch`, so write `return await`; an `async` function always returns a new promise. -- [ ] P1 · new · *Async* › **fetch semantics**: `fetch` rejects only on network failure; HTTP 4xx/5xx resolve with `res.ok === false`; the body can be read once (`res.clone()` to reuse it); there's no default timeout (`AbortSignal.timeout`). -- [ ] P1 · new · *Memory* › **Hidden classes and inline caches**: V8 gives objects built with the same properties in the same order a shared hidden class (shape); property-access sites cache shapes: monomorphic is fast, more than 4 shapes goes **megamorphic**; initialize every field in the constructor and avoid `delete` on hot objects. +- [x] P1 · new · *Async* › **async/await ordering**: the `Promise` executor runs **synchronously**; `.then` callbacks and the code after `await` always run as microtasks, even for resolved values; inside `try`, `return promise` bypasses the `catch`, so write `return await`; an `async` function always returns a new promise. +- [x] P1 · new · *Async* › **fetch semantics**: `fetch` rejects only on network failure; HTTP 4xx/5xx resolve with `res.ok === false`; the body can be read once (`res.clone()` to reuse it); there's no default timeout (`AbortSignal.timeout`). +- [x] P1 · new · *Memory* › **Hidden classes and inline caches**: V8 gives objects built with the same properties in the same order a shared hidden class (shape); property-access sites cache shapes: monomorphic is fast, more than 4 shapes goes **megamorphic**; initialize every field in the constructor and avoid `delete` on hot objects. - [ ] P2 · new · *Coercion and equality* › **Strings and Unicode**: strings are UTF-16, so `'😀'.length === 2` and indexing can split a surrogate pair; `for...of` and spread iterate code points; user-perceived characters need `Intl.Segmenter`; `normalize('NFC')` before comparing. - [ ] P2 · new · *Coercion and equality* › **Object vs Map**: object keys are strings or symbols (numbers coerce), ordered integer-like keys ascending, then strings by insertion, then symbols; `Map` keeps any key type in insertion order, has `size`, and handles frequent adds and deletes better; `JSON.stringify` turns a `Map` into `{}`. - [ ] P2 · new · *Node.js runtime* › **EventEmitter gotchas**: listeners run **synchronously** in registration order; an `'error'` event without a listener **throws** and crashes the process; more than 10 listeners logs a leak warning; `events.once()` returns a promise. @@ -279,14 +279,13 @@ Good language-semantics coverage, but light on async ordering and engine interna - [ ] P2 · extend · **CommonJS vs ESM**: in an import cycle ESM sees uninitialized bindings (TDZ `ReferenceError`), CommonJS a partially filled `exports` object. - [ ] P3 · extend · **Typed arrays**: browsers expose `SharedArrayBuffer` only to cross-origin-isolated pages (COOP `same-origin` + COEP `require-corp`). -**Trim / restructure** +**Trim** - [ ] cut · **Array and object helpers**: standard-library listing (`toSorted`, `with`, `groupBy`). - [ ] cut · **Promise helpers**: API listing (`withResolvers`, `try`). - [ ] cut · **Sets and iterators** bullet 1: Set method list. Keep the lazy iterator-helpers bullet. - [ ] cut · **Temporal** bullet 2: browser support status goes stale within months. - [ ] cut · **Workers, cluster, child processes** bullet 3: `spawn` vs `exec` basics. -- [ ] restructure · 12 sections → ≤ 10 (see Cross-cutting › Structure). ### Python @@ -294,10 +293,10 @@ Strong on the runtime, object model, and asyncio. Missing a few classic gotchas **Add** -- [ ] P1 · extend · **multiprocessing start methods**: with `spawn`/`forkserver` (defaults on macOS since 3.8 and on Linux since 3.14) children **re-import the main module**, so guard entry code with `if __name__ == "__main__":`; arguments and results must pickle (no lambdas, local functions, or open sockets). -- [ ] P1 · new · *Gotchas* › **Shared class attributes**: a mutable class attribute (`items = []` in the class body) is shared by every instance; `self.items.append(x)` mutates the shared list, while `self.items = [...]` creates an instance attribute that shadows it. -- [ ] P1 · new · *Gotchas* › **Numeric gotchas**: `//` and `%` floor toward −∞ (`-7 // 2 == -4`, `-7 % 2 == 1`), unlike C, Java, Go, and JavaScript; `round()` rounds half to even (`round(2.5) == 2`); ints never overflow; use `decimal.Decimal` for money. -- [ ] P1 · new · *Gotchas* › **Recursion depth**: the default limit is **1000** (`RecursionError`) and there's no tail-call optimization, so deep DFS or memoized recursion needs an explicit stack or a careful `sys.setrecursionlimit`. +- [x] P1 · extend · **multiprocessing start methods**: with `spawn`/`forkserver` (defaults on macOS since 3.8 and on Linux since 3.14) children **re-import the main module**, so guard entry code with `if __name__ == "__main__":`; arguments and results must pickle (no lambdas, local functions, or open sockets). +- [x] P1 · new · *Gotchas* › **Shared class attributes**: a mutable class attribute (`items = []` in the class body) is shared by every instance; `self.items.append(x)` mutates the shared list, while `self.items = [...]` creates an instance attribute that shadows it. *Done in* Object model *instead, to keep Gotchas at 8.* +- [x] P1 · new · *Gotchas* › **Numeric gotchas**: `//` and `%` floor toward −∞ (`-7 // 2 == -4`, `-7 % 2 == 1`), unlike C, Go, Rust, and JavaScript; `round()` rounds half to even (`round(2.5) == 2`); ints never overflow; use `decimal.Decimal` for money. +- [x] P1 · new · *Gotchas* › **Recursion depth**: the default limit is **1000** (`RecursionError`) and there's no tail-call optimization, so deep DFS or memoized recursion needs an explicit stack or a careful `sys.setrecursionlimit`. - [ ] P2 · new · *Concurrency* › **WSGI vs ASGI servers**: WSGI (Flask, Django) handles one request per worker thread or process; ASGI (FastAPI, Starlette) runs an event loop per worker; Gunicorn pre-forks workers, and refcount updates dirty the copy-on-write pages; `gc.freeze()` (3.7) before forking and **immortal objects** (3.12, PEP 683) keep them shared. - [ ] P2 · new · *Concurrency* › **contextvars**: a `ContextVar` carries request-scoped state; each asyncio task runs in a **copy** of the context taken at creation, making it the async-safe replacement for thread-locals. - [ ] P2 · extend · **Descriptors** (or new **Attribute lookup**): `obj.x` checks data descriptors on the type → the instance `__dict__` → non-data descriptors and class attributes → `__getattr__` (only on failure); `__getattribute__` runs on every access. @@ -320,10 +319,10 @@ Strong on ownership, traits, and async. Missing numeric semantics, the standard **Add** -- [ ] P1 · new · *Error handling* › **Integer overflow and casts**: overflow **panics in debug and wraps in release** (unless `overflow-checks = true`), so state intent with `checked_`, `wrapping_`, `saturating_`, or `overflowing_`; `as` truncates between integer types and saturates float → int (NaN → 0). -- [ ] P1 · new · *Traits and generics* › **Eq, Ord, and Hash**: `PartialEq`/`PartialOrd` allow incomparable values (NaN), `Eq`/`Ord` promise a total order; `f64` implements neither, nor `Hash`, so it can't key a `HashMap` or use `.sort()` (use `total_cmp` or an ordered wrapper); `Hash` must agree with `Eq`; derived `Ord` compares fields in declaration order. -- [ ] P1 · new · *Smart pointers and memory* › **Layout and niche optimization**: `Option<&T>`, `Option>`, and `Option` are the size of the inner type (the null or zero niche encodes `None`); the default `repr(Rust)` may reorder fields, `repr(C)` is for FFI; `&str`, `&[T]`, and `&dyn Trait` are two words; an enum is its largest variant plus a tag. -- [ ] P1 · extend · **Futures and executors**: `tokio::spawn` needs a `Send + 'static` future, so move owned data or `Arc` clones in; Tokio's default runtime is multi-threaded work-stealing, and `current_thread` + `LocalSet` runs non-`Send` futures; `JoinSet` manages groups of tasks. +- [x] P1 · new · *Error handling* › **Integer overflow and casts**: overflow **panics in debug and wraps in release** (unless `overflow-checks = true`), so state intent with `checked_`, `wrapping_`, `saturating_`, or `overflowing_`; `as` truncates between integer types and saturates float → int (NaN → 0). +- [x] P1 · new · *Traits and generics* › **Eq, Ord, and Hash**: `PartialEq`/`PartialOrd` allow incomparable values (NaN), `Eq`/`Ord` promise a total order; `f64` implements neither, nor `Hash`, so it can't key a `HashMap` or use `.sort()` (use `total_cmp` or an ordered wrapper); `Hash` must agree with `Eq`; derived `Ord` compares fields in declaration order. +- [x] P1 · new · *Smart pointers and memory* › **Layout and niche optimization**: `Option<&T>`, `Option>`, and `Option` are the size of the inner type (the null or zero niche encodes `None`); the default `repr(Rust)` may reorder fields, `repr(C)` is for FFI; `&str`, `&[T]`, and `&dyn Trait` are two words; an enum is its largest variant plus a tag. +- [x] P1 · extend · **Futures and executors**: `tokio::spawn` needs a `Send + 'static` future, so move owned data or `Arc` clones in; Tokio's default runtime is multi-threaded work-stealing, and `current_thread` + `LocalSet` runs non-`Send` futures; `JoinSet` manages groups of tasks. - [ ] P2 · new · *Unsafe and FFI* › **FFI boundaries**: `#[repr(C)]` types and `extern "C"` functions; `CString`/`CStr` for NUL-terminated strings (a pointer from a temporary `CString` dangles); a panic escaping an `extern "C"` function **aborts since 1.81** (UB before), so use `extern "C-unwind"` or `catch_unwind`; bindgen and cbindgen generate the bindings. - [ ] P2 · new · *Lifetimes* › **Variance and PhantomData**: `&'a T` is covariant; `&'a mut T` is **invariant** in `T` (otherwise a shorter-lived reference could be written through it); `Cell` is invariant; `PhantomData` declares ownership and variance for types that hold raw pointers. - [ ] P2 · new · *Smart pointers and memory* › **Collections gotchas**: `HashMap` hashes with randomly keyed SipHash-1-3, which resists HashDoS but is slow, so swap in FxHash or ahash for trusted keys; the `entry` API avoids a double lookup; `BTreeMap` for ordered iteration and ranges; `swap_remove` is O(1). @@ -345,10 +344,10 @@ The most thorough brief (254 lines). Few additions; trimming version trivia matt **Add** -- [ ] P1 · new · *Gas optimization* (deployment cost) or *Upgradeability* › **Clones and factories**: an **EIP-1167 minimal proxy** (45 bytes of runtime code delegating to a fixed implementation) makes deploying many instances cheap; `CREATE2` + salt gives addresses known before deployment; clones can't be upgraded and need an initializer; bind the salt to the deployer and parameters so a front-runner can't claim the address with other arguments. -- [ ] P1 · extend · **Access control** with admin keys and governance: `Ownable2Step` makes the new owner accept, so a typo can't brick ownership; admin actions go through a **timelock** (plus a multisig) that gives users an exit window; flash-loan governance attacks (Beanstalk, April 2022, ~$182M) are stopped by snapshotting voting power at proposal creation (`ERC20Votes` checkpoints) and by voting delays. -- [ ] P1 · extend · **Signature replay and malleability**: to accept signatures from smart-contract wallets (Safe, ERC-4337, 7702-delegated EOAs), verify through **`SignatureChecker`** (ECDSA or ERC-1271 `isValidSignature`); ERC-6492 wraps signatures from wallets not yet deployed. -- [ ] P1 · new · *Security* › **Front-running and slippage**: public-mempool transactions can be front-run or sandwiched, so swap and liquidity functions take a `minAmountOut` and a `deadline` chosen off-chain (never derived on-chain from the manipulable spot price); commit-reveal for bids and games. MEV mechanics live in ethereum.md. Security reaches 9 concepts: split it into *Security* (reentrancy, access, signatures, randomness, DoS) and *Integration risks* (tokens, oracles, front-running, rounding). +- [x] P1 · new · *Gas optimization* (deployment cost) or *Upgradeability* › **Clones and factories**: an **EIP-1167 minimal proxy** (45 bytes of runtime code delegating to a fixed implementation) makes deploying many instances cheap; `CREATE2` + salt gives addresses known before deployment; clones can't be upgraded and need an initializer; bind the salt to the deployer and parameters so a front-runner can't claim the address with other arguments. *Done in* Gas optimization. +- [x] P1 · extend · **Access control** with admin keys and governance: `Ownable2Step` makes the new owner accept, so a typo can't brick ownership; admin actions go through a **timelock** (plus a multisig) that gives users an exit window; flash-loan governance attacks (Beanstalk, April 2022, ~$182M) are stopped by snapshotting voting power at proposal creation (`ERC20Votes` checkpoints) and by voting delays. *Done as a separate concept,* Admin keys and governance. +- [x] P1 · extend · **Signature replay and malleability**: to accept signatures from smart-contract wallets (Safe, ERC-4337, 7702-delegated EOAs), verify through **`SignatureChecker`** (ECDSA or ERC-1271 `isValidSignature`); ERC-6492 wraps signatures from wallets not yet deployed. +- [x] P1 · new · *Security* › **Front-running and slippage**: public-mempool transactions can be front-run or sandwiched, so swap and liquidity functions take a `minAmountOut` and a `deadline` chosen off-chain (never derived on-chain from the manipulable spot price); commit-reveal for bids and games. MEV mechanics live in ethereum.md. Security reaches 9 concepts: split it into *Security* (reentrancy, access, signatures, randomness, DoS) and *Integration risks* (tokens, oracles, front-running, rounding). *Security is now split into* Security *and* Integration risks. - [ ] P2 · new · *Gas optimization* › **Merkle allowlists**: store one root instead of a mapping and verify proofs with OpenZeppelin `MerkleProof`; **double-hash the leaves** so a 64-byte internal node can't pass as a leaf (second preimage); record claims in a bitmap to block double claims. - [ ] P2 · extend · **Proxy storage and initializers**: legacy **storage gaps** (`uint256[50] __gap`) in upgradeable base contracts; shrink the gap by the slots you add. ERC-7201 namespaces replace them. - [ ] P3 · new · *Security* › **Emergency controls**: `Pausable` with a guardian role, per-window outflow limits (bridges, lending) to cap losses during an exploit; pausing is itself a centralization risk to disclose. @@ -370,9 +369,9 @@ Good type-system depth. The biggest gap is the runtime boundary (types vanish), **Add** -- [ ] P1 · new · *Typing patterns* › **Runtime validation at boundaries**: types are erased, so `JSON.parse`, `res.json()`, env vars, and `as` casts yield unchecked data; parse with a schema library (Zod, Valibot, ArkType) and derive the type from the schema (`z.infer`) so the two can't drift; type untrusted input as `unknown`, not `any`. -- [ ] P1 · new · *Type system semantics* › **`{}`, `object`, and index signatures**: **`{}` means any non-nullish value** (strings and numbers included), not "empty object"; `object` = any non-primitive; `Record` is a truly empty object; an index signature makes every key "present" unless `noUncheckedIndexedAccess` is on. -- [ ] P1 · new · *Type system semantics* › **Function assignability**: a function returning a value is assignable to one returning `void` (so `arr.forEach(x => out.push(x))` compiles); a function with fewer parameters is assignable to one with more (callbacks may ignore arguments). +- [x] P1 · new · *Typing patterns* › **Runtime validation at boundaries**: types are erased, so `JSON.parse`, `res.json()`, env vars, and `as` casts yield unchecked data; parse with a schema library (Zod, Valibot, ArkType) and derive the type from the schema (`z.infer`) so the two can't drift; type untrusted input as `unknown`, not `any`. +- [x] P1 · new · *Type system semantics* › **`{}`, `object`, and index signatures**: **`{}` means any non-nullish value** (strings and numbers included), not "empty object"; `object` = any non-primitive; `Record` is a truly empty object; an index signature makes every key "present" unless `noUncheckedIndexedAccess` is on. +- [x] P1 · new · *Type system semantics* › **Function assignability**: a function returning a value is assignable to one returning `void` (so `arr.forEach(x => out.push(x))` compiles); a function with fewer parameters is assignable to one with more (callbacks may ignore arguments). - [ ] P2 · new · *Declarations and runtime features* › **`private` vs `#private`**: TS `private`, `protected`, and `readonly` are compile-time only, visible at runtime and reachable via `obj['x']`; ECMAScript `#x` is engine-enforced and hidden from `Object.keys` and JSON. - [ ] P2 · new · *Narrowing* (rename "Narrowing and widening") › **Literal widening**: `let x = 'a'` is `string`, `const x = 'a'` is `'a'`; object literal properties widen (`{ kind: 'a' }` → `{ kind: string }`) unless `as const`, `satisfies`, or a contextual type applies; the usual cause of "string is not assignable to 'a' | 'b'". - [ ] P2 · extend · **Conditional types**: `C` distributes over an empty union and yields `never`, so test with `[T] extends [never]`; `infer U extends string` (4.7) constrains the inferred type. @@ -394,9 +393,9 @@ Good API and reliability patterns. Missing schema evolution, tenancy, time handl **Add** -- [ ] P1 · new · *API design* › **Schema evolution**: **backward compatible** = new readers read old data, **forward compatible** = old readers read new data; Protobuf: never reuse or renumber a field (mark it `reserved`), adding fields is safe, proto3 has no `required`, unknown fields survive round trips; Avro + Schema Registry enforces BACKWARD/FORWARD/FULL modes; JSON consumers must ignore unknown fields (tolerant reader). -- [ ] P1 · new · *Data access* › **Multi-tenancy models**: shared tables with a `tenant_id` (cheapest; every query must filter, so enforce it with PostgreSQL **row-level security**, which the table owner bypasses unless `FORCE ROW LEVEL SECURITY`) → schema per tenant → database per tenant (strongest isolation, per-tenant restore, most operations work); move noisy tenants to their own shard. -- [ ] P1 · new · *Data access* › **Time handling**: store and send instants in UTC (RFC 3339 with an offset); for future local-time events (meetings, schedules) store the local time + an **IANA zone**, since offsets and DST rules change; a DST switch skips or repeats local times, so a 02:30 cron runs twice or never. +- [x] P1 · new · *API design* › **Schema evolution**: **backward compatible** = new readers read old data, **forward compatible** = old readers read new data; Protobuf: never reuse or renumber a field (mark it `reserved`), adding fields is safe, proto3 has no `required`, unknown fields survive round trips; Avro + Schema Registry enforces BACKWARD/FORWARD/FULL modes; JSON consumers must ignore unknown fields (tolerant reader). *Done in* Service calls *instead, since API design already had 8.* +- [x] P1 · new · *Data access* › **Multi-tenancy models**: shared tables with a `tenant_id` (cheapest; every query must filter, so enforce it with PostgreSQL **row-level security**, which the table owner bypasses unless `FORCE ROW LEVEL SECURITY`) → schema per tenant → database per tenant (strongest isolation, per-tenant restore, most operations work); move noisy tenants to their own shard. +- [x] P1 · new · *Data access* › **Time handling**: store and send instants in UTC (RFC 3339 with an offset); for future local-time events (meetings, schedules) store the local time + an **IANA zone**, since offsets and DST rules change; a DST switch skips or repeats local times, so a 02:30 cron runs twice or never. - [ ] P2 · new · *Service calls* › **Service-to-service authentication**: mTLS with workload identities (SPIFFE, a mesh), OAuth client credentials (short-lived JWTs with `aud`), or signed requests (HMAC, AWS SigV4); API keys are long-lived bearer secrets, so store them hashed, give them a scannable prefix, and rotate them. Mechanisms in security.md. - [ ] P2 · extend · **Timeouts and deadline propagation**: a short connect timeout (~1 s) separate from the read or overall timeout; propagate the W3C `traceparent` header along with the deadline. - [ ] P2 · new · *Lifecycle and config* › **Service internals**: hexagonal architecture (ports and adapters) keeps the domain free of framework and database imports; a DDD **aggregate** is the consistency and transaction boundary (one aggregate per transaction, others referenced by ID); **bounded contexts** map to service boundaries. @@ -416,10 +415,10 @@ Good breadth. Missing the React data-fetching and state-update gotchas that inte **Add** -- [ ] P1 · new · *React hooks pitfalls* › **Data fetching in effects**: responses can arrive out of order, so ignore stale ones in cleanup (an `ignore` flag or `AbortController`); effect-based fetching causes **waterfalls** (parent fetch → child mounts → child fetch), so hoist fetching to route loaders or a query library; Strict Mode fires the request twice in development. -- [ ] P1 · new · *React rendering model* › **State snapshots and keys**: state is a **snapshot** per render, so `setCount(count + 1)` twice adds 1 while `setCount(c => c + 1)` twice adds 2; changing a component's `key` resets its state; `useRef` holds mutable values without re-rendering. -- [ ] P1 · new · *Caching* › **Browser storage**: cookies (~4 KB, sent with every request), `localStorage` (~5 MB per origin, **synchronous**, strings only), `sessionStorage` (per tab), **IndexedDB** (async, large, structured, available in workers), the Cache API (for service workers); any XSS can read all of them (tokens in security.md). -- [ ] P1 · new · *React rendering model* › **Error boundaries**: they catch render and lifecycle errors in a subtree and show a fallback; still written as **class components** (or `react-error-boundary`); they don't catch errors in event handlers or async code. +- [x] P1 · new · *React hooks pitfalls* › **Data fetching in effects**: responses can arrive out of order, so ignore stale ones in cleanup (an `ignore` flag or `AbortController`); effect-based fetching causes **waterfalls** (parent fetch → child mounts → child fetch), so hoist fetching to route loaders or a query library; Strict Mode fires the request twice in development. +- [x] P1 · new · *React rendering model* › **State snapshots and keys**: state is a **snapshot** per render, so `setCount(count + 1)` twice adds 1 while `setCount(c => c + 1)` twice adds 2; changing a component's `key` resets its state; `useRef` holds mutable values without re-rendering. +- [x] P1 · new · *Caching* › **Browser storage**: cookies (~4 KB, sent with every request), `localStorage` (~5 MB per origin, **synchronous**, strings only), `sessionStorage` (per tab), **IndexedDB** (async, large, structured, available in workers), the Cache API (for service workers); any XSS can read all of them (tokens in security.md). +- [x] P1 · new · *React rendering model* › **Error boundaries**: they catch render and lifecycle errors in a subtree and show a fallback; still written as **class components** (or `react-error-boundary`); they don't catch errors in event handlers or async code. - [ ] P2 · new · *React hooks pitfalls* › **useLayoutEffect vs useEffect**: `useEffect` runs after paint; `useLayoutEffect` runs after DOM mutation but **before paint**, for measuring layout without flicker, at the cost of blocking paint. - [ ] P2 · extend · **Core Web Vitals**: rankings use **field data** (CrUX, p75 over 28 days, mobile and desktop separately); a page-load Lighthouse run is lab data and can't measure INP, so it reports TBT as a proxy. - [ ] P2 · new · *Performance* › **Long lists**: **virtualize** (render only the visible rows: TanStack Virtual, react-window) beyond a few hundred complex rows; keep stable keys for infinite scroll. @@ -444,10 +443,10 @@ Strong. Missing a few browser-policy nuances, randomness, account recovery, and **Add** -- [ ] P1 · extend · **CORS**: **simple requests** (GET, HEAD, or POST with form or `text/plain` bodies and no custom headers) go out without a preflight, and the server acts on them even when the browser hides the response, so CORS is no CSRF defense; everything else preflights with `OPTIONS`, cached by `Access-Control-Max-Age`. -- [ ] P1 · new · *Cryptography* › **Secure randomness**: tokens, IDs, nonces, and reset codes need a **CSPRNG** (`crypto.getRandomValues`/`randomBytes`, Python `secrets`, Go `crypto/rand`); `Math.random`, `random`, and `math/rand` are predictable from a few outputs; use ≥ 128 bits for unguessable tokens. -- [ ] P1 · new · *Authentication and sessions* › **Password reset and recovery**: single-use, short-lived, high-entropy tokens stored **hashed**; revoke other sessions after a reset; identical responses whether or not the account exists; build reset links from a configured origin, not the `Host` header (host-header poisoning); recovery is often the weakest login path (SIM swap, support desk). -- [ ] P1 · new · *Server-side attacks* › **Resource-exhaustion attacks**: **ReDoS** (catastrophic backtracking on patterns like `(a+)+$`; use linear-time engines such as RE2 or Go's `regexp`, or timeouts), decompression and zip bombs (cap the output size), XML billion laughs, hash flooding (randomized hash seeds), unbounded JSON or GraphQL depth. +- [x] P1 · extend · **CORS**: **simple requests** (GET, HEAD, or POST with form or `text/plain` bodies and no custom headers) go out without a preflight, and the server acts on them even when the browser hides the response, so CORS is no CSRF defense; everything else preflights with `OPTIONS`, cached by `Access-Control-Max-Age`. +- [x] P1 · new · *Cryptography* › **Secure randomness**: tokens, IDs, nonces, and reset codes need a **CSPRNG** (`crypto.getRandomValues`/`randomBytes`, Python `secrets`, Go `crypto/rand`); `Math.random`, `random`, and `math/rand` are predictable from a few outputs; use ≥ 128 bits for unguessable tokens. +- [x] P1 · new · *Authentication and sessions* › **Password reset and recovery**: single-use, short-lived, high-entropy tokens stored **hashed**; revoke other sessions after a reset; identical responses whether or not the account exists; build reset links from a configured origin, not the `Host` header (host-header poisoning); recovery is often the weakest login path (SIM swap, support desk). +- [x] P1 · new · *Server-side attacks* › **Resource-exhaustion attacks**: **ReDoS** (catastrophic backtracking on patterns like `(a+)+$`; use linear-time engines such as RE2 or Go's `regexp`, or timeouts), decompression and zip bombs (cap the output size), XML billion laughs, hash flooding (randomized hash seeds), unbounded JSON or GraphQL depth. - [ ] P2 · extend · **CSRF**: "same-site" means same scheme + **registrable domain** (eTLD+1), so `evil.example.com` is same-site with `app.example.com` and SameSite doesn't stop attacks from a compromised or user-controlled subdomain; `Lax` still sends cookies on top-level GET navigations, so never change state on GET. - [ ] P2 · new · *TLS* › **SNI, ALPN, ECH**: **SNI** carries the hostname in the ClientHello, so one IP serves many certificates and L4 proxies can route TLS without terminating it; **ALPN** negotiates `h2`/`http/1.1` in the handshake; **ECH** encrypts the inner ClientHello, hiding SNI from the network. - [ ] P2 · new · *TLS* › **Certificate lifecycle**: the CA/Browser Forum (2025) cuts the maximum certificate lifetime to 200 days (March 2026), 100 days (2027), and **47 days (2029)**, so automate with ACME; revocation checking is weak (Let's Encrypt shut down OCSP in 2025), so short lifetimes do the work; monitor Certificate Transparency logs for your domains. @@ -475,10 +474,10 @@ Compact and accurate. Missing the load balancer choice, cross-account access, S3 **Add** -- [ ] P1 · new · *Networking* › **ALB vs NLB** (table): ALB is L7 (host, path, and header routing; WebSockets; gRPC; OIDC auth; WAF); NLB is L4 TCP/UDP/TLS with a **static IP per AZ**, preserves the client IP, supports TLS passthrough and very high throughput, and fronts PrivateLink services; GWLB is for inline appliances; cross-zone balancing is on for ALB and off by default for NLB (cross-AZ charges). -- [ ] P1 · new · *Identity and access* › **Cross-account access**: within one account, an allow in the identity **or** the resource policy suffices (KMS key policies and role trust policies excepted); across accounts **both** sides must allow; third parties assume your role with an **`sts:ExternalId`** condition (confused deputy); `aws:PrincipalOrgID` limits resource policies to your organization. -- [ ] P1 · new · *Storage and databases* › **S3 access and CloudFront**: new buckets block public access and disable ACLs ("bucket owner enforced") since April 2023, and encrypt with SSE-S3 since January 2023; serve private buckets through CloudFront with **Origin Access Control**; signed URLs or cookies for private content at the edge. -- [ ] P1 · extend · **Capacity and cost guardrails** (or new **Cost drivers**): NAT gateway data processing (~$0.045/GB; add S3/DynamoDB gateway endpoints), **cross-AZ traffic** (~$0.01/GB each way), internet egress, CloudWatch Logs ingestion; Savings Plans and RIs (up to ~72% off for 1–3 year commitments), Spot (up to ~90% off), Graviton (~20% cheaper). +- [x] P1 · new · *Networking* › **ALB vs NLB** (table): ALB is L7 (host, path, and header routing; WebSockets; gRPC; OIDC auth; WAF); NLB is L4 TCP/UDP/TLS with a **static IP per AZ**, preserves the client IP, supports TLS passthrough and very high throughput, and fronts PrivateLink services; GWLB is for inline appliances; cross-zone balancing is on for ALB and off by default for NLB (cross-AZ charges). +- [x] P1 · new · *Identity and access* › **Cross-account access**: within one account, an allow in the identity **or** the resource policy suffices (KMS key policies and role trust policies excepted); across accounts **both** sides must allow; third parties assume your role with an **`sts:ExternalId`** condition (confused deputy); `aws:PrincipalOrgID` limits resource policies to your organization. +- [x] P1 · new · *Storage and databases* › **S3 access and CloudFront**: new buckets block public access and disable ACLs ("bucket owner enforced") since April 2023, and encrypt with SSE-S3 since January 2023; serve private buckets through CloudFront with **Origin Access Control**; signed URLs or cookies for private content at the edge. +- [x] P1 · extend · **Capacity and cost guardrails** (or new **Cost drivers**): NAT gateway data processing (~$0.045/GB; add S3/DynamoDB gateway endpoints), **cross-AZ traffic** (~$0.01/GB each way), internet egress, CloudWatch Logs ingestion; Savings Plans and RIs (up to ~72% off for 1–3 year commitments), Spot (up to ~90% off), Graviton (~20% cheaper). *Done as a new concept,* Cost drivers, *in Operations.* - [ ] P2 · extend · **Managed database behavior**: **RDS Proxy** pools connections for Lambda bursts (each concurrent environment opens its own) and shortens failover; read replicas are asynchronous. - [ ] P2 · new · *Events and workflows* › **Streams with Lambda**: Kinesis and DynamoDB Streams deliver in order per shard, so one failing record **blocks the shard** until it expires; set `BisectBatchOnFunctionError`, `MaximumRetryAttempts`, and an on-failure destination; a Kinesis shard takes 1 MB/s or 1,000 records/s in and 2 MB/s out; DynamoDB Streams keep 24 h; async Lambda invocations retry twice. - [ ] P2 · new · *Compute* › **EC2 Auto Scaling**: target tracking (hold a metric such as requests per target) over step or scheduled policies; a health check grace period; lifecycle hooks for bootstrap and drain; warm pools for fast scale-out; T instances drop to baseline CPU when their credits run out (`unlimited` mode bills instead). @@ -502,10 +501,10 @@ Good Kubernetes and Terraform coverage. Missing workload security, a key Terrafo **Add** -- [ ] P1 · new · *Kubernetes security* › **Pod security**: Pod Security Admission levels (privileged, baseline, **restricted**) per namespace, since PodSecurityPolicy was removed in 1.25; `securityContext`: `runAsNonRoot`, `readOnlyRootFilesystem`, `allowPrivilegeEscalation: false`, drop all capabilities, `seccompProfile: RuntimeDefault`; Kyverno or OPA Gatekeeper for custom policy. -- [ ] P1 · new · *Terraform* › **count vs for_each**: `count` addresses resources by index, so removing one element shifts every later index and **recreates** those resources; `for_each` keys them by stable map or set keys. -- [ ] P1 · extend · **Autoscaling**: HPA utilization is a percentage of **requests**, so without requests there's no CPU-based scaling; scale-down waits out a 5-minute stabilization window; **KEDA** scales on queue length or events, down to zero; Karpenter provisions right-sized nodes and consolidates underused ones. -- [ ] P1 · new · *Deployment and release* › **Incident response**: roles (incident commander, communications, operations); **mitigate first** (roll back, flip a flag), find the root cause later; a blameless postmortem with a timeline, contributing factors, and owned action items; track MTTD and MTTR; link runbooks from alerts. +- [x] P1 · new · *Kubernetes security* › **Pod security**: Pod Security Admission levels (privileged, baseline, **restricted**) per namespace, since PodSecurityPolicy was removed in 1.25; `securityContext`: `runAsNonRoot`, `readOnlyRootFilesystem`, `allowPrivilegeEscalation: false`, drop all capabilities, `seccompProfile: RuntimeDefault`; Kyverno or OPA Gatekeeper for custom policy. *Kubernetes security holds Pod security, ServiceAccounts, ConfigMaps and Secrets; NetworkPolicy stays in Kubernetes networking; Packaging and extension moved to Kubernetes architecture.* +- [x] P1 · new · *Terraform* › **count vs for_each**: `count` addresses resources by index, so removing one element shifts every later index and **recreates** those resources; `for_each` keys them by stable map or set keys. +- [x] P1 · extend · **Autoscaling**: HPA utilization is a percentage of **requests**, so without requests there's no CPU-based scaling; scale-down waits out a 5-minute stabilization window; **KEDA** scales on queue length or events, down to zero; Karpenter provisions right-sized nodes and consolidates underused ones. +- [x] P1 · new · *Deployment and release* › **Incident response**: roles (incident commander, communications, operations); **mitigate first** (roll back, flip a flag), find the root cause later; a blameless postmortem with a timeline, contributing factors, and owned action items; track MTTD and MTTR; link runbooks from alerts. - [ ] P2 · new · *CI/CD and GitOps* › **DORA metrics**: deployment frequency, lead time for changes, change failure rate, failed-deployment recovery time; high performers improve speed and stability together; recent reports add rework rate. - [ ] P2 · extend · **Deployment strategies** table: **shadow** (mirror live traffic to the new version and discard its responses; watch for side effects); A/B tests split by user for product metrics, not safety; Argo Rollouts and Flagger automate canary analysis. - [ ] P2 · new · *Kubernetes workloads* › **Jobs and CronJobs**: `backoffLimit`, `activeDeadlineSeconds`, `ttlSecondsAfterFinished`; `concurrencyPolicy: Forbid` prevents overlapping runs; schedules use the controller's time zone (usually UTC) unless `timeZone` (GA 1.27) is set. @@ -530,9 +529,9 @@ Strong on inference, serving, RAG, and agents. Missing how models are trained (i **Add** -- [ ] P1 · new · *Fine-tuning* (rename "Training and fine-tuning") › **Training pipeline**: **pretraining** (next-token prediction on trillions of tokens; Chinchilla-optimal is ≈ 20 tokens per parameter, and modern models train far past it to be cheaper at inference) → SFT → preference tuning (RLHF, DPO) → **RL with verifiable rewards** (math and code graded automatically, e.g., GRPO), which is how reasoning models learn long chains of thought. -- [ ] P1 · new · *Inference and serving* › **Model parallelism and GPU memory**: memory ≈ weights + KV cache + activations; **tensor parallelism** splits each layer across GPUs (needs NVLink-class links, so within a node); **pipeline parallelism** splits layers across nodes (pipeline bubbles); data parallelism replicates for throughput; **disaggregated serving** runs prefill and decode on separate GPU pools. -- [ ] P1 · extend · **Vector index types**: **filtered search**. Post-filtering the top-k returns too few hits for selective filters, and pre-filtering breaks HNSW graph connectivity; use filter-aware engines or partition indexes by tenant. +- [x] P1 · new · *Fine-tuning* (rename "Training and fine-tuning") › **Training pipeline**: **pretraining** (next-token prediction on trillions of tokens; Chinchilla-optimal is ≈ 20 tokens per parameter, and modern models train far past it to be cheaper at inference) → SFT → preference tuning (RLHF, DPO) → **RL with verifiable rewards** (math and code graded automatically, e.g., GRPO), which is how reasoning models learn long chains of thought. +- [x] P1 · new · *Inference and serving* › **Model parallelism and GPU memory**: memory ≈ weights + KV cache + activations; **tensor parallelism** splits each layer across GPUs (needs NVLink-class links, so within a node); **pipeline parallelism** splits layers across nodes (pipeline bubbles); data parallelism replicates for throughput; **disaggregated serving** runs prefill and decode on separate GPU pools. +- [x] P1 · extend · **Vector index types**: **filtered search**. Post-filtering the top-k returns too few hits for selective filters, and pre-filtering breaks HNSW graph connectivity; use filter-aware engines or partition indexes by tenant. - [ ] P2 · new · *LLM fundamentals* › **Positional encoding**: attention is order-blind; **RoPE** rotates query and key vectors by position so scores depend on relative distance; longer contexts come from RoPE scaling (position interpolation, YaRN) plus long-context training, and quality degrades past the trained length. - [ ] P2 · new · *Fine-tuning* › **Distillation**: train a small student on a large teacher's outputs or logits for most of the quality at a fraction of the serving cost (also how small reasoning models are made); fine-tuning can cause catastrophic forgetting, which LoRA limits by freezing the base. - [ ] P2 · extend · **Eval sets and metrics**: **pass@k** for code and agent tasks (the probability that at least one of k samples passes); precision/recall (PR-AUC when labels are imbalanced) for classifier-style checks; public benchmarks suffer from contamination. @@ -555,10 +554,10 @@ Good protocol coverage. Missing precompiles, node and RPC practicalities, ZK pro **Add** -- [ ] P1 · new · *EVM* › **Precompiles**: fixed low addresses for cryptography too costly in bytecode: `0x01` ecrecover, `0x02` SHA-256, `0x05` modexp, `0x06`–`0x08` BN254 add/mul/pairing (SNARK verifiers), `0x0a` KZG point evaluation (EIP-4844), **BLS12-381** (Pectra, EIP-2537), **P-256** verification (Fusaka, EIP-7951; passkey wallets); they have no code, so `extcodesize` is 0. -- [ ] P1 · new · *Accounts and transactions* › **RPC block tags and reorgs**: `latest` can reorg, **`safe`** (justified) rarely does, and **`finalized`** can't without slashing ⅓ of the stake; `eth_call` simulates against a block; `eth_estimateGas` binary-searches and can underestimate state-dependent paths, so add headroom; indexers store block hashes and roll back on reorg, or index only finalized blocks. -- [ ] P1 · new · *Scaling* › **ZK proof systems**: **SNARKs** (Groth16, PLONK) have small proofs, cheap L1 verification via BN254 pairings, and often a trusted setup; **STARKs** need no trusted setup, are hash-based (plausibly post-quantum), and have larger proofs, often wrapped in a SNARK for L1; zkEVM types trade Ethereum equivalence against proving cost. -- [ ] P1 · extend · **Account abstraction**: EIP-7702 risks. One authorization signature hands the EOA to the delegate's code (a phishing target); an authorization with `chain_id = 0` is valid on **every chain**; the delegate's storage lives in the EOA, so switching delegates can collide layouts (use namespaced storage). +- [x] P1 · new · *EVM* › **Precompiles**: fixed low addresses for cryptography too costly in bytecode: `0x01` ecrecover, `0x02` SHA-256, `0x05` modexp, `0x06`–`0x08` BN254 add/mul/pairing (SNARK verifiers), `0x0a` KZG point evaluation (EIP-4844), **BLS12-381** (Pectra, EIP-2537), **P-256** verification (Fusaka, EIP-7951; passkey wallets); they have no code, so `extcodesize` is 0. +- [x] P1 · new · *Accounts and transactions* › **RPC block tags and reorgs**: `latest` can reorg, **`safe`** (justified) rarely does, and **`finalized`** can't without slashing ⅓ of the stake; `eth_call` simulates against a block; `eth_estimateGas` binary-searches and can underestimate state-dependent paths, so add headroom; indexers store block hashes and roll back on reorg, or index only finalized blocks. +- [x] P1 · new · *Scaling* › **ZK proof systems**: **SNARKs** (Groth16, PLONK) have small proofs, cheap L1 verification via BN254 pairings, and often a trusted setup; **STARKs** need no trusted setup, are hash-based (plausibly post-quantum), and have larger proofs, often wrapped in a SNARK for L1; zkEVM types trade Ethereum equivalence against proving cost. +- [x] P1 · extend · **Account abstraction**: EIP-7702 risks. One authorization signature hands the EOA to the delegate's code (a phishing target); an authorization with `chain_id = 0` is valid on **every chain**; the delegate's storage lives in the EOA, so switching delegates can collide layouts (use namespaced storage). - [ ] P2 · new · *Consensus (PoS)* › **Execution and consensus clients**: since the Merge a node = execution client (Geth, Nethermind, Besu, Erigon, Reth) + consensus client (Prysm, Lighthouse, Teku, Nimbus, Lodestar) linked by the authenticated **Engine API**; a bug in a client with > ⅔ of the stake could finalize an invalid chain, hence client diversity; full vs archive nodes. - [ ] P2 · extend · **Transaction lifecycle**: a replacement needs the same nonce and ≥ 10% higher fees (Geth's default; 100% for blob transactions); private RPCs (Flashbots Protect) skip the public mempool. - [ ] P2 · new · *Scaling* › **L2 fees and messaging**: an L2 fee = L2 execution + the **L1 data fee** (blob or calldata cost, usually the larger part); deposits through the canonical bridge can be force-included; withdrawals wait for the fraud window or a validity proof; L2BEAT stages 0–2 grade how much users rely on a security council vs proofs. diff --git a/docs/topics/ai.md b/docs/topics/ai.md index 8765391..0f0ec01 100644 --- a/docs/topics/ai.md +++ b/docs/topics/ai.md @@ -68,6 +68,13 @@ What experienced AI engineers forget before an interview, grouped by subtopic. F - A small **draft model** proposes several tokens; the large model verifies them in one pass and keeps the accepted prefix. - Faster decode with the **same output distribution**; the gain depends on how often drafts are accepted. +### Model parallelism and GPU memory + +- Serving memory ≈ weights + KV cache + activations; a model too large for one GPU must be split. +- **Tensor parallelism** splits each layer's matrices across GPUs; it needs a fast interconnect (NVLink), so it stays within a node. +- **Pipeline parallelism** puts consecutive layers on different GPUs or nodes: less communication, but pipeline bubbles leave stages idle. +- Data parallelism replicates the whole model for throughput; **disaggregated serving** runs prefill and decode on separate GPU pools, each tuned for its bottleneck. + ### Quantization - Weights in FP16 take **2 bytes per parameter** (a 70B model ≈ 140 GB); INT8 halves that, **4-bit** (GPTQ, AWQ) quarters it, with some quality loss. @@ -95,6 +102,8 @@ What experienced AI engineers forget before an interview, grouped by subtopic. F | **IVF** | cluster, then probe `nprobe` clusters | less memory; recall depends on `nprobe` | | **PQ** | compress vectors into codes | much smaller, lower recall; often combined as IVF-PQ | +- **Filtered search**: post-filtering the top-k returns too few hits when the filter is selective, and pre-filtering breaks HNSW graph connectivity — use a filter-aware engine or partition the index (per tenant). + ### Chunking - Chunk along **document structure** (sections, paragraphs); a few hundred tokens with **10–20% overlap** is a common starting point — tune on evals. @@ -118,7 +127,13 @@ What experienced AI engineers forget before an interview, grouped by subtopic. F | RAG | facts are private or change often; citations matter | | Fine-tuning | a stable style, format, or decision gap persists after prompting; poor for keeping facts current | -## Fine-tuning +## Training and fine-tuning + +### Training pipeline + +- **Pretraining**: next-token prediction on trillions of tokens; Chinchilla-optimal is ≈ **20 tokens per parameter**, but modern models train far past it so a smaller model is cheaper to serve. +- Post-training: SFT on demonstrations, then preference tuning (RLHF, DPO) for helpfulness and safety. +- **RL with verifiable rewards** (math and code graded automatically, e.g. GRPO) is how reasoning models learn long chains of thought. ### SFT, RLHF, DPO diff --git a/docs/topics/algorithms.md b/docs/topics/algorithms.md index 9624560..ad53ac0 100644 --- a/docs/topics/algorithms.md +++ b/docs/topics/algorithms.md @@ -10,6 +10,19 @@ What experienced engineers forget before an algorithms interview, grouped by sub - Nested loops aren't automatically O(n²): if two pointers each advance at most `n` times, total work is O(n). - Recursion stack counts as space: balanced divide-and-conquer uses O(log n) frames, a linear chain O(n). +### Input size and target complexity + +At ~10⁸ simple operations per second, the constraints tell you which complexity to aim for: + +| n up to | Target | Typical technique | +|---|---|---| +| 10–11 | O(n!) | permutations | +| 20 | O(2ⁿ) | subsets, bitmask DP | +| 500 | O(n³) | interval DP, Floyd–Warshall | +| 5,000 | O(n²) | pairwise DP | +| 10⁶ | O(n log n) | sorting, heaps, binary search | +| beyond | O(n) or O(log n) | linear scan, math | + ### Amortized analysis - A dynamic array's occasional **O(n) resize** still gives **O(1) amortized** append, because capacity grows geometrically. @@ -50,6 +63,12 @@ What experienced engineers forget before an algorithms interview, grouped by sub - **Sliding window maximum**: keep indices with decreasing values; pop smaller values from the back, drop the front once it leaves the window. - Every index enters and leaves once — **O(n)** total instead of O(nk). +### Maximum subarray (Kadane) + +- Scan once: `cur = max(x, cur + x)`, `best = max(best, cur)` — **O(n)** time, O(1) space. +- Initialize both with the first element, not 0, so an all-negative array returns its largest value. +- **Circular** variant: `max(best, total − minimum subarray)`, unless every value is negative (then just `best`). + ### Intervals - **Merge overlapping intervals**: sort by start, extend the last merged interval while the next start ≤ its end — O(n log n). @@ -72,7 +91,7 @@ What experienced engineers forget before an algorithms interview, grouped by sub - A **polynomial rolling hash** updates a window's hash in O(1) as it slides, so search is O(n + m) expected. - Collisions happen: **verify each match** for exact results — two moduli only make collisions rarer; also finds duplicate substrings via binary search on length. -## Sorting and selection +## Sorting, selection, and sampling ### Comparison sorts @@ -94,6 +113,12 @@ Standard array implementations; variants differ in stability and space. - **Quickselect** partitions around a random pivot and recurses into one side: O(n) expected, O(n²) worst. - A size-`k` **min-heap** keeps the largest `k` of `n` items in O(n log k) time and O(k) space. +### Random sampling and shuffling + +- **Reservoir sampling** picks `k` items from a stream of unknown length: keep the first `k`, then replace a random slot with the i-th item with probability k/i — one pass, O(k) memory. +- **Fisher–Yates** shuffle: for `i` from `n−1` down to 1, swap `a[i]` with `a[rand(0..i)]` — O(n), every permutation equally likely. +- Swapping with `a[rand(0..n−1)]` at each step looks similar but is **biased** (nⁿ outcomes can't split evenly over n! permutations). + ## Data structures ### Heap invariants @@ -101,6 +126,12 @@ Standard array implementations; variants differ in stability and space. - A binary heap is a **complete tree** in an array; the root is the min or max, siblings are unordered. - Peek O(1); insert and remove-root O(log n); **bottom-up construction is O(n)**. +### Heap patterns + +- **k-way merge**: push the head of each of `k` sorted lists into a min-heap, pop and push the next from the same list — O(n log k). +- Running median with **two heaps**: a max-heap for the lower half, a min-heap for the upper, sizes differing by at most one — O(log n) per insert, O(1) median. +- Heaps can't delete arbitrary items cheaply: **lazy deletion** marks items removed and discards them when they reach the top. + ### Hash tables and collisions - Expected O(1) lookup and update, no ordering; **collisions** are resolved by chaining or probing, and the table rehashes past a load threshold. diff --git a/docs/topics/aws.md b/docs/topics/aws.md index 00b6184..1857b47 100644 --- a/docs/topics/aws.md +++ b/docs/topics/aws.md @@ -15,6 +15,13 @@ What experienced AWS developers and DevOps engineers forget before an interview, - Use **temporary role credentials** for EC2, ECS tasks, and Lambda; use OIDC federation for external CI so pipelines do not store long-lived AWS keys. - In ECS, the **task role** grants the application access to AWS APIs; the **execution role** lets the ECS agent pull images, fetch configured secrets, and send logs. +### Cross-account access + +- Within one account, an allow in the identity policy **or** the resource policy suffices (KMS key policies and role trust policies are exceptions). +- Across accounts, **both** sides must allow: the resource policy trusts the other account or principal, and that principal's identity policy grants the action. +- Third parties assume your role with an **`sts:ExternalId`** condition, preventing the confused-deputy problem. +- `aws:PrincipalOrgID` in a resource policy limits access to accounts in your organization. + ### KMS and envelope encryption - **Envelope encryption**: `GenerateDataKey` returns a plaintext data key (encrypt locally, then discard) and the same key encrypted under the KMS key (store it with the data). KMS `Encrypt` itself only takes **4 KB**. @@ -32,6 +39,19 @@ What experienced AWS developers and DevOps engineers forget before an interview, - **Security groups** are stateful and attach to network interfaces; **network ACLs** are stateless and apply at subnet boundaries, so return traffic needs an explicit ACL rule. - **Gateway VPC endpoints** route S3 and DynamoDB traffic without a NAT device or internet gateway; interface endpoints use private IPs and AWS PrivateLink for supported services. +### ALB vs NLB + +| | ALB | NLB | +|---|---|---| +| Layer | L7: HTTP(S), gRPC, WebSockets | L4: TCP, UDP, TLS | +| Routing | host, path, header, query string | port only | +| Addresses | changing IPs; use the DNS name | **static IP per AZ** (Elastic IPs optional) | +| Client IP | in `X-Forwarded-For` | preserved, or sent via PROXY protocol v2 | +| Extras | OIDC/Cognito auth, WAF, Lambda targets | TLS passthrough, PrivateLink services, very high throughput | +| Cross-zone | on by default | **off** by default; cross-AZ data is charged when on | + +Gateway Load Balancer inserts inline appliances such as third-party firewalls. + ### Connecting VPCs | Option | Topology | Note | @@ -87,6 +107,12 @@ What experienced AWS developers and DevOps engineers forget before an interview, - With **versioning**, deleting an object without a version ID adds a delete marker; deleting a specific version permanently removes it. Lifecycle rules can expire noncurrent versions. - A **presigned URL** grants temporary access using the signer's permissions and expires no later than the credentials used to sign it. +### S3 access and CloudFront + +- New buckets block public access and disable ACLs (**bucket owner enforced**) by default since April 2023; objects are encrypted with SSE-S3 by default since January 2023. +- Serve a private bucket through CloudFront with **Origin Access Control**, which replaces the legacy OAI; the bucket policy allows only that distribution. +- CloudFront **signed URLs or signed cookies** gate private content at the edge; S3 presigned URLs bypass the CDN. + ### S3 performance and classes - Each **prefix** supports about **3,500 writes and 5,500 reads per second**; spread hot keys over prefixes. @@ -149,3 +175,10 @@ What experienced AWS developers and DevOps engineers forget before an interview, - Service **quotas** are per account and Region and often stop scaling before the application does — many are soft and raised by request. - AWS Budgets alerts follow billing-data updates, at least daily; use CloudWatch service metrics for operational alarms. Cost Explorer is for spend analysis. - EC2 **Spot** capacity can be reclaimed; stop/terminate interruption notices give about **2 minutes** on a best-effort basis (hibernation starts immediately). Checkpoint work and replace capacity proactively. + +### Cost drivers + +- **NAT gateway** data processing (~$0.045/GB in us-east-1, plus hourly) is a classic surprise; S3 and DynamoDB gateway endpoints are free and skip it. +- **Cross-AZ traffic** costs ~$0.01/GB in each direction, so chatty services and replicas spread across AZs add up. +- Internet egress and CloudWatch Logs ingestion (~$0.50/GB) are the other usual suspects. +- Discounts: Savings Plans and Reserved Instances (up to ~72% for 1–3 year commitments), Spot (up to ~90%), Graviton (roughly 20% cheaper per hour than comparable x86). diff --git a/docs/topics/backend.md b/docs/topics/backend.md index 2a198b8..35745af 100644 --- a/docs/topics/backend.md +++ b/docs/topics/backend.md @@ -88,6 +88,13 @@ What experienced backend engineers forget before an interview, grouped by subtop - **Propagate the deadline** (gRPC does it natively) so downstream services stop work once the original caller has given up. - Retries, backoff, and circuit breakers: see [distributed.md](distributed.md). +### Schema evolution + +- **Backward compatible**: new readers read old data; **forward compatible**: old readers read new data — rolling deploys and replayed events need both. +- Protobuf: never reuse or renumber a field tag (mark removed ones `reserved`); adding fields is safe; proto3 has no `required`; unknown fields survive a round trip. +- Avro with a schema registry checks BACKWARD, FORWARD, or FULL compatibility on every schema change. +- JSON consumers must ignore unknown fields (**tolerant reader**); rename a field by adding the new one, writing both, moving readers over, then removing the old. + ### Webhooks - **Sign** each payload (HMAC over timestamp + body) and have receivers verify it with a **constant-time** compare; reject stale timestamps to stop replays. @@ -133,6 +140,19 @@ What experienced backend engineers forget before an interview, grouped by subtop - Never make a network call inside an open DB transaction — it holds **locks and a connection** for the whole round trip. - For "commit, then notify another service", use the outbox instead of calling inside the transaction. +### Multi-tenancy models + +- Shared tables with a `tenant_id`: cheapest, but every query must filter — enforce it with PostgreSQL **row-level security** (the table owner bypasses it unless `FORCE ROW LEVEL SECURITY`). +- Schema per tenant: more isolation, but migrations and connection pools multiply with the tenant count. +- Database per tenant: strongest isolation, per-tenant restore and data residency, the most operational work. +- Move **noisy neighbors** (the largest tenants) to their own shard or database, and rate-limit per tenant. + +### Time handling + +- Store and send instants in **UTC** (RFC 3339 with an offset, `2026-03-08T09:30:00Z`); in PostgreSQL use `timestamptz`. +- For future local-time events (meetings, schedules), store the local time plus an **IANA zone** (`Europe/Berlin`), not an offset — DST rules and offsets change. +- A DST switch skips or repeats a local hour, so a job scheduled at 02:30 local time runs never or twice; schedule jobs in UTC. + ### File uploads - Large files go straight to object storage with a **presigned URL**, bypassing app servers; the app stores only metadata. diff --git a/docs/topics/database.md b/docs/topics/database.md index 9056be4..73a8aac 100644 --- a/docs/topics/database.md +++ b/docs/topics/database.md @@ -128,9 +128,13 @@ What experienced database engineers forget before an interview, grouped by subto - **`FROM/JOIN → WHERE → GROUP BY → HAVING → SELECT → DISTINCT → ORDER BY → LIMIT`** — why a `SELECT` alias works in `ORDER BY` but not in `WHERE`. -### Reading EXPLAIN ANALYZE +### Why an index isn't used -- Look for sequential scans on big tables, **estimated vs actual rows** far apart (stale statistics — run `ANALYZE`), and sorts or hashes spilling to disk. +- Low selectivity: when a filter matches a large share of rows, the planner prefers a **sequential scan**, since one sequential pass beats many random heap reads. +- `LIKE 'x%'` uses a B-tree only with C collation or `text_pattern_ops`; `LIKE '%x'` needs a trigram GIN index (`pg_trgm`). +- A function or implicit cast on the column, and `OR` across columns without an index on each, also defeat it. +- **Stale statistics** show up in `EXPLAIN ANALYZE` as estimated vs actual rows far apart — run `ANALYZE`; also watch for sorts or hashes spilling to disk. +- Scan types: Seq Scan, Index Scan, Index Only Scan, and **Bitmap Heap Scan** (collects matches from one or more indexes, then reads pages in physical order). ### Join algorithms @@ -163,6 +167,12 @@ What experienced database engineers forget before an interview, grouped by subto - **Since PostgreSQL 12**, a side-effect-free CTE referenced **once** is inlined into the outer query; one referenced several times is materialized. - `MATERIALIZED` / `NOT MATERIALIZED` override the default. +### Join pitfalls + +- A condition on the right table in **`WHERE`** discards the NULL-extended rows and turns a `LEFT JOIN` into an inner join; put it in `ON`. +- Joining a parent to **two one-to-many children** multiplies rows (fan-out) and inflates `SUM`/`COUNT`; aggregate each child in a subquery first. +- `EXISTS` / `NOT EXISTS` are semi- and anti-joins: they never duplicate rows, unlike `JOIN` + `DISTINCT`. + ### Upsert - **`INSERT ... ON CONFLICT (...) DO UPDATE`** (PostgreSQL) / `ON DUPLICATE KEY UPDATE` (MySQL) replaces a racy check-then-write. @@ -181,6 +191,20 @@ What experienced database engineers forget before an interview, grouped by subto - Replication is **asynchronous** — failover can drop acknowledged writes. - The 2024 license change led to the **Valkey** fork (Linux Foundation); Redis 8 (2025) added AGPLv3 as an option. +### Redis eviction, expiry, and messaging + +- `maxmemory-policy` defaults to **`noeviction`**: at the memory limit, writes fail with an OOM error. +- Caches use `allkeys-lru` or `allkeys-lfu`; `volatile-*` policies evict only keys with a TTL, so without TTLs they behave like `noeviction`. +- Expired keys are removed **lazily** on access plus by background sampling, so memory lags behind expirations. +- Pub/sub is fire-and-forget (offline subscribers miss messages); Streams persist entries, with consumer groups, acknowledgments, and redelivery of pending entries. + +### Document stores (MongoDB) + +- **Embed** data that is read together (one read, atomic update); reference unbounded or shared data — a document is capped at **16 MB**. +- Single-document writes are atomic; multi-document transactions (replica sets since 4.0, sharded clusters since 4.2) cost more, so design for single-document atomicity. +- Write concern **`w: "majority"`** is the default since 5.0; `w: 1` acknowledges before replication, so a failover can roll back acknowledged writes. +- A query without a matching index scans the collection (`COLLSCAN`); order compound index keys by the ESR rule: Equality, Sort, Range. + ### Wide-column key design (Cassandra, DynamoDB) - The **partition key** picks the node; the sort/clustering key orders rows inside the partition — an efficient query must supply the partition key; otherwise it's a full scan (DynamoDB `Scan`, Cassandra `ALLOW FILTERING`) or a secondary index. diff --git a/docs/topics/devops.md b/docs/topics/devops.md index efbe81a..4e4cfa4 100644 --- a/docs/topics/devops.md +++ b/docs/topics/devops.md @@ -30,6 +30,13 @@ What experienced DevOps engineers forget before an interview, grouped by subtopi - A destructive migration (dropping a column old code still reads) makes rollback impossible. - Keep each DDL short and lock-safe (`lock_timeout`, concurrent index builds) — see [database.md](database.md). +### Incident response + +- Assign roles: an **incident commander** coordinates while others handle communications and operations. +- **Mitigate first** (roll back, flip a flag, fail over); find the root cause later. +- Write a blameless postmortem: timeline, contributing factors, and action items with owners. +- Track time to detect and time to recover (MTTD, MTTR); link a runbook from every alert. + ## Containers ### How containers work @@ -66,6 +73,11 @@ What experienced DevOps engineers forget before an interview, grouped by subtopi - **kube-proxy** or an **eBPF** CNI such as Cilium implements Service virtual IPs. - kube-proxy modes: iptables (default), nftables (GA in 1.33), IPVS (deprecated since 1.35). +### Packaging and extension + +- **Helm** templates charts with values and tracks releases; **Kustomize** patches plain YAML with overlays, no templating. +- **CRDs + operators** extend the API: an operator's controller reconciles custom resources (databases, certificates) like built-in objects. + ## Kubernetes workloads ### Workload types @@ -136,7 +148,9 @@ What experienced DevOps engineers forget before an interview, grouped by subtopi ### Autoscaling -- **HPA** scales replicas from metrics; **VPA** adjusts requests; Cluster Autoscaler/**Karpenter** add nodes when Pods can't be scheduled. +- **HPA** scales replicas from metrics; VPA adjusts requests; Cluster Autoscaler/Karpenter add nodes when Pods can't be scheduled. +- HPA utilization targets are a percentage of **requests**, so Pods without CPU requests can't scale on CPU; scale-down waits out a 5-minute stabilization window by default. +- **KEDA** scales on external events (queue length, consumer lag), down to zero; Karpenter also consolidates underused nodes. - More replicas don't help when the bottleneck is a saturated downstream database. ### Graceful Pod shutdown @@ -145,26 +159,30 @@ What experienced DevOps engineers forget before an interview, grouped by subtopi - The kubelet runs **`preStop`** first, then sends `SIGTERM` — a short `preStop` sleep covers that race. - **`terminationGracePeriodSeconds`** (default **30 s**) covers `preStop` plus shutdown; then the kubelet sends `SIGKILL`. App-side steps are in [backend.md](backend.md). -### ConfigMaps and Secrets - -- Secret values are only **base64-encoded**; enable encryption at rest (KMS), restrict access with **RBAC**, or sync from a vault (External Secrets Operator). -- Env vars from a ConfigMap don't update in a running Pod; mounted files do (eventually) — most apps still need a restart. - ### Debugging Pod states - **`Pending`**: unschedulable (resources, quota, taints, unbound volume). **`ImagePullBackOff`**: wrong image or registry credentials. **`CrashLoopBackOff`**: the process or its liveness probe keeps failing. - `kubectl describe pod` shows events; `kubectl logs --previous` shows the crashed container's last output. +## Kubernetes security + +### Pod security + +- **Pod Security Admission** enforces the privileged, baseline, or **restricted** profile per namespace via labels; PodSecurityPolicy was removed in 1.25. +- A hardened `securityContext`: `runAsNonRoot`, `readOnlyRootFilesystem`, `allowPrivilegeEscalation: false`, drop all capabilities, `seccompProfile: RuntimeDefault`. +- `privileged: true`, `hostPath` mounts, and `hostNetwork`/`hostPID` effectively hand over the node. +- Kyverno or OPA Gatekeeper enforce custom rules (allowed registries, no `latest` tags, required labels). + ### ServiceAccounts and workload identity - Each Pod runs as a **ServiceAccount**; RBAC Roles bound to it limit what it may do through the Kubernetes API. - Its tokens are projected, short-lived, and audience-bound; set `automountServiceAccountToken: false` when the app doesn't call the API. - **Workload identity** maps a ServiceAccount to a cloud role (EKS IRSA or Pod Identity, GKE Workload Identity) — no static cloud keys in Secrets. -### Packaging and extension +### ConfigMaps and Secrets -- **Helm** templates charts with values and tracks releases; **Kustomize** patches plain YAML with overlays, no templating. -- **CRDs + operators** extend the API: an operator's controller reconciles custom resources (databases, certificates) like built-in objects. +- Secret values are only **base64-encoded**; enable encryption at rest (KMS), restrict access with **RBAC**, or sync from a vault (External Secrets Operator). +- Env vars from a ConfigMap don't update in a running Pod; mounted files do (eventually) — most apps still need a restart. ## Terraform @@ -178,6 +196,12 @@ What experienced DevOps engineers forget before an interview, grouped by subtopi - **State** maps resource addresses to real objects and can hold secrets — keep it in a **remote backend with locking**, never in Git. - **Drift**: out-of-band changes show up in the next plan, which proposes reverting them. +### count vs for_each + +- `count` addresses instances by index (`aws_instance.web[2]`): removing one element shifts every later index, so Terraform **destroys and recreates** those resources. +- **`for_each`** keys instances by stable map or set keys (`aws_instance.web["api"]`), so adding or removing one touches only that one. +- `for_each` keys must be known at plan time, not computed during apply; switching between the two needs `moved` blocks. + ### Refactoring resources - **`moved`** blocks record a renamed address, so the plan doesn't destroy and recreate it. diff --git a/docs/topics/distributed.md b/docs/topics/distributed.md index 591cff9..afbd118 100644 --- a/docs/topics/distributed.md +++ b/docs/topics/distributed.md @@ -109,7 +109,8 @@ Key distributed-systems building blocks and trade-offs, grouped by subtopic. ### Physical clocks and TrueTime - Clocks drift and NTP can step them backward, so wall-clock timestamps can't order events across nodes — **last-write-wins** silently loses data. -- Spanner's **TrueTime** returns an uncertainty interval; a commit **waits out** the uncertainty (~ms) before becoming visible, giving external consistency. +- Spanner's **TrueTime** returns an uncertainty interval; a commit waits out the uncertainty (~ms) before becoming visible, giving external consistency. +- Measure durations, timeouts, and leases with the **monotonic clock** (`CLOCK_MONOTONIC`, Go's `time.Since`, `performance.now()`), which never jumps; wall-clock time steps on NTP corrections, manual changes, and VM migration. ### Logical clocks @@ -138,10 +139,12 @@ Key distributed-systems building blocks and trade-offs, grouped by subtopic. - A chain of local transactions, each with a **compensating action**; eventual consistency, **no isolation** (others see intermediate states). - **Orchestration** (a central coordinator) vs choreography (services react to each other's events). -### Effectively-once processing +### Delivery guarantees -- **Effectively-once = at-least-once delivery + idempotent processing**: handlers may run repeatedly, but the effect lands once. -- Publish events atomically with the local write via the **transactional outbox**; dedupe on the consumer via an inbox — both in [backend.md](backend.md). +- **At-most-once**: ack (or commit the offset) before processing — a crash mid-processing loses the message. +- **At-least-once**: ack after processing — a crash between the effect and the ack redelivers it, so handlers see duplicates. +- Exactly-once *delivery* is impossible; an **exactly-once effect** = at-least-once + idempotent handling, or one transaction covering both the effect and the offset. +- Publish events atomically with the local write via the transactional outbox; dedupe on the consumer via an inbox — both in [backend.md](backend.md). ## Conflict resolution @@ -201,10 +204,19 @@ Key distributed-systems building blocks and trade-offs, grouped by subtopic. - **Tumbling** (fixed, non-overlapping), **sliding/hopping** (fixed, overlapping), **session** (closed by an inactivity gap). +### Change data capture + +- **Log-based CDC** (Debezium) tails the WAL or binlog: every committed change in commit order, deletes included, with no dual writes in the application. +- Polling an `updated_at` column misses hard deletes and rows that commit late with an older timestamp. +- Bootstrap from a **consistent snapshot**, then stream from the log position it was taken at. +- Events are ordered per key (partition by primary key); connectors deliver at least once, so consumers must be idempotent. + ### Kafka ordering and consumer groups - Order is guaranteed **only within a partition**; key by entity ID to keep one entity's events in order. -- A **consumer group** splits partitions among its members — parallelism is capped at the **partition count**. +- A consumer group splits partitions among its members — parallelism is capped at the **partition count**. +- Adding partitions changes `hash(key) % partitions`, so existing keys move and **per-key ordering breaks**; the count can't be decreased — size it up front. +- Consumer lag (latest offset − committed offset) is the health metric to alert on. ### Kafka producer semantics diff --git a/docs/topics/ethereum.md b/docs/topics/ethereum.md index 81c29be..1566b30 100644 --- a/docs/topics/ethereum.md +++ b/docs/topics/ethereum.md @@ -31,6 +31,12 @@ What experienced Ethereum engineers forget before an interview, grouped by subto - Signed → propagated to the **mempool** → a builder assembles a block (**PBS** via MEV-Boost separates building from proposing) → the proposer publishes it → validators attest. - **Finalized after 2 epochs (~12.8 min)**; before that a block can be reorged, so exchanges and bridges wait for finality or several confirmations. +### RPC block tags and reorgs + +- `latest` can be reorged; **`safe`** (the justified checkpoint) rarely is; **`finalized`** can't be reverted without slashing at least ⅓ of the stake. +- `eth_call` simulates against a chosen block without sending a transaction; `eth_estimateGas` binary-searches a working gas limit and can underestimate state-dependent paths, so add headroom. +- Indexers store block hashes and roll back on a reorg, or index only finalized blocks. + ## Gas and fees ### EIP-1559 fee market @@ -62,6 +68,20 @@ What experienced Ethereum engineers forget before an interview, grouped by subto - Memory expansion cost is **quadratic** in size; storage is the most expensive resource, priced per 32-byte slot. - `DELEGATECALL` runs another contract's code on the caller's storage; any call forwards at most 63/64 of the remaining gas (EIP-150) — see [solidity.md](solidity.md). +### Precompiles + +Built-in contracts at fixed low addresses for cryptography too expensive in bytecode; they have no code, so `extcodesize` returns 0. + +| Address | Function | +|---|---| +| `0x01` | `ecrecover` | +| `0x02`, `0x03` | SHA-256, RIPEMD-160 | +| `0x05` | modexp (RSA verification) | +| `0x06`–`0x08` | BN254 add, mul, pairing — **SNARK verifiers** | +| `0x0a` | KZG point evaluation (EIP-4844 blobs) | +| `0x0b`–`0x11` | BLS12-381 operations (Pectra, EIP-2537) | +| `0x100` | P-256 verification (Fusaka, EIP-7951) — passkeys and secure enclaves | + ### Transient storage and SELFDESTRUCT - **Transient storage** (`TSTORE`/`TLOAD`, EIP-1153, Cancun) costs 100 gas and is cleared after each transaction — cheap reentrancy locks. @@ -103,6 +123,8 @@ What experienced Ethereum engineers forget before an interview, grouped by subto - **ERC-4337**: users sign UserOperations, bundlers submit them to a singleton EntryPoint, and **paymasters** can sponsor gas — no protocol change. - **EIP-7702** lets an existing EOA delegate to smart-wallet code while keeping its address. +- 7702 risks: one authorization signature hands the EOA to the delegate's code, a prime phishing target; an authorization with `chain_id = 0` is valid on every chain. +- The delegate's storage lives in the EOA, so switching delegates can collide storage layouts — use namespaced storage (ERC-7201). ## Consensus (PoS) @@ -131,6 +153,12 @@ What experienced Ethereum engineers forget before an interview, grouped by subto - Rollups post transaction data to L1 for **data availability**, so anyone can rebuild state and challenge or exit. - Most use a **centralized sequencer** for ordering, with forced inclusion through L1 as the censorship backstop. +### ZK proof systems + +- **SNARKs** (Groth16, PLONK): proofs of a few hundred bytes, cheap to verify on L1 via the BN254 pairing precompile; many need a **trusted setup** (per circuit for Groth16, universal for PLONK). +- **STARKs**: no trusted setup and hash-based (plausibly post-quantum), but proofs run to tens or hundreds of KB, so rollups often wrap a STARK in a SNARK for L1. +- zkEVM types 1–4 trade Ethereum equivalence against proving cost: type 1 proves unmodified Ethereum blocks, type 4 compiles Solidity to a different VM. + ### Blobs and PeerDAS - **EIP-4844** blobs are cheap, temporary data (pruned after ~18 days), separate from calldata. diff --git a/docs/topics/frontend.md b/docs/topics/frontend.md index 59e3265..22bfa94 100644 --- a/docs/topics/frontend.md +++ b/docs/topics/frontend.md @@ -123,6 +123,18 @@ What experienced frontend engineers forget before an interview, grouped by subto - Long `max-age` + `immutable` on **content-hashed filenames** (`app.a3f9c1.js`), with HTML served `no-cache` — each deploy is a new URL. - `ETag`/`Last-Modified` let the server answer **`304 Not Modified`** — saves the body, not the round trip. +### Browser storage + +| Storage | Size | Notes | +|---|---|---| +| Cookies | ~4 KB each | sent with every request to the domain | +| `localStorage` | ~5 MB per origin | **synchronous** (blocks the main thread), strings only | +| `sessionStorage` | ~5 MB per origin | per tab, cleared when the tab closes | +| **IndexedDB** | a share of free disk | async, structured data, available in workers | +| Cache API | a share of free disk | request/response pairs, used by service workers | + +Any XSS can read all of them except `HttpOnly` cookies — token storage in [security.md](security.md). + ### Service workers - **Service workers** implement cache-first, network-first, or stale-while-revalidate strategies and offline support. @@ -135,6 +147,18 @@ What experienced frontend engineers forget before an interview, grouped by subto - **Keys** match list items across renders; an array index as key attaches the wrong state after reorder or filter. - A component re-renders on its own state change, a **parent re-render** (unless memoized), or a consumed **context value** change. +### State snapshots and resets + +- State is a **snapshot** per render: `setCount(count + 1)` twice adds 1; the updater form `setCount(c => c + 1)` twice adds 2. +- Changing a component's **`key`** remounts it and resets its state — the clean way to reset a form when the selected item changes. +- `useRef` holds a mutable value across renders without triggering a re-render; don't read or write it during render. + +### Error boundaries + +- An error boundary catches errors thrown while **rendering** its subtree and shows a fallback UI instead of unmounting the whole app. +- It's still a **class component** (`getDerivedStateFromError`, `componentDidCatch`) or the `react-error-boundary` package; there's no hook equivalent. +- It doesn't catch errors in event handlers or async code (`setTimeout`, promises) — handle those with `try/catch` and state. + ### Fiber and concurrent rendering - **Fiber** splits rendering into interruptible units: the render phase can pause, restart, or be discarded; the **commit phase** applies DOM changes synchronously. @@ -174,6 +198,12 @@ What experienced frontend engineers forget before an interview, grouped by subto - Deriving state inside an effect + `setState` causes an extra render and a flash — **compute it during render**. - Every subscription, timer, or listener an effect creates needs a **cleanup** function. +### Data fetching in effects + +- Responses can arrive **out of order**: ignore stale ones in the effect cleanup (an `ignore` flag or `AbortController`), or a slow earlier request overwrites newer data. +- Effect-based fetching creates **waterfalls** (parent fetches → child mounts → child fetches); hoist fetching to route loaders, Server Components, or a query library. +- Strict Mode runs effects twice in development, so a fetch without cleanup fires twice there. + ### Memoization pitfalls - `React.memo` is defeated by a **new object, array, or function** literal passed as a prop on every render. diff --git a/docs/topics/golang.md b/docs/topics/golang.md index cad31a3..fea1c0f 100644 --- a/docs/topics/golang.md +++ b/docs/topics/golang.md @@ -7,8 +7,9 @@ What experienced Go engineers forget before an interview, grouped by subtopic. ### Scheduler (GMP) - Goroutines (G) run on OS threads (M) through logical processors (P); **`GOMAXPROCS`** = number of Ps. -- Default = min(logical CPUs, affinity mask); **since Go 1.25** also capped by the cgroup CPU limit (rounded up, floor 2) and updated when it changes — before that, containers needed `automaxprocs`. +- Default = min(logical CPUs, affinity mask); since Go 1.25 also capped by the cgroup CPU limit (rounded up, floor 2) and updated when it changes — before that, containers needed `automaxprocs`. - Blocking syscall → the M is parked and the P moves to another M; network I/O goes through the netpoller and doesn't hold a thread. +- Each P has a local run queue (256 goroutines) plus a `runnext` slot; an idle P takes half of another P's queue (**work stealing**), and every 61st schedule checks the global queue for fairness. - Preemption is asynchronous (signal-based) since Go 1.14, so tight loops no longer starve the scheduler. - Goroutines start with a **2 KB** stack that grows and is copied as needed — this is why launching hundreds of thousands is normal. @@ -51,9 +52,10 @@ Only the sender should close a channel; `for range ch` ends once it's closed and ### context.Context - Carries cancellation, deadlines, and request-scoped values across API and goroutine boundaries; canceling a parent cancels all children. -- `WithCancelCause` (**1.20**) lets callers retrieve *why* a context was canceled via `context.Cause(ctx)`. +- `WithCancelCause` (1.20) lets callers retrieve *why* a context was canceled via `context.Cause(ctx)`. - `AfterFunc` and `WithoutCancel` (**1.21**): run a function on cancellation, or derive a context that keeps values but drops the parent's cancellation. - Pass as the **first parameter**, never store in a struct; use `WithValue` only for request-scoped data, not optional parameters. +- Every `WithCancel`/`WithTimeout`/`WithDeadline` returns a `cancel` func: call it (**`defer cancel()`**) or the child context and its timer live until the parent ends; `go vet` flags it (`lostcancel`). ### Patterns and goroutine leaks @@ -105,8 +107,9 @@ Only the sender should close a channel; `for range ch` ends once it's closed and - Hash table; implemented as **Swiss tables since Go 1.24** (faster, but iteration order was already randomized and remains so). - Concurrent write (or write + read) is a race; the runtime detects it best-effort, and then it's a **fatal, unrecoverable** error, not a panic you can `recover`. -- Maps never shrink after deletions; `clear(m)` (**1.21**) empties one without reallocating the header. +- Maps never shrink after deletions; `clear(m)` (1.21) empties one without reallocating the header. - Map values aren't addressable: `&m[k]` and `m[k].field = x` don't compile for struct values. +- Reading a nil map returns zero values, but **writing to a nil map panics** — `make` it first (a nil slice, by contrast, works with `append`). ### Strings @@ -166,6 +169,13 @@ Only the sender should close a channel; `for range ch` ends once it's closed and - Always **close `resp.Body`** (and drain it) or the connection isn't reused and leaks. - `http.Server` needs `ReadHeaderTimeout`/`ReadTimeout`/`WriteTimeout`, or slow clients (Slowloris) hold connections open. +### encoding/json gotchas + +- Numbers decoded into `any` become **float64**, so integer IDs above 2⁵³ lose precision — use `Decoder.UseNumber` or a typed field. +- A nil slice or map encodes as `null`, an empty one as `[]` or `{}`. +- Unexported fields are silently skipped; unknown JSON fields are ignored unless `DisallowUnknownFields`; field-name matching is case-insensitive. +- `omitempty` never omits a struct value (a zero `time.Time` included); **`omitzero`** (1.24) does. + ### Routing, JSON, logging - **`ServeMux` patterns since 1.22**: methods and wildcards, `mux.HandleFunc("GET /items/{id}", h)` with `r.PathValue("id")`. diff --git a/docs/topics/javascript.md b/docs/topics/javascript.md index cc071a9..f2ae6c4 100644 --- a/docs/topics/javascript.md +++ b/docs/topics/javascript.md @@ -78,6 +78,13 @@ What experienced JavaScript engineers forget before an interview, grouped by sub | `Promise.race` | first settles (either way) | timeouts, first response wins | | `Promise.any` | first fulfills, or all reject (`AggregateError`) | first success wins | +### async/await ordering + +- The `new Promise` executor runs **synchronously**; only the `.then` callbacks are deferred. +- Code after `await` always resumes as a microtask, even when the awaited value is already resolved or isn't a promise. +- Inside `try`, **`return promise`** skips the `catch` when it rejects; write `return await promise`. +- An `async` function always returns a new promise, so a `throw` inside it becomes a rejection, not a synchronous exception. + ### Sequential vs parallel await - `for (const x of xs) await f(x)` runs **serially**: each call starts after the previous settles; start all calls first, then `await Promise.all([...])` so they overlap. @@ -88,6 +95,13 @@ What experienced JavaScript engineers forget before an interview, grouped by sub - **`AbortController`** cancels `fetch` and other abortable APIs via a shared `AbortSignal`; `AbortSignal.timeout(ms)` builds a deadline. - **`for await...of`** consumes async generators and any object with `Symbol.asyncIterator`. +### fetch semantics + +- `fetch` rejects only on network failure (DNS, refused connection, CORS, abort); HTTP 4xx/5xx **resolve** with `res.ok === false`, so check it. +- The body is a stream and can be read **once**; call `res.clone()` before reading it twice. +- There is no default timeout: pass `signal: AbortSignal.timeout(ms)`. +- Cookies go only to the same origin by default (`credentials: 'same-origin'`); cross-origin requests need `'include'` plus CORS credential headers. + ### Promise helpers - **`Promise.withResolvers()`** (ES2024) returns `{ promise, resolve, reject }`. @@ -113,6 +127,13 @@ What experienced JavaScript engineers forget before an interview, grouped by sub - Common leaks: **detached DOM nodes** still referenced from JS, forgotten listeners and timers, unbounded caches. - A closure keeps its referenced outer variables alive, so a long-lived listener can retain a large object it barely uses. +### Hidden classes and inline caches + +- V8 gives objects created with the same properties in the same order a shared **hidden class** (shape); adding a property transitions to a new one. +- Each property-access site caches the shapes it has seen: monomorphic (one) is fastest, polymorphic up to 4, then **megamorphic** (a generic slow lookup). +- Initialize every field in the constructor in a fixed order; `delete` on a hot object can drop it into slow dictionary mode. +- Arrays track element kinds too: mixing integers, doubles, and holes (`new Array(n)`) downgrades them for good. + ### Weak references - **`WeakMap`/`WeakSet`** keys don't keep objects alive — good for per-object metadata and caches. diff --git a/docs/topics/networking.md b/docs/topics/networking.md index e04b5b5..47ac204 100644 --- a/docs/topics/networking.md +++ b/docs/topics/networking.md @@ -10,6 +10,16 @@ What experienced engineers forget about networking before an interview, grouped - A cold HTTPS request over TCP costs about **3 RTTs** before the first response byte; **HTTP/3** saves one, and resumption with 0-RTT saves more. - Every later request reuses the connection, which is why keep-alive and connection pools matter. +### Connection failure signatures + +| Symptom | Usual cause | +|---|---| +| Connection refused | RST: host reachable, nothing listening on the port | +| Connect timeout | SYN dropped: firewall, security group, or dead host; Linux retries the SYN for **~127 s**, so set connect timeouts | +| Connection reset by peer | peer crashed, or a middlebox dropped the flow after its idle timeout | +| **502** from a proxy | upstream refused, reset, or sent an invalid response | +| **504** from a proxy | upstream didn't answer in time | + ### Debugging tools - `dig` (DNS answer, TTL), `curl -v` and `curl -w '%{time_connect} %{time_appconnect} %{time_starttransfer}'` (per-phase timing). @@ -36,6 +46,13 @@ What experienced engineers forget about networking before an interview, grouped - Throughput ≤ window / RTT (**bandwidth-delay product**) — high-latency links need large windows. - CUBIC (Linux default) backs off on packet loss; BBR models bandwidth and RTT instead, doing better on lossy links. +### Retransmission and loss recovery + +- The retransmission timeout (**RTO**) derives from smoothed RTT; Linux floors it at **200 ms** (initial 1 s) and doubles it on each retry. +- One lost packet on a quiet connection therefore adds ≥ 200 ms — a classic cause of p99 spikes. +- **Fast retransmit**: 3 duplicate ACKs resend the missing segment without waiting for the RTO; SACK tells the sender exactly which ranges arrived. +- A lost last segment produces no duplicate ACKs; Linux's tail loss probe resends it after ~2 RTTs instead of waiting for the RTO. + ### Keepalive and half-open connections - **TCP keepalive** probes an idle connection to detect a dead peer (Linux: first probe after **2 hours** by default); HTTP keep-alive only means reusing a connection — unrelated. @@ -57,7 +74,7 @@ What experienced engineers forget about networking before an interview, grouped - No handshake, ordering, retransmission, or congestion control — the application decides. - Used where latency beats reliability or the protocol handles it itself: DNS, VoIP, games, **QUIC**. -## HTTP versions +## HTTP ### HTTP/1.1 @@ -81,6 +98,12 @@ What experienced engineers forget about networking before an interview, grouped - Starts as HTTP/1.1 **`Upgrade: websocket`** → **`101 Switching Protocols`**, then framed full-duplex messages on the same TCP connection. - Proxies and load balancers need idle timeouts above the app's ping interval, or they drop quiet connections. +### Client IP behind proxies + +- L7 proxies append the peer's address to **`X-Forwarded-For`**; clients can forge earlier entries, so trust only those your own proxies added — read from the right, skipping known proxy hops. +- L4 load balancers either preserve the source IP or pass it in a **PROXY protocol** header, which the backend must be configured to expect. +- Rate limits, geo-blocking, and audit logs depend on it: taking the leftmost entry lets any client spoof its IP. + ## DNS ### Resolution path @@ -110,6 +133,12 @@ What experienced engineers forget about networking before an interview, grouped - `/24` = 256 addresses, `/16` = 65,536; each bit less doubles the block. - Private ranges: **10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16**; 100.64.0.0/10 is carrier-grade NAT; AWS reserves **5 addresses** per subnet. +### Routing tables + +- The kernel picks the **longest prefix match**: a `/32` route beats a `/24`, which beats the default route `0.0.0.0/0` (the gateway). +- On the local link, **ARP** (IPv6: neighbor discovery) resolves the next hop's MAC address; MACs change at every hop, while IPs stay end to end unless NAT rewrites them. +- `ip route get ` shows the route, interface, and source address the kernel would use. + ### NAT - NAT rewrites source IP and port and tracks each flow in a **connection-tracking table** — unsolicited inbound connections are dropped unless a port forward or static mapping exists. diff --git a/docs/topics/os.md b/docs/topics/os.md index 8ca9aa2..4ae08e7 100644 --- a/docs/topics/os.md +++ b/docs/topics/os.md @@ -15,6 +15,16 @@ What experienced engineers forget about Linux and OS internals before an intervi - **`exec()`** replaces the program image, keeping the PID and open descriptors (unless `O_CLOEXEC`). - Forking a multi-threaded process copies only the calling thread — locks held by others stay locked forever in the child. +### Process states + +| State | Meaning | +|---|---| +| R | running or runnable (on a run queue) | +| S | interruptible sleep: waiting for an event; signals wake it | +| **D** | uninterruptible sleep, usually disk or NFS I/O; even `SIGKILL` waits, and it counts toward load average | +| Z | zombie: exited, not yet reaped by its parent | +| T | stopped (`SIGSTOP`, a debugger) | + ### Zombies and orphans - A **zombie** has exited but its parent hasn't called `wait()` — it holds only a PID table entry, but enough of them exhaust PIDs. @@ -122,6 +132,12 @@ What experienced engineers forget about Linux and OS internals before an intervi - Data is durable only after **`fsync`** (or `fdatasync`); a new file also needs its **directory** fsynced. - After an fsync error, Linux may drop the dirty pages and a retry can falsely succeed — since 2018's "fsyncgate", **PostgreSQL panics** on fsync failure instead of retrying. +### Atomic file replace + +- Write a temp file in the **same directory** → `fsync` it → `rename()` it over the target → `fsync` the directory. +- `rename` within one filesystem is **atomic** on POSIX: readers see the old or the new file, never a torn mix. +- Skipping the first `fsync` can leave an empty file after a crash (the rename persisted before the data). + ### Zero-copy I/O - **`sendfile`**/`splice` move file data to a socket inside the kernel, skipping user-space copies — how static file servers and Kafka reach high throughput. @@ -145,6 +161,13 @@ What experienced engineers forget about Linux and OS internals before an intervi - A low-priority task holds a lock needed by a high-priority task while a medium-priority task starves it (Mars Pathfinder, 1997). - **Priority inheritance** temporarily boosts the lock holder. +### Atomics, CAS, and the ABA problem + +- **Compare-and-swap** writes only if the value still equals the expected one; retry loops build lock-free stacks, counters, and mutex fast paths. +- **ABA**: the value goes A → B → A between the read and the CAS, so a stale CAS succeeds (a popped stack node freed and reused); fix with version-tagged pointers or safe reclamation (hazard pointers, epochs). +- Under heavy contention, CAS loops bounce the cache line between cores and can be slower than a mutex. +- x86 is strongly ordered (TSO), ARM weakly ordered, so code that works on x86 can break on ARM without the right memory orderings ([rust.md](rust.md)). + ### False sharing - Cores transfer memory in **cache lines** (64 bytes on x86-64, 128 on Apple M-series); two threads writing different variables on the same line keep invalidating each other's caches. @@ -158,6 +181,18 @@ What experienced engineers forget about Linux and OS internals before an intervi - **`perf`** samples stacks with low overhead → flame graphs; **eBPF** tools (`bpftrace`, bcc) trace kernel events in production safely. - **`strace`** shows every syscall but slows the process heavily (ptrace) — avoid on hot production paths. +### Memory hierarchy latencies + +| Level | Latency | +|---|---| +| L1 cache | ~1 ns | +| L2 cache | ~4 ns | +| L3 cache | ~10–40 ns | +| DRAM | **~100 ns** | +| NVMe SSD read | ~10–100 µs | + +Sequential access and contiguous layouts (arrays over linked lists, struct-of-arrays) win through prefetching and full cache-line use. + ### CPU time breakdown - us (user code), sy (kernel), **wa** (idle waiting for I/O), **st** (stolen by the hypervisor — noisy neighbors on VMs). diff --git a/docs/topics/python.md b/docs/topics/python.md index 148c6ae..1da958d 100644 --- a/docs/topics/python.md +++ b/docs/topics/python.md @@ -71,8 +71,9 @@ What experienced Python engineers forget before an interview, grouped by subtopi ### multiprocessing start methods - **`fork`** copies the parent — fast, but can inherit inconsistent state (a lock held by another thread mid-acquire). -- `spawn` starts a fresh interpreter — slower, safest; **`forkserver`** forks children from a clean single-threaded server process. -- **`forkserver` is the Linux default since 3.14** (previously `fork`). +- `spawn` starts a fresh interpreter — slower, safest; `forkserver` forks children from a clean single-threaded server process. +- **`forkserver` is the Linux default since 3.14** (previously `fork`); macOS defaults to `spawn` since 3.8, Windows always has. +- With `spawn`/`forkserver`, children **re-import the main module**, so guard entry code with `if __name__ == "__main__":`; the target, arguments, and results must pickle (no lambdas, local functions, or open sockets). ### asyncio event loop @@ -102,6 +103,18 @@ What experienced Python engineers forget before an interview, grouped by subtopi - **LEGB** lookup: Local, Enclosing, Global, Built-in. - Assigning to a name anywhere in a function makes it local for the **whole** body, so reading it before the assignment raises `UnboundLocalError`; use `nonlocal`/`global`. +### Numeric gotchas + +- `//` and `%` **floor toward −∞**: `-7 // 2 == -4` and `-7 % 2 == 1`; C, Go, Rust, and JavaScript truncate toward zero (`-7 % 2 == -1`). +- **`round()` rounds half to even**: `round(2.5) == 2`, `round(3.5) == 4`; `round(2.675, 2) == 2.67` because the float is slightly below 2.675. +- `int` never overflows (arbitrary precision); `float` is an IEEE 754 double, so use **`decimal.Decimal`** built from strings for money. + +### Recursion depth + +- The default limit is **1000** frames (`sys.getrecursionlimit()`); going deeper raises `RecursionError`. +- There's no **tail-call optimization**, so deep DFS or memoized recursion on large inputs needs an explicit stack. +- `sys.setrecursionlimit` helps for moderate depths; for depths around 10⁵ and beyond, rewrite iteratively. + ### Copies and aliasing - `[[0] * 3] * 3` builds three references to the **same** inner list — mutating one row mutates all. @@ -124,6 +137,12 @@ What experienced Python engineers forget before an interview, grouped by subtopi - Multiple inheritance resolves via **C3 linearization** (the MRO, `Cls.__mro__`). - **`super()`** follows the instance's MRO, not the direct parent, so every class in a mixin chain must call `super().__init__()`. +### Shared class attributes + +- A mutable class attribute (`items = []` in the class body) is **shared by every instance**. +- `self.items.append(x)` mutates the shared list; `self.items = [...]` creates an instance attribute that shadows it. +- Create per-instance state in `__init__`; dataclasses force `field(default_factory=list)` for this reason. + ### Descriptors - An object with `__get__`/`__set__`/`__delete__` on a class attribute is a **descriptor**; `property`, bound methods, `classmethod`, and `staticmethod` are all built on it. diff --git a/docs/topics/rust.md b/docs/topics/rust.md index e76d685..e644f28 100644 --- a/docs/topics/rust.md +++ b/docs/topics/rust.md @@ -63,6 +63,13 @@ What experienced Rust engineers forget before an interview, grouped by subtopic. - Every type parameter is implicitly `Sized`; **`?Sized`** accepts `str`, `[T]`, or `dyn Trait` behind a pointer. - `impl Trait` in argument position is an anonymous generic; in return position it hides the concrete type but stays static dispatch. +### Eq, Ord, and Hash + +- `PartialEq`/`PartialOrd` allow incomparable values (NaN ≠ NaN); **`Eq`/`Ord`** promise a total order. +- `f64` implements none of `Eq`, `Ord`, or `Hash`, so it can't key a `HashMap` or `BTreeMap` or use `.sort()`; use `sort_by(f64::total_cmp)` or an ordered wrapper. +- `Hash` must agree with `Eq` (`a == b` ⇒ equal hashes), or map lookups silently fail. +- Derived `PartialOrd`/`Ord` compare fields in **declaration order** (enums by variant order). + ### Async functions in traits - **Async fn in traits** (**1.75**) desugars to a method returning `impl Future`. @@ -111,6 +118,12 @@ What experienced Rust engineers forget before an interview, grouped by subtopic. - **`AsRef`** is a cheap reference conversion for flexible parameters: `fn open>(p: P)`. - **`Borrow`** also promises identical `Eq`/`Hash`/`Ord`, which is why `HashMap::get` accepts a `&str`. +### Layout and niche optimization + +- **Niche optimization**: `Option<&T>`, `Option>`, and `Option` are the same size as the inner type — the forbidden null or zero value encodes `None`. +- The default `repr(Rust)` may reorder fields to cut padding; **`repr(C)`** fixes C field order for FFI. +- `&str`, `&[T]`, and `&dyn Trait` are two words (pointer + length or vtable); an enum is its largest variant plus a tag, unless a niche absorbs the tag. + ### Pin and Unpin - **`Pin

`** stops the pointee from moving **only if it's `!Unpin`**; most types are `Unpin` and move freely. @@ -123,6 +136,12 @@ What experienced Rust engineers forget before an interview, grouped by subtopic. - `?` returns early with `Err`, converting via **`From`**; on `Option` it returns `None`. - **`thiserror`** for libraries (typed enums callers can match); **`anyhow`** for applications (one dynamic error with context). +### Integer overflow and casts + +- Overflow **panics in debug builds and wraps in release** (unless `overflow-checks = true`), so state intent with `checked_*`, `wrapping_*`, `saturating_*`, or `overflowing_*`. +- `as` between integers truncates or reinterprets silently (`300_i32 as u8 == 44`, `-1_i32 as u32 == u32::MAX`); `try_from` fails instead. +- `as` from float to integer **saturates** (since 1.45), and NaN becomes 0. + ### Panics and unwinding - `panic!` **unwinds** by default, running destructors; `panic = "abort"` exits immediately — smaller binary, no recovery. @@ -156,6 +175,8 @@ What experienced Rust engineers forget before an interview, grouped by subtopic. - Futures are **lazy** — nothing runs until an executor (e.g. **Tokio**) polls them. - Holding a non-`Send` guard across `.await` makes the future non-`Send`, so it can't be spawned on a multi-threaded runtime. +- `tokio::spawn` needs a **`Send + 'static`** future: move owned data or `Arc` clones in, not references. +- Tokio's default runtime is multi-threaded with work stealing; `current_thread` plus a `LocalSet` runs non-`Send` futures; `JoinSet` spawns and awaits a group of tasks. ### Blocking and locks in async code diff --git a/docs/topics/security.md b/docs/topics/security.md index 2322010..93e9b22 100644 --- a/docs/topics/security.md +++ b/docs/topics/security.md @@ -36,6 +36,13 @@ What experienced engineers forget about application security before an interview - A proxy and the backend disagree on where a request ends (**`Content-Length` vs `Transfer-Encoding`**), so attacker bytes become the start of the next user's request. - Reject ambiguous requests at the edge, use HTTP/2 end to end, and keep proxies patched. +### Resource-exhaustion attacks + +- **ReDoS**: backtracking regex engines take exponential time on patterns like `(a+)+$` with crafted input; use linear-time engines (RE2, Go `regexp`, Rust `regex`) or match timeouts. +- Decompression bombs and XML **billion laughs** expand kilobytes into gigabytes — cap the decompressed size and disable entity expansion. +- Hash flooding sends colliding keys that make hash tables O(n) per operation; runtimes defend with randomized hash seeds (SipHash). +- Cap JSON nesting depth, GraphQL query depth and cost, and request sizes at the edge. + ## Browser-side attacks ### XSS @@ -63,6 +70,8 @@ What experienced engineers forget about application security before an interview - CORS is a **browser read policy**, not authentication or a firewall — non-browser clients ignore it. - A credentialed response can't use `Access-Control-Allow-Origin: *`; reflecting any `Origin` with credentials is equivalent to no policy. +- **Simple requests** (GET, HEAD, or POST with a form or `text/plain` body and no custom headers) go out without a preflight: the server acts on them even though the browser hides the response, so CORS is no CSRF defense. +- Other requests are **preflighted** with `OPTIONS`; `Access-Control-Max-Age` caches the result. ### Open redirect @@ -102,6 +111,13 @@ What experienced engineers forget about application security before an interview - An attacker plants a known session ID before login, then shares the victim's session once they authenticate. - Always **issue a new session ID** on authentication and privilege change. +### Password reset and recovery + +- Reset tokens are single-use, short-lived, high-entropy, and **stored hashed** like passwords. +- Respond identically whether or not the account exists; revoke other sessions after a reset. +- Build the reset link from a configured origin, never the request's `Host` header — **host-header poisoning** sends the token to the attacker's domain. +- Recovery is often the weakest login path (SIM swap, support-desk social engineering): hold it to the same assurance as MFA. + ### Browser token storage - **`HttpOnly` cookie**: safe from XSS token theft, needs `SameSite` + CSRF tokens — the default for web apps. @@ -163,6 +179,12 @@ What experienced engineers forget about application security before an interview | Encryption | yes, with the key | yes | confidentiality | | Hashing | no | no | integrity, fingerprint | +### Secure randomness + +- Tokens, session IDs, nonces, and reset codes need a **CSPRNG**: `crypto.getRandomValues`/`crypto.randomBytes`, Python `secrets`, Go `crypto/rand`. +- `Math.random`, Python `random` (Mersenne Twister, reconstructable from 624 outputs), and Go `math/rand` aren't designed for secrets. +- Use at least **128 bits** for unguessable tokens. + ### AES-GCM nonces - **AES-GCM** is authenticated encryption: confidentiality plus an integrity tag. diff --git a/docs/topics/solidity.md b/docs/topics/solidity.md index 60ccda9..575c0bb 100644 --- a/docs/topics/solidity.md +++ b/docs/topics/solidity.md @@ -109,11 +109,33 @@ What experienced Solidity engineers forget before an interview, grouped by subto - **`msg.sender == tx.origin`** no longer proves there is no code in the path: since EIP-7702 (Pectra, May 2025) a delegated EOA runs code and makes several calls per transaction. - `code.length == 0` doesn't prove an EOA either: it's 0 for a contract still in its constructor, and a 7702-delegated EOA has code. +### Admin keys and governance + +- **`Ownable2Step`** makes the new owner accept the transfer, so a typo in the address can't brick ownership. +- Route admin actions through a **timelock** controlled by a multisig, giving users a window to exit before a change lands. +- Flash-loan governance attacks borrow voting power for one transaction (Beanstalk, April 2022, ~$182M lost); snapshot voting power at proposal creation (`ERC20Votes` checkpoints) and add a voting delay. + ### Signature replay and malleability - Signed messages without a **nonce, chainId, and deadline** can be replayed on another chain or later. - ECDSA `s` can be flipped (`n − s`) into a second valid signature — enforce **low-`s`** and never use a signature as a unique ID. - Raw `ecrecover` returns `address(0)` on a bad signature, which matches an unset signer — use OpenZeppelin's `ECDSA`, which reverts and enforces low-`s`. +- Smart-contract wallets (Safe, ERC-4337 accounts) sign via **ERC-1271** `isValidSignature`; OpenZeppelin's `SignatureChecker` tries ECDSA, then ERC-1271, and ERC-6492 wraps signatures from wallets not yet deployed. + +### Denial of service + +- **Unbounded loops** over user-growable arrays eventually exceed the gas limit — paginate or cap the size. +- Pushing ETH to many receivers fails if one reverts (a contract without `receive`) — switch to **pull payments** (a withdraw function). +- A malicious callee can return huge data that Solidity copies into memory even when discarded — a **returnbomb**; cap the copy with an assembly `call`. + +### Randomness and block data + +- **`block.prevrandao`** (0.8.18, replaced `difficulty`) is known to the proposer, who can bias it by withholding a block — use **Chainlink VRF** or commit-reveal. +- `blockhash(n)` returns 0 for blocks older than **256**; EIP-2935 (Pectra) serves 8,191 hashes from a system contract, but the opcode is unchanged. +- Anything derived from block data can be computed by an attacker's contract in the same transaction, which reverts when the outcome is bad. +- On L1, `block.timestamp` advances in fixed 12 s slots; L2 sequencers set it within looser bounds. + +## Integration risks ### Token integration quirks @@ -129,18 +151,11 @@ What experienced Solidity engineers forget before an interview, grouped by subto - Chainlink `latestRoundData`: check **staleness** (`updatedAt` against the feed's heartbeat) and `answer > 0`; on L2s also check the **sequencer uptime feed**. - Feeds have their own decimals (USD pairs use 8, ETH pairs 18) — scale before combining with token amounts. -### Denial of service - -- **Unbounded loops** over user-growable arrays eventually exceed the gas limit — paginate or cap the size. -- Pushing ETH to many receivers fails if one reverts (a contract without `receive`) — switch to **pull payments** (a withdraw function). -- A malicious callee can return huge data that Solidity copies into memory even when discarded — a **returnbomb**; cap the copy with an assembly `call`. - -### Randomness and block data +### Front-running and slippage -- **`block.prevrandao`** (0.8.18, replaced `difficulty`) is known to the proposer, who can bias it by withholding a block — use **Chainlink VRF** or commit-reveal. -- `blockhash(n)` returns 0 for blocks older than **256**; EIP-2935 (Pectra) serves 8,191 hashes from a system contract, but the opcode is unchanged. -- Anything derived from block data can be computed by an attacker's contract in the same transaction, which reverts when the outcome is bad. -- On L1, `block.timestamp` advances in fixed 12 s slots; L2 sequencers set it within looser bounds. +- Public-mempool transactions can be front-run or **sandwiched**: the attacker trades right before and after the victim's swap. +- Swap and liquidity functions take a **`minAmountOut`** and a `deadline` chosen off-chain by the user; a minimum computed on-chain from the current spot price protects nothing. +- Use commit-reveal for bids, auctions, and games where seeing a pending transaction gives an edge; MEV mechanics in [ethereum.md](ethereum.md). ### Rounding and precision @@ -164,6 +179,13 @@ What experienced Solidity engineers forget before an interview, grouped by subto - Workarounds: move logic into external libraries, split into several contracts, lower optimizer `runs`, or use the Diamond pattern. - **EIP-7954**, scheduled for Glamsterdam, raises the limits to 64 KiB and 128 KiB. +### Clones and factories + +- An **EIP-1167 minimal proxy** is 45 bytes of runtime code that `delegatecall`s a fixed implementation, so deploying many instances (vaults, wallets, pools) costs a fraction of a full deployment. +- Clones can't be upgraded and run no constructor: they need an initializer, and each call pays an extra `DELEGATECALL`. +- **`CREATE2`** sets the address to `keccak256(0xff ++ deployer ++ salt ++ keccak256(initcode))[12:]`, known before deployment (counterfactual wallets). +- Derive the salt from the caller and the init parameters, or a front-runner can take the predicted address with other arguments. + ## Upgradeability ### Proxy patterns diff --git a/docs/topics/system.md b/docs/topics/system.md index 7b00174..14d4f27 100644 --- a/docs/topics/system.md +++ b/docs/topics/system.md @@ -15,6 +15,7 @@ Key system design building blocks and trade-offs, grouped by subtopic. For CAP, - 1 day ≈ 86,400 s ≈ 10⁵ s, so **1M requests/day ≈ 12 QPS**; assume peak ≈ 2–3× average unless told otherwise. - 1 KB × 1M items = 1 GB; 1 KB × 1B = 1 TB. - Ballpark capacity (varies with workload): a well-indexed PostgreSQL box handles **10k+ simple queries/s**; Redis ~100k ops/s per core. +- **Little's law** L = λ × W: requests in flight = throughput × latency — 1,000 RPS × 200 ms = 200 concurrent requests, which sizes thread pools, connection pools, and queues. ## Traffic and edge @@ -127,7 +128,20 @@ Key system design building blocks and trade-offs, grouped by subtopic. For CAP, - Components in **series** multiply: 99.9% × 99.9% ≈ 99.8%. - Redundant components in **parallel** fail only together: 1 − 0.001² ≈ 99.9999%. - Both formulas assume **independent failures**; a shared zone or dependency wipes out most of the parallel redundancy gain. -- RPO (acceptable data loss) and RTO (acceptable recovery time) drive backup and failover design; active-passive vs active-active. + +### Multi-region and disaster recovery + +- **RPO** = acceptable data loss, **RTO** = acceptable recovery time; together they pick the tier. + +| Tier | What runs in the standby region | RTO / RPO | +|---|---|---| +| Backup and restore | nothing; restore from backups | hours / hours | +| Pilot light | replicated data, compute off | tens of minutes / minutes | +| Warm standby | a scaled-down copy | minutes / seconds | +| Active-active | full capacity everywhere | ~zero / ~zero with sync replication | + +- Async cross-region replication means RPO > 0; active-active also needs conflict handling or a home region per record, plus global routing (GeoDNS, anycast). +- A failover that was never rehearsed rarely works: run regular game days. ### SLIs, SLOs, error budgets @@ -137,9 +151,11 @@ Key system design building blocks and trade-offs, grouped by subtopic. For CAP, ### Observability -- Metrics: numeric time series (Prometheus); **golden signals** latency, traffic, errors, saturation — **RED** for services, **USE** for resources. +- Metrics: numeric time series (Prometheus); golden signals latency, traffic, errors, saturation — **RED** for services, **USE** for resources. - Logs: structured, centralized, tagged with a request ID. Traces: a request's span tree across services (OpenTelemetry). - Metrics say something is wrong, traces say where, logs say why. +- Percentiles **can't be averaged** across hosts or time windows: merge the histograms (or sketches), then take p99. +- High-cardinality labels (user ID, request ID) multiply Prometheus time series; keep them in logs and traces. ## Architecture @@ -197,6 +213,13 @@ Key system design building blocks and trade-offs, grouped by subtopic. For CAP, - A **trie** (or prefix index) with precomputed **top-k suggestions** per node, built offline from query logs and cached aggressively. - Debounce on the client; for semantic matches, query an approximate nearest-neighbor index (HNSW). +### Video streaming + +- Upload to object storage → a **transcoding** pipeline splits the video into chunks and encodes them in parallel at several resolutions and bitrates. +- Package as **HLS or DASH**: 2–10 s segments plus a manifest listing the renditions, served from a CDN. +- The player picks a rendition per segment from measured bandwidth and buffer (**adaptive bitrate**), so quality drops instead of stalling. +- Pre-warm popular titles at the edge; the long tail streams from regional caches or the origin. + ### Notification system - One API → a queue per channel (push, SMS, email) → workers calling providers (APNs, FCM, Twilio) with retries. diff --git a/docs/topics/typescript.md b/docs/topics/typescript.md index ce8cb4c..45f614c 100644 --- a/docs/topics/typescript.md +++ b/docs/topics/typescript.md @@ -18,6 +18,18 @@ What experienced TypeScript engineers forget before an interview, grouped by sub - **`any`** turns checking off in both directions; **`unknown`** accepts anything but must be narrowed before use. - **`never`** is the empty type — the result of exhaustive narrowing and of functions that never return. +### `{}`, `object`, and index signatures + +- **`{}` means any non-nullish value** — strings and numbers included — not "empty object"; `Object` behaves the same. +- `object` is any non-primitive; `Record` is a truly empty object. +- With an index signature (`Record`), every key reads as present and typed `T` unless **`noUncheckedIndexedAccess`** is on. + +### Function assignability + +- A function returning a value is assignable to a **`void`-returning** function type, so `arr.forEach(x => out.push(x))` compiles and the result is ignored. +- A function with **fewer parameters** is assignable to one with more: callbacks may ignore arguments (`arr.map(x => x * 2)`). +- Only the contextual case is relaxed: a function declared with a `void` return type still can't return a value. + ### `interface` vs `type` - `interface` supports **declaration merging** (reopening adds members) and gives clearer error messages for object shapes. @@ -146,6 +158,12 @@ What experienced TypeScript engineers forget before an interview, grouped by sub ## Typing patterns +### Runtime validation at boundaries + +- Types are erased: `JSON.parse` and `res.json()` return `any`, and env vars or `as` casts are unchecked, so data can violate its declared type at runtime. +- Parse untrusted input with a schema library (Zod, Valibot, ArkType) and **derive the type from the schema** (`type User = z.infer`), so the two can't drift. +- Type unparsed input as **`unknown`**, not `any`, so it must be validated or narrowed before use. + ### Overloads - Several **overload signatures** followed by one implementation signature that callers can't see. From d4b38433ac3a80d83915dc9f71e924ae5c93397f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 30 Sep 2026 02:41:57 +0000 Subject: [PATCH 3/4] Apply trim and merge items from the coverage review Cut definition-level concepts, standard-library listings, version trivia, and stale support-status lines; fold one-bullet concepts into related ones; and remove the three cross-brief duplicates. Two P2 additions come along because trims depended on them: the Master theorem replaces the worked recurrences, and Context performance replaces "Where state lives". Concepts go from 675 to 645. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FADC1PgtXHNSjrM55y3LdW --- coverage-review.md | 160 ++++++++++++++++++------------------- docs/topics/ai.md | 12 +-- docs/topics/algorithms.md | 10 +-- docs/topics/aws.md | 9 +-- docs/topics/backend.md | 19 +---- docs/topics/database.md | 21 ++--- docs/topics/devops.md | 17 +--- docs/topics/distributed.md | 7 +- docs/topics/ethereum.md | 8 +- docs/topics/frontend.md | 20 ++--- docs/topics/golang.md | 26 +----- docs/topics/javascript.md | 23 +----- docs/topics/networking.md | 28 +++---- docs/topics/os.md | 12 +-- docs/topics/python.md | 45 +++++------ docs/topics/rust.md | 15 ++-- docs/topics/security.md | 24 +----- docs/topics/solidity.md | 16 ++-- docs/topics/system.md | 7 +- docs/topics/typescript.md | 12 +-- 20 files changed, 166 insertions(+), 325 deletions(-) diff --git a/coverage-review.md b/coverage-review.md index 6afbf77..0e66cc4 100644 --- a/coverage-review.md +++ b/coverage-review.md @@ -2,7 +2,7 @@ Temporary working file (2026-09-29): tick the items to act on, then delete this file before merging. -**Status (2026-09-30):** all 72 P1 items are applied (619 → 675 concepts) and ticked below; notes in *italics* say where placement differs from the proposal. The section limit in AGENTS.md is now 5–20. P2, P3, and trim items are untouched. +**Status (2026-09-30):** all 72 P1 items are applied (619 → 675 concepts) and ticked below; notes in *italics* say where placement differs from the proposal. The section limit in AGENTS.md is now 5–20. All cut, merge, restructure, and duplicate items are applied too (675 → 645 concepts). Two P2 items were pulled in because a trim depended on them: the Master theorem and Context performance. The rest of P2 and P3 is untouched. **Legend** @@ -60,16 +60,16 @@ No file owned these; each is now named in the AGENTS.md ownership table (merged ### Duplicates -- [ ] solidity `Oracle integration` bullet 1 repeats ethereum `Oracle manipulation` bullet 1 (owner: ethereum). Keep only the link in solidity. -- [ ] backend `File uploads` bullet 1 repeats system `CDN and object storage` bullet 2 (presigned URLs, metadata only). Keep one. -- [ ] aws `KMS and envelope encryption` bullet 1 re-explains envelope encryption (owner: security). Keep the AWS-specific facts: `GenerateDataKey` and the 4 KB `Encrypt` limit. +- [x] solidity `Oracle integration` bullet 1 repeats ethereum `Oracle manipulation` bullet 1 (owner: ethereum). Keep only the link in solidity. +- [x] backend `File uploads` bullet 1 repeats system `CDN and object storage` bullet 2 (presigned URLs, metadata only). Keep one. +- [x] aws `KMS and envelope encryption` bullet 1 re-explains envelope encryption (owner: security). Keep the AWS-specific facts: `GenerateDataKey` and the 4 KB `Encrypt` limit. - [x] distributed `Effectively-once processing` would overlap the proposed Delivery guarantees concept. Merge them. *Done: replaced by Delivery guarantees.* ### Structure - Section counts: no brief exceeds the new 20-section limit (javascript has 12, system 11), so no merges are needed for that reason. - [ ] Many sections have only 2 concepts (guide: 3–8). The P1 items filled backend Service calls, ai Training and fine-tuning, and rust Error handling; *new* P2 items would fill devops CI/CD, ethereum Consensus, rust Unsafe and FFI, and security Supply chain. Merge the rest where they stay thin. -- [ ] Growth budget: P1 added 56 concepts (619 → 675). The remaining 107 P2 and 51 P3 items include 59 *new* P2 concepts; the cut/merge items remove about 24 whole concepts plus many bullets. Pairing each add with a trim in the same brief keeps skimming and quizzes fast. +- [ ] Growth budget: P1 added 56 concepts (619 → 675) and the trims removed 30 (→ 645). The remaining 105 P2 and 51 P3 items include 58 *new* P2 concepts; pair each add with a trim in the same brief to keep skimming and quizzes fast. ## Fundamentals @@ -83,7 +83,7 @@ Solid on arrays, DP, and graphs. Missing the problem-solving heuristics and a fe - [x] P1 · new · *Data structures* › **Heap patterns**: **k-way merge** of k sorted lists with a size-k min-heap, O(n log k); **two heaps** (max-heap for the lower half, min-heap for the upper) give a running median in O(log n) per insert; lazy deletion for removals. - [x] P1 · new · *Arrays and sequences* › **Maximum subarray (Kadane)**: `cur = max(x, cur + x)`, `best = max(best, cur)`, O(n) time and O(1) space; circular variant = max(best, total − minimum subarray) unless every value is negative. The section reaches 8 concepts. - [x] P1 · new · *Sorting and selection* (rename "Sorting, selection, and sampling") › **Random sampling and shuffling**: **reservoir sampling** keeps the i-th item with probability k/i (one pass, O(k) memory, unknown stream length); **Fisher–Yates** swaps `a[i]` with `a[rand(0..i)]`; drawing from the whole array at each step is biased. -- [ ] P2 · extend · **Recurrence patterns** with the **Master theorem**: `T(n) = aT(n/b) + f(n)`; compare f(n) with n^(log_b a): smaller → Θ(n^(log_b a)), equal → Θ(n^(log_b a) · log n), larger → Θ(f(n)). Replaces the two worked examples. +- [x] P2 · extend · **Recurrence patterns** with the **Master theorem**: `T(n) = aT(n/b) + f(n)`; compare f(n) with n^(log_b a): smaller → Θ(n^(log_b a)), equal → Θ(n^(log_b a) · log n), larger → Θ(f(n)). Replaces the two worked examples. - [ ] P2 · extend · **Knapsack and one-dimensional DP**: coin change with coins in the outer loop counts **combinations**; with the amount in the outer loop it counts **permutations**. - [ ] P2 · extend · **Shortest-path choices** table: 0/1 weights → **0-1 BFS** with a deque, O(V+E); all pairs → **Floyd–Warshall** O(V³) (negative edges fine; a negative diagonal entry means a negative cycle); Dijkstra skips stale heap entries (lazy deletion). - [ ] P2 · new · *Trees and graphs* › **Cycle detection and bipartiteness**: directed → DFS with three colors (reaching a gray node = back edge = cycle); undirected → a visited neighbor that isn't the parent, or union-find; bipartite ⇔ BFS 2-coloring succeeds ⇔ no odd cycle. @@ -98,9 +98,9 @@ Solid on arrays, DP, and graphs. Missing the problem-solving heuristics and a fe **Trim** -- [ ] cut · **Time and space bounds** bullet 1's opening ("state the input size…"): generic advice. Keep the Ω(k) output-size point. -- [ ] cut · **Recurrence patterns** bullets 1–2: two textbook recurrences, superseded by the Master theorem. -- [ ] cut · **LRU cache** bullet 2: library API listing (low confidence; handy mid-interview). +- [x] cut · **Time and space bounds** bullet 1's opening ("state the input size…"): generic advice. Keep the Ω(k) output-size point. +- [x] cut · **Recurrence patterns** bullets 1–2: two textbook recurrences, superseded by the Master theorem. *Replaced by the Master theorem, with merge sort and binary search as one-line examples.* +- [x] cut · **LRU cache** bullet 2: library API listing (low confidence; handy mid-interview). *Split the remaining bullet in two.* ### Databases @@ -128,11 +128,11 @@ Strong on PostgreSQL and InnoDB internals. Weaker on everyday SQL pitfalls, inde **Trim** -- [ ] cut · **Redis persistence and licensing** bullet 3: license history is trivia; at most "Valkey is the drop-in open-source fork". -- [ ] cut · **OLTP vs OLAP** bullet 1: definition-level. Keep the column-store bullet. -- [ ] merge · **InnoDB MVCC** (one bullet) into **MySQL InnoDB isolation**. -- [ ] merge · **Deep pagination cost** (one bullet) into the new index concept; backend owns pagination. -- [ ] merge · **Materialized views** (one bullet) into **OLTP vs OLAP** or the denormalization bullet in **Normalization**. +- [x] cut · **Redis persistence and licensing** bullet 3: license history is trivia; at most "Valkey is the drop-in open-source fork". *Dropped entirely; the concept is now *Redis persistence and replication*.* +- [x] cut · **OLTP vs OLAP** bullet 1: definition-level. Keep the column-store bullet. +- [x] merge · **InnoDB MVCC** (one bullet) into **MySQL InnoDB isolation**. *The merged concept is *InnoDB isolation and MVCC*.* +- [x] merge · **Deep pagination cost** (one bullet) into the new index concept; backend owns pagination. +- [x] merge · **Materialized views** (one bullet) into **OLTP vs OLAP** or the denormalization bullet in **Normalization**. *Merged into OLTP vs OLAP.* ### Distributed Systems @@ -157,7 +157,7 @@ Strong and dense. **Trim** -- [ ] merge · **Window types** (one bullet) into **Event time and watermarks**; frees a slot in Stream processing for CDC. +- [x] merge · **Window types** (one bullet) into **Event time and watermarks**; frees a slot in Stream processing for CDC. - [x] merge · **Effectively-once processing** into the Delivery guarantees concept above. ### Networking @@ -180,9 +180,9 @@ The smallest brief (5 sections, 22 concepts). Good fundamentals, light on troubl **Trim** -- [ ] merge · **UDP**: definition-level. Move "DNS, VoIP, games, QUIC" into **HTTP/3 and QUIC** or **Head-of-line blocking**. -- [ ] cut · **HTTP/1.1** bullet 2's history (domain sharding, sprite sheets). Keep "~6 connections per host". -- [ ] merge · **Debugging tools**: a tool list. Fold it into the failure-signatures concept as symptom → tool. +- [x] merge · **UDP**: definition-level. Move "DNS, VoIP, games, QUIC" into **HTTP/3 and QUIC** or **Head-of-line blocking**. +- [x] cut · **HTTP/1.1** bullet 2's history (domain sharding, sprite sheets). Keep "~6 connections per host". +- [x] merge · **Debugging tools**: a tool list. Fold it into the failure-signatures concept as symptom → tool. *Now a *Check with* column in the failure-signatures table.* ### Operating Systems @@ -204,9 +204,9 @@ Good coverage of memory and I/O. Missing process states, a safe file-replace pat **Trim** -- [ ] cut · **Processes vs threads** bullet 1: definition-level. Keep the `clone()` bullet, merged into **fork, exec, copy-on-write**. -- [ ] cut · **Priority inversion**: rarely asked outside real-time roles (low confidence; Mars Pathfinder is a good memory hook). -- [ ] cut · **Linux observability tools** bullet 1: a tool list. Keep the perf/eBPF/strace bullets, or turn the concept into a symptom → tool table. +- [x] cut · **Processes vs threads** bullet 1: definition-level. Keep the `clone()` bullet, merged into **fork, exec, copy-on-write**. *The concept is gone; its `clone()` bullet moved to fork, exec, copy-on-write.* +- [x] cut · **Priority inversion**: rarely asked outside real-time roles (low confidence; Mars Pathfinder is a good memory hook). +- [x] cut · **Linux observability tools** bullet 1: a tool list. Keep the perf/eBPF/strace bullets, or turn the concept into a symptom → tool table. ### System Design @@ -230,9 +230,9 @@ Strong building blocks and classic designs. Missing capacity math, metric aggreg **Trim** -- [ ] cut · **Leaderboard** bullet 2: Redis command deprecation trivia. -- [ ] cut · **SQL vs NoSQL** bullet 1: definition-level. -- [ ] cut · **Monolith vs microservices** bullets 1–2: well-known pros and cons. Keep "modular monolith by default" and Conway's law. +- [x] cut · **Leaderboard** bullet 2: Redis command deprecation trivia. +- [x] cut · **SQL vs NoSQL** bullet 1: definition-level. +- [x] cut · **Monolith vs microservices** bullets 1–2: well-known pros and cons. Keep "modular monolith by default" and Conway's law. ## Languages @@ -256,11 +256,11 @@ Strong runtime and concurrency coverage. Missing several everyday gotchas; a few **Trim** -- [ ] cut · **Newer language features**: syntax trivia (`min`/`max`, range over int, generic type aliases). Keep `new(expr)` at most. -- [ ] cut · **Toolchains and tools**: `GOTOOLCHAIN`, `tool` directives, and `go fix` modernizers are rarely asked. -- [ ] cut · **Routing, JSON, logging** bullets 2–3: json/v2's status keeps moving and "`log/slog` exists" is trivia. Replace them with the encoding/json gotchas concept. -- [ ] cut · **Test tooling** bullet 1: table-driven tests and `t.Run`/`t.Parallel`/`t.Cleanup` are basics. -- [ ] cut · **Cleanups, weak pointers, interning**: niche runtime APIs (low confidence). +- [x] cut · **Newer language features**: syntax trivia (`min`/`max`, range over int, generic type aliases). Keep `new(expr)` at most. *`new(expr)` dropped too.* +- [x] cut · **Toolchains and tools**: `GOTOOLCHAIN`, `tool` directives, and `go fix` modernizers are rarely asked. +- [x] cut · **Routing, JSON, logging** bullets 2–3: json/v2's status keeps moving and "`log/slog` exists" is trivia. Replace them with the encoding/json gotchas concept. *The remaining ServeMux bullet moved into net/http clients and servers.* +- [x] cut · **Test tooling** bullet 1: table-driven tests and `t.Run`/`t.Parallel`/`t.Cleanup` are basics. +- [x] cut · **Cleanups, weak pointers, interning**: niche runtime APIs (low confidence). ### JavaScript @@ -281,11 +281,11 @@ Good language-semantics coverage, but light on async ordering and engine interna **Trim** -- [ ] cut · **Array and object helpers**: standard-library listing (`toSorted`, `with`, `groupBy`). -- [ ] cut · **Promise helpers**: API listing (`withResolvers`, `try`). -- [ ] cut · **Sets and iterators** bullet 1: Set method list. Keep the lazy iterator-helpers bullet. -- [ ] cut · **Temporal** bullet 2: browser support status goes stale within months. -- [ ] cut · **Workers, cluster, child processes** bullet 3: `spawn` vs `exec` basics. +- [x] cut · **Array and object helpers**: standard-library listing (`toSorted`, `with`, `groupBy`). +- [x] cut · **Promise helpers**: API listing (`withResolvers`, `try`). +- [x] cut · **Sets and iterators** bullet 1: Set method list. Keep the lazy iterator-helpers bullet. *The iterator-helpers bullet moved into Iterators and generators.* +- [x] cut · **Temporal** bullet 2: browser support status goes stale within months. +- [x] cut · **Workers, cluster, child processes** bullet 3: `spawn` vs `exec` basics. *Renamed *Worker threads and cluster*.* ### Python @@ -307,11 +307,11 @@ Strong on the runtime, object model, and asyncio. Missing a few classic gotchas **Trim** -- [ ] cut · **Refcounting and the cyclic GC** bullet 2: patch-release GC history won't be asked. -- [ ] cut · **Mutation during iteration** bullet 2: "dict order since 3.7" repeats dict internals. -- [ ] merge · **Late-binding closures** (one bullet) into **Mutable default arguments** (same `i=i` fix) or **Scope and `UnboundLocalError`**. -- [ ] cut · **Specializing interpreter and JIT** bullet 2: the JIT is off by default (low confidence). -- [ ] restructure · merge Recent language features + Typing (2 concepts each). +- [x] cut · **Refcounting and the cyclic GC** bullet 2: patch-release GC history won't be asked. +- [x] cut · **Mutation during iteration** bullet 2: "dict order since 3.7" repeats dict internals. +- [x] merge · **Late-binding closures** (one bullet) into **Mutable default arguments** (same `i=i` fix) or **Scope and `UnboundLocalError`**. *Merged into *Default arguments and late binding*.* +- [x] cut · **Specializing interpreter and JIT** bullet 2: the JIT is off by default (low confidence). *Renamed *Specializing interpreter*.* +- [x] restructure · merge Recent language features + Typing (2 concepts each). *Now *Typing and recent features*.* ### Rust @@ -333,10 +333,10 @@ Strong on ownership, traits, and async. Missing numeric semantics, the standard **Trim** -- [ ] cut · **Iterators** bullet 2: `iter`/`iter_mut`/`into_iter` basics. -- [ ] cut · **String vs &str** bullet 1: basics. Keep the no-indexing and char-boundary panic bullet. -- [ ] cut · **Lock files and editions** bullet 2's version note ("edition 2024 since 1.85"). Keep what edition 2024 changes. -- [ ] merge · **Async closures** (one bullet) into **Futures and executors** or **Fn, FnMut, FnOnce**. +- [x] cut · **Iterators** bullet 2: `iter`/`iter_mut`/`into_iter` basics. +- [x] cut · **String vs &str** bullet 1: basics. Keep the no-indexing and char-boundary panic bullet. +- [x] cut · **Lock files and editions** bullet 2's version note ("edition 2024 since 1.85"). Keep what edition 2024 changes. +- [x] merge · **Async closures** (one bullet) into **Futures and executors** or **Fn, FnMut, FnOnce**. *Merged into Fn, FnMut, FnOnce.* ### Solidity @@ -354,14 +354,14 @@ The most thorough brief (254 lines). Few additions; trimming version trivia matt **Trim** (keep the mechanism, drop the release number) -- [ ] cut · **Modifiers** bullet 4: `virtual` modifier deprecation (0.8.31). -- [ ] cut · **Libraries and user-defined types**: the `global` (0.8.13) and operator-binding (0.8.19) version details. -- [ ] cut · **Transient and relocated storage** bullet 3: `layout at` (0.8.29/0.8.35) is niche. -- [ ] cut · **Error types** bullet 4: the 0.8.26 vs 0.8.27 split for `require(cond, Error())`. -- [ ] cut · **Assembly gotchas** bullet 2's deprecated-comment clause, and **Gas optimization patterns** bullet 5's 0.8.22 note. -- [ ] cut · **Code size limit** bullet 3: EIP-7954 and Glamsterdam are still moving; re-add once shipped. -- [ ] cut · **Oracle integration** bullet 1: duplicate of ethereum.md (owner). -- [ ] cut · **Randomness and block data** bullet 4: the timestamp slot detail is minor. +- [x] cut · **Modifiers** bullet 4: `virtual` modifier deprecation (0.8.31). +- [x] cut · **Libraries and user-defined types**: the `global` (0.8.13) and operator-binding (0.8.19) version details. +- [x] cut · **Transient and relocated storage** bullet 3: `layout at` (0.8.29/0.8.35) is niche. +- [x] cut · **Error types** bullet 4: the 0.8.26 vs 0.8.27 split for `require(cond, Error())`. +- [x] cut · **Assembly gotchas** bullet 2's deprecated-comment clause, and **Gas optimization patterns** bullet 5's 0.8.22 note. +- [x] cut · **Code size limit** bullet 3: EIP-7954 and Glamsterdam are still moving; re-add once shipped. +- [x] cut · **Oracle integration** bullet 1: duplicate of ethereum.md (owner). *Now one line linking to ethereum.md.* +- [x] cut · **Randomness and block data** bullet 4: the timestamp slot detail is minor. ### TypeScript @@ -381,9 +381,9 @@ Good type-system depth. The biggest gap is the runtime boundary (types vanish), **Trim** -- [ ] merge · **Structural typing** (one definition-level bullet) into **Branded types**, which exists because of it. -- [ ] cut · **TypeScript 7 native compiler** bullet 2: tooling compatibility status will change within months. -- [ ] merge · **Exhaustiveness with `never`** (one bullet) into **Control-flow narrowing** (low confidence). +- [x] merge · **Structural typing** (one definition-level bullet) into **Branded types**, which exists because of it. +- [x] cut · **TypeScript 7 native compiler** bullet 2: tooling compatibility status will change within months. +- [x] merge · **Exhaustiveness with `never`** (one bullet) into **Control-flow narrowing** (low confidence). ## Web @@ -404,10 +404,10 @@ Good API and reliability patterns. Missing schema evolution, tenancy, time handl **Trim** -- [ ] cut · **Resource modeling**: REST naming basics. -- [ ] cut · **Configuration and secrets**: 12-factor generics. Keep "validate config at startup" at most. -- [ ] cut · **File uploads** bullet 1: duplicates system.md. Keep the multipart/resumable bullet. -- [ ] cut · **Queue vs direct call**: system.md's **Queue semantics** covers it (low confidence). +- [x] cut · **Resource modeling**: REST naming basics. +- [x] cut · **Configuration and secrets**: 12-factor generics. Keep "validate config at startup" at most. *Cut entirely; the section is now *Service lifecycle*.* +- [x] cut · **File uploads** bullet 1: duplicates system.md. Keep the multipart/resumable bullet. *Shortened to a link to system.md.* +- [x] cut · **Queue vs direct call**: system.md's **Queue semantics** covers it (low confidence). ### Frontend @@ -422,7 +422,7 @@ Good breadth. Missing the React data-fetching and state-update gotchas that inte - [ ] P2 · new · *React hooks pitfalls* › **useLayoutEffect vs useEffect**: `useEffect` runs after paint; `useLayoutEffect` runs after DOM mutation but **before paint**, for measuring layout without flicker, at the cost of blocking paint. - [ ] P2 · extend · **Core Web Vitals**: rankings use **field data** (CrUX, p75 over 28 days, mobile and desktop separately); a page-load Lighthouse run is lab data and can't measure INP, so it reports TBT as a proxy. - [ ] P2 · new · *Performance* › **Long lists**: **virtualize** (render only the visible rows: TanStack Virtual, react-window) beyond a few hundred complex rows; keep stable keys for infinite scroll. -- [ ] P2 · new · *State management* › **Context performance** (replaces **Where state lives**): every consumer re-renders when the provider `value` changes identity, so memoize it, split state and dispatch into separate contexts, or use a store with selectors (`useSyncExternalStore`). +- [x] P2 · new · *State management* › **Context performance** (replaces **Where state lives**): every consumer re-renders when the provider `value` changes identity, so memoize it, split state and dispatch into separate contexts, or use a store with selectors (`useSyncExternalStore`). - [ ] P2 · new · *Performance* › **Web fonts**: `font-display: swap` shows fallback text instead of invisible text but causes a swap shift; `size-adjust` and metric overrides reduce that CLS; preload the one critical font; subset and self-host. - [ ] P2 · extend · **Semantic HTML and ARIA**: dynamic messages (toasts, form errors) need an **`aria-live`** region; every input needs a programmatic label; test with axe and a keyboard. - [ ] P3 · new · *State management* › **Signals**: fine-grained reactivity (Solid, Preact, Vue, Angular signals) updates only the dependents without a VDOM diff; a TC39 Signals proposal exists. @@ -431,11 +431,11 @@ Good breadth. Missing the React data-fetching and state-update gotchas that inte **Trim** -- [ ] cut · **CSS layout and specificity** bullet 1: flexbox vs grid basics. -- [ ] cut · **Modern CSS features**: feature listing and Baseline status. Keep container queries and `:has()`. -- [ ] cut · **View transitions** bullet 2: Baseline status details go stale. -- [ ] cut · **Where state lives**: generic advice (replaced by Context performance). -- [ ] cut · **Controlled vs uncontrolled inputs**: basic React (low confidence). +- [x] cut · **CSS layout and specificity** bullet 1: flexbox vs grid basics. *Renamed *Specificity and the cascade*.* +- [x] cut · **Modern CSS features**: feature listing and Baseline status. Keep container queries and `:has()`. *The nesting and `subgrid` clause went too.* +- [x] cut · **View transitions** bullet 2: Baseline status details go stale. *Kept the multi-page opt-in, dropped the Baseline status.* +- [x] cut · **Where state lives**: generic advice (replaced by Context performance). *Replaced by Context performance (P2 item ticked).* +- [x] cut · **Controlled vs uncontrolled inputs**: basic React (low confidence). ### Security @@ -462,9 +462,9 @@ Strong. Missing a few browser-policy nuances, randomness, account recovery, and **Trim** -- [ ] cut · **Encoding vs encryption vs hashing**: definition-level table. -- [ ] merge · **Clickjacking** into **Content Security Policy** (`frame-ancestors`) (low confidence). -- [ ] cut · **OWASP Top 10:2025**: keep only if you expect "name the list" questions (low confidence). +- [x] cut · **Encoding vs encryption vs hashing**: definition-level table. +- [x] merge · **Clickjacking** into **Content Security Policy** (`frame-ancestors`) (low confidence). *Now a bullet in Content Security Policy.* +- [x] cut · **OWASP Top 10:2025**: keep only if you expect "name the list" questions (low confidence). *Cut; Threat modeling would have had one concept left, so it merged with Supply chain into *Secure development*.* ## Infrastructure @@ -490,10 +490,10 @@ Compact and accurate. Missing the load balancer choice, cross-account access, S3 **Trim** -- [ ] cut · **ECS service mechanics**: definitions (task definition, service). -- [ ] cut · **Lambda limits and concurrency** bullet 2: Managed Instances' 90-minute limit is new and niche (low confidence). -- [ ] cut · **Capacity and cost guardrails** bullet 2: Budgets vs Cost Explorer trivia. -- [ ] cut · **KMS and envelope encryption** bullet 1's re-explanation (owner: security). Keep `GenerateDataKey` and the 4 KB limit. +- [x] cut · **ECS service mechanics**: definitions (task definition, service). +- [x] cut · **Lambda limits and concurrency** bullet 2: Managed Instances' 90-minute limit is new and niche (low confidence). +- [x] cut · **Capacity and cost guardrails** bullet 2: Budgets vs Cost Explorer trivia. +- [x] cut · **KMS and envelope encryption** bullet 1's re-explanation (owner: security). Keep `GenerateDataKey` and the 4 KB limit. ### DevOps @@ -516,10 +516,10 @@ Good Kubernetes and Terraform coverage. Missing workload security, a key Terrafo **Trim** -- [ ] cut · **Container networking and storage**: Docker basics (`EXPOSE` vs `-p`, volumes vs bind mounts). -- [ ] cut · **Modules, workspaces, licensing** bullet 3: license history. Keep "OpenTofu is the open fork" (low confidence). -- [ ] cut · **Node components** bullet 3: kube-proxy modes by version (low confidence). -- [ ] cut · **Workload types**: definition-level for Kubernetes users. Keep "never run a bare Pod" (low confidence). +- [x] cut · **Container networking and storage**: Docker basics (`EXPOSE` vs `-p`, volumes vs bind mounts). +- [x] cut · **Modules, workspaces, licensing** bullet 3: license history. Keep "OpenTofu is the open fork" (low confidence). *Renamed *Modules, workspaces, OpenTofu*.* +- [x] cut · **Node components** bullet 3: kube-proxy modes by version (low confidence). +- [x] cut · **Workload types**: definition-level for Kubernetes users. Keep "never run a bare Pod" (low confidence). *The bare-Pod bullet moved to Control plane.* ## Domains @@ -544,9 +544,9 @@ Strong on inference, serving, RAG, and agents. Missing how models are trained (i **Trim** -- [ ] cut · **Browser automation as a fallback**: generic. Move "approve irreversible submits" into **Human approval gates**. -- [ ] cut · **Model routing and caching** bullet 3: "measure cost per completed task" is generic (low confidence). -- [ ] cut · **Stop conditions** bullet 2: generic (low confidence). +- [x] cut · **Browser automation as a fallback**: generic. Move "approve irreversible submits" into **Human approval gates**. *Moved into Human approval gates.* +- [x] cut · **Model routing and caching** bullet 3: "measure cost per completed task" is generic (low confidence). +- [x] cut · **Stop conditions** bullet 2: generic (low confidence). ### Ethereum @@ -570,5 +570,5 @@ Good protocol coverage. Missing precompiles, node and RPC practicalities, ZK pro **Trim** -- [ ] cut · **Bridge exploits**: historical hack list. Keep one lesson per incident, or fold it into Bridge designs (low confidence). -- [ ] cut · **Account model** bullet 1: definition-level for Ethereum roles (low confidence). +- [x] cut · **Bridge exploits**: historical hack list. Keep one lesson per incident, or fold it into Bridge designs (low confidence). *Kept as one lesson per incident.* +- [x] cut · **Account model** bullet 1: definition-level for Ethereum roles (low confidence). *Renamed *Account nonces*.* diff --git a/docs/topics/ai.md b/docs/topics/ai.md index 0f0ec01..2bec062 100644 --- a/docs/topics/ai.md +++ b/docs/topics/ai.md @@ -162,8 +162,8 @@ What experienced AI engineers forget before an interview, grouped by subtopic. F ### Stop conditions -- Cap steps, tokens, and cost per run; require evidence (tests pass, a record exists) before declaring success; escalate on repeated failure. -- Open-ended self-critique loops often repeat the same mistake and burn budget. +- Cap steps, tokens, and cost per run; escalate to a human on repeated failure. +- Require evidence (tests pass, a record exists) before declaring success. ### Context management @@ -182,11 +182,6 @@ What experienced AI engineers forget before an interview, grouped by subtopic. F - **MCP** standardizes how apps discover and call tools, read resources, and fetch prompts — JSON-RPC 2.0 over stdio (local) or **Streamable HTTP** (remote, replaced HTTP+SSE in 2025). - Authorization is optional; HTTP servers that support it use **OAuth 2.1**. MCP doesn't replace per-action authorization or business validation. -### Browser automation as a fallback - -- Use it only without an API — layouts change and clicks have ambiguous effects. -- Isolate its credentials and require **approval** before irreversible submits. - ## Evaluation ### Eval sets and metrics @@ -215,7 +210,6 @@ What experienced AI engineers forget before an interview, grouped by subtopic. F - **Route** easy requests to a small, fast model and hard ones to a strong model. - **Semantic caching** reuses answers to similar queries; its key must include user permissions, source version, and freshness, or it leaks. -- Measure cost **per completed task**, not per call. ### Batch and streaming @@ -236,5 +230,5 @@ What experienced AI engineers forget before an interview, grouped by subtopic. F ### Human approval gates -- Require approval before high-impact actions (money, legal, external sends); show the action, evidence, and affected records. +- Require approval before high-impact actions (money, legal, external sends, irreversible form submits by a browser agent); show the action, evidence, and affected records. - An approval covers **one specific action**; re-check that data hasn't changed since the proposal, and record who approved what and when. diff --git a/docs/topics/algorithms.md b/docs/topics/algorithms.md index ad53ac0..519a118 100644 --- a/docs/topics/algorithms.md +++ b/docs/topics/algorithms.md @@ -6,7 +6,7 @@ What experienced engineers forget before an algorithms interview, grouped by sub ### Time and space bounds -- State the **input size**, then worst-case time and **auxiliary space**; producing an output of size `k` already costs Ω(k). +- Producing an output of size `k` already costs **Ω(k)**, whatever the algorithm. - Nested loops aren't automatically O(n²): if two pointers each advance at most `n` times, total work is O(n). - Recursion stack counts as space: balanced divide-and-conquer uses O(log n) frames, a linear chain O(n). @@ -30,8 +30,8 @@ At ~10⁸ simple operations per second, the constraints tell you which complexit ### Recurrence patterns -- **Binary search**: `T(n) = T(n/2) + O(1) = O(log n)`. -- **Merge sort**: `T(n) = 2T(n/2) + O(n) = O(n log n)`. +- **Master theorem** for `T(n) = aT(n/b) + f(n)`: compare `f(n)` with `n^(log_b a)` — smaller → Θ(n^(log_b a)); equal → Θ(n^(log_b a) · log n); larger → Θ(f(n)). +- Merge sort (a = b = 2, f = n) is the equal case → O(n log n); binary search (a = 1, b = 2, f = 1) → O(log n). - Recursion without memoization can revisit states exponentially often; after memoizing, cost = **states × work per state**. ## Arrays and sequences @@ -149,8 +149,8 @@ Standard array implementations; variants differ in stability and space. ### LRU cache -- **Hash map + doubly linked list**: the map finds a node in O(1), the list keeps recency — move to front on access, evict from the tail. -- Python: `OrderedDict.move_to_end` + `popitem(last=False)`; Java: `LinkedHashMap` in access order. +- **Hash map + doubly linked list**: the map finds a node in O(1), the list keeps recency. +- Move a node to the front on every access and evict from the tail — both O(1). ### Fenwick and segment trees diff --git a/docs/topics/aws.md b/docs/topics/aws.md index 1857b47..c95b9a4 100644 --- a/docs/topics/aws.md +++ b/docs/topics/aws.md @@ -24,7 +24,7 @@ What experienced AWS developers and DevOps engineers forget before an interview, ### KMS and envelope encryption -- **Envelope encryption**: `GenerateDataKey` returns a plaintext data key (encrypt locally, then discard) and the same key encrypted under the KMS key (store it with the data). KMS `Encrypt` itself only takes **4 KB**. +- `GenerateDataKey` returns a data key in plaintext (use it, then discard it) and wrapped under the KMS key (store it with the data) — the envelope pattern in [security.md](security.md); KMS `Encrypt` itself takes at most **4 KB**. - Every KMS key has a **key policy**; IAM policies grant access only if the key policy delegates to the account. ## Networking @@ -79,7 +79,6 @@ Gateway Load Balancer inserts inline appliances such as third-party firewalls. ### Lambda limits and concurrency - Maximum timeout **15 minutes**; synchronous payloads 6 MB each way (streamed responses allow more). -- Lambda Managed Instances allow up to **90 minutes** for async and event-source invocations (Sept 2026); synchronous calls stay at 15. - **Reserved concurrency** guarantees capacity and caps a function; provisioned concurrency pre-initializes environments to reduce startup latency and incurs separate charges. ### Lambda cold starts and scaling @@ -94,11 +93,6 @@ Gateway Load Balancer inserts inline appliances such as third-party firewalls. - **HTTP API**: cheaper, JWT/Lambda/IAM authorizers and throttling, but no usage plans or request validation; integration timeout max **30 s**. - ALB in front of Lambda or containers can authenticate via OIDC/Cognito but has no throttling, usage plans, or validation; LCU pricing is usually cheaper at sustained high volume. -### ECS service mechanics - -- A **task definition** specifies containers and resources; a **service** keeps the desired number of tasks running and replaces failed ones. -- Services register tasks with a load balancer target group and roll out new task definitions with rolling or blue/green deployments. - ## Storage and databases ### S3 consistency and versions @@ -173,7 +167,6 @@ Gateway Load Balancer inserts inline appliances such as third-party firewalls. ### Capacity and cost guardrails - Service **quotas** are per account and Region and often stop scaling before the application does — many are soft and raised by request. -- AWS Budgets alerts follow billing-data updates, at least daily; use CloudWatch service metrics for operational alarms. Cost Explorer is for spend analysis. - EC2 **Spot** capacity can be reclaimed; stop/terminate interruption notices give about **2 minutes** on a best-effort basis (hibernation starts immediately). Checkpoint work and replace capacity proactively. ### Cost drivers diff --git a/docs/topics/backend.md b/docs/topics/backend.md index 35745af..4ccf095 100644 --- a/docs/topics/backend.md +++ b/docs/topics/backend.md @@ -4,11 +4,6 @@ What experienced backend engineers forget before an interview, grouped by subtop ## API design -### Resource modeling - -- Resources are nouns and HTTP methods are verbs: `POST /orders/42/items`, not `/addItemToOrder`. -- Non-CRUD actions become sub-resources or state changes: `POST /orders/42/cancellation`. - ### Status codes people confuse | Codes | Meaning | @@ -103,11 +98,6 @@ What experienced backend engineers forget before an interview, grouped by subtop ## Async work -### Queue vs direct call - -- Direct call when the caller needs the result now and the dependency is fast and available. -- Queue when work is slow, the downstream is flaky or rate-limited (**load leveling**), or several consumers need the event. - ### Long-running operations - Return **202 Accepted** with a `Location` to a status resource (`/operations/123`); the client polls it or gets a webhook when done. @@ -155,10 +145,10 @@ What experienced backend engineers forget before an interview, grouped by subtop ### File uploads -- Large files go straight to object storage with a **presigned URL**, bypassing app servers; the app stores only metadata. +- Clients upload straight to object storage with a presigned URL, bypassing app servers ([system.md](system.md)). - **Multipart/resumable uploads** retry individual parts instead of the whole file. -## Lifecycle and config +## Service lifecycle ### Graceful shutdown @@ -170,11 +160,6 @@ What experienced backend engineers forget before an interview, grouped by subtop - Separate endpoints: **liveness** checks only that the process can make progress; **readiness** checks what serving needs (warm-up done, required dependencies) and fails while draining. - Keep them cheap and on an internal port; probe configuration and pitfalls: see [devops.md](devops.md). -### Configuration and secrets - -- Config that varies by environment comes from the **environment**, so one immutable artifact promotes from staging to production. -- Secrets come from a secret manager at runtime, never from the repo; **validate config at startup** and fail fast. - ## Backend security ### Mass assignment diff --git a/docs/topics/database.md b/docs/topics/database.md index 73a8aac..ec27266 100644 --- a/docs/topics/database.md +++ b/docs/topics/database.md @@ -60,10 +60,11 @@ What experienced database engineers forget before an interview, grouped by subto - **Default: Read Committed**; Repeatable Read is **snapshot isolation** — no phantoms, and a concurrent update of the same row aborts (no lost update), but write skew is possible. - Serializable is **SSI**: it prevents write skew by aborting with a serialization error, so the app must retry. -### MySQL InnoDB isolation +### InnoDB isolation and MVCC - **Default: Repeatable Read** with **next-key locks** (record + gap) on locking reads, blocking many phantoms. - Plain `SELECT` reads the snapshot, but `UPDATE` sees the latest committed row — lost updates slip through without `SELECT ... FOR UPDATE`. +- Updates happen in place; older versions are rebuilt from the **undo log**, and a long transaction makes undo history grow. ## MVCC and locking @@ -74,10 +75,6 @@ What experienced database engineers forget before an interview, grouped by subto - **XID wraparound** (32-bit transaction IDs) forces aggressive anti-wraparound vacuuming. - HOT updates skip index maintenance when no indexed column changed and the page has room. -### InnoDB MVCC - -- Updates happen in place; older versions are rebuilt from the **undo log**, and a long transaction makes undo history grow. - ### Row locks, queue tables, advisory locks - `SELECT ... FOR UPDATE` locks the rows it returns; **`SKIP LOCKED`** lets workers claim different rows of a queue table without blocking. @@ -135,6 +132,7 @@ What experienced database engineers forget before an interview, grouped by subto - A function or implicit cast on the column, and `OR` across columns without an index on each, also defeat it. - **Stale statistics** show up in `EXPLAIN ANALYZE` as estimated vs actual rows far apart — run `ANALYZE`; also watch for sorts or hashes spilling to disk. - Scan types: Seq Scan, Index Scan, Index Only Scan, and **Bitmap Heap Scan** (collects matches from one or more indexes, then reads pages in physical order). +- `OFFSET` still reads and discards every skipped row, so deep pages get slower; keyset pagination seeks by index — API side in [backend.md](backend.md). ### Join algorithms @@ -144,10 +142,6 @@ What experienced database engineers forget before an interview, grouped by subto | **Hash join** | large equality joins without a useful index; builds on the smaller side | | **Merge join** | both inputs already sorted (e.g. from indexes) | -### Deep pagination cost - -- **OFFSET** still reads and discards every skipped row, so deep pages get slower; **keyset** pagination seeks by index — API side in [backend.md](backend.md). - ## SQL gotchas ### NULL and three-valued logic @@ -185,11 +179,10 @@ What experienced database engineers forget before an interview, grouped by subto - Structures: strings, hashes, lists, sets, **sorted sets** (skip list + hash — leaderboards, rate limiters), streams, HyperLogLog. - Redis Cluster splits keys into **16,384 hash slots**; multi-key operations need the same slot, forced with hash tags (`{user42}:cart`). -### Redis persistence and licensing +### Redis persistence and replication - RDB: periodic fork + snapshot (copy-on-write), loses writes since the last one. AOF: logs every write; `appendfsync everysec` (default) loses up to **~1 s**. - Replication is **asynchronous** — failover can drop acknowledged writes. -- The 2024 license change led to the **Valkey** fork (Linux Foundation); Redis 8 (2025) added AGPLv3 as an option. ### Redis eviction, expiry, and messaging @@ -256,9 +249,5 @@ What experienced database engineers forget before an interview, grouped by subto ### OLTP vs OLAP -- **OLTP**: row storage, many small transactional reads and writes. - **OLAP**: **column storage**, compression, vectorized scans of few columns over many rows, star schemas (facts + dimensions). - -### Materialized views - -- Store a query result for fast reads that are stale until refresh; `REFRESH MATERIALIZED VIEW CONCURRENTLY` avoids blocking reads but needs a unique index. +- Materialized views store a query result for fast reads that stay stale until refresh; `REFRESH MATERIALIZED VIEW CONCURRENTLY` avoids blocking reads but needs a unique index. diff --git a/docs/topics/devops.md b/docs/topics/devops.md index 4e4cfa4..a75e3f0 100644 --- a/docs/topics/devops.md +++ b/docs/topics/devops.md @@ -55,23 +55,18 @@ What experienced DevOps engineers forget before an interview, grouped by subtopi - PID 1 gets no default signal handlers, so an app not written for it may ignore **`SIGTERM`** and be killed after the grace period. - Use the **exec form** (`CMD ["app"]`, not `CMD app`, which wraps it in a shell) and a tiny init (`tini`, `--init`) to forward signals and reap zombies. -### Container networking and storage - -- On a user-defined bridge network, containers resolve each other by name; `EXPOSE` only documents a port, `-p` publishes it. -- **Volumes** are Docker-managed and survive the container; **bind mounts** map a host path; the writable layer dies with the container. - ## Kubernetes architecture ### Control plane - The **API server** is the only component talking to **etcd**; the scheduler assigns Pods to nodes; **controllers** reconcile actual state toward desired state. - Everything is declarative and level-triggered: `kubectl apply` succeeding means the object was stored, not that the app is healthy. +- A bare Pod has no controller, so nothing recreates it after a node failure — run workloads through a Deployment, StatefulSet, DaemonSet, or Job. ### Node components - **kubelet** runs the node's Pods through the container runtime (CRI) and reports status. - **kube-proxy** or an **eBPF** CNI such as Cilium implements Service virtual IPs. -- kube-proxy modes: iptables (default), nftables (GA in 1.33), IPVS (deprecated since 1.35). ### Packaging and extension @@ -80,12 +75,6 @@ What experienced DevOps engineers forget before an interview, grouped by subtopi ## Kubernetes workloads -### Workload types - -- **Deployment**: interchangeable stateless Pods via ReplicaSets. **StatefulSet**: stable names (`db-0`), ordered rollout, a volume per Pod. -- **DaemonSet**: one Pod per node (log agents, CNI). Job/CronJob: run to completion, once or on a schedule. -- Never run a bare Pod for anything that should come back after failure. - ### Rolling update tuning - **`maxSurge`** (extra Pods above desired) and **`maxUnavailable`** (Pods allowed down) — both default **25%**. @@ -208,11 +197,11 @@ What experienced DevOps engineers forget before an interview, grouped by subtopi - **`import`** blocks (1.5) adopt existing resources into state. - **`removed`** blocks (1.7) drop a resource from config; the default destroys it — only `lifecycle { destroy = false }` keeps the real object. -### Modules, workspaces, licensing +### Modules, workspaces, OpenTofu - Modules package resources behind inputs and outputs. - Workspaces give one configuration several states but are **not an access boundary** — isolate environments with separate backends or root modules. -- Terraform moved to the **BSL license in 2023**; **OpenTofu** is the open-source fork with the same workflow. +- **OpenTofu** is the open-source fork of Terraform with the same workflow. ## CI/CD and GitOps diff --git a/docs/topics/distributed.md b/docs/topics/distributed.md index afbd118..7051b63 100644 --- a/docs/topics/distributed.md +++ b/docs/topics/distributed.md @@ -195,14 +195,11 @@ Key distributed-systems building blocks and trade-offs, grouped by subtopic. ## Stream processing -### Event time and watermarks +### Event time, watermarks, and windows - **Event time** (when it happened) vs **processing time** (when it arrived) — late events break processing-time windows. - A **watermark** says "no events older than T are expected", letting a window close; later stragglers go to a side output or update results. - -### Window types - -- **Tumbling** (fixed, non-overlapping), **sliding/hopping** (fixed, overlapping), **session** (closed by an inactivity gap). +- Windows: tumbling (fixed, non-overlapping), sliding or hopping (fixed, overlapping), session (closed by an inactivity gap). ### Change data capture diff --git a/docs/topics/ethereum.md b/docs/topics/ethereum.md index 1566b30..dda14ca 100644 --- a/docs/topics/ethereum.md +++ b/docs/topics/ethereum.md @@ -4,9 +4,8 @@ What experienced Ethereum engineers forget before an interview, grouped by subto ## Accounts and transactions -### Account model +### Account nonces -- **EOA** (controlled by a secp256k1 key) vs **contract account** (controlled by its code); only EOAs originate transactions. - The **nonce** orders an EOA's transactions and prevents replay; an EIP-7702 authorization also increments it, even in someone else's transaction. - A stuck transaction blocks every later nonce until replaced by one with the same nonce and a higher fee. @@ -189,5 +188,6 @@ Built-in contracts at fixed low addresses for cryptography too expensive in byte ### Bridge exploits -- Bridges hold large locked pools, making them prime targets. -- **Ronin** (5 of 9 validator keys compromised), **Wormhole** (signature verification bypass), **Nomad** (bad initialization let anyone forge messages). +- A bridge is only as secure as whoever attests to cross-chain messages, and its locked pool makes it a prime target. +- **Ronin** (2022): 5 of 9 validator keys compromised — a small validator set is just a multisig. +- **Wormhole** (2022): a signature-verification bypass minted unbacked tokens; **Nomad** (2022): an upgrade marked the zero root as trusted, so any message passed and copycats drained it. diff --git a/docs/topics/frontend.md b/docs/topics/frontend.md index 22bfa94..b0c5115 100644 --- a/docs/topics/frontend.md +++ b/docs/topics/frontend.md @@ -53,9 +53,8 @@ What experienced frontend engineers forget before an interview, grouped by subto ## CSS -### CSS layout and specificity +### Specificity and the cascade -- **Flexbox** for one axis (a toolbar, centering); **Grid** for two axes (page layout, card grids). - **Specificity**: inline > ID > class/attribute/pseudo-class > element; cascade layers and origin rank above specificity, and `!important` inverts layer order. ### Stacking contexts @@ -66,13 +65,12 @@ What experienced frontend engineers forget before an interview, grouped by subto ### Modern CSS features - **Container queries** (`@container`) style a component by its container's size, not the viewport — reusable responsive components. -- **`:has()`** selects a parent by its children (`form:has(:invalid)`); native **nesting** and `subgrid` remove common preprocessor and wrapper hacks. -- All Baseline since 2023. +- **`:has()`** selects a parent by its children (`form:has(:invalid)`), which used to need JavaScript. ### View transitions - **View Transitions API** animates between two DOM states: `document.startViewTransition(update)` snapshots old and new, then cross-fades or morphs elements sharing a `view-transition-name`. -- Same-document transitions are Baseline since Firefox 144 (October 2025); multi-page apps opt in with `@view-transition { navigation: auto }`. +- Multi-page apps opt in to cross-document transitions with `@view-transition { navigation: auto }`. ## Performance @@ -209,17 +207,13 @@ Any XSS can read all of them except `HttpOnly` cookies — token storage in [sec - `React.memo` is defeated by a **new object, array, or function** literal passed as a prop on every render. - Memoize only when the skipped work costs more than the comparison. -### Controlled vs uncontrolled inputs - -- **Controlled** (`value` + `onChange`): React owns the value — needed when it drives other UI. -- **Uncontrolled** (read via ref): less code, fewer re-renders; a file input is always uncontrolled. - ## State management -### Where state lives +### Context performance -- Local state → lift to the nearest common parent → context → a **dedicated store** only when many unrelated components share it. -- Reach for context or a store when prop drilling actually hurts, not for a two-level pass. +- Every consumer re-renders when the provider's `value` changes **identity** — an inline object literal changes it on every render. +- Memoize the value, split fast- and slow-changing state into separate contexts, or use a store with selectors (`useSyncExternalStore`, Zustand) so components subscribe to slices. +- Context suits low-frequency values (theme, locale, current user), not fast-changing shared state. ### Server state vs client state diff --git a/docs/topics/golang.md b/docs/topics/golang.md index fea1c0f..474b555 100644 --- a/docs/topics/golang.md +++ b/docs/topics/golang.md @@ -88,12 +88,6 @@ Only the sender should close a channel; `for range ch` ends once it's closed and - Fields are aligned to their type's alignment, so on 64-bit `struct{ a bool; b int64; c bool }` takes **24 bytes** while `{b int64; a, c bool}` takes **16** — order fields largest first in hot, numerous structs. - An empty struct (`struct{}`) is **zero bytes** — used for sets (`map[K]struct{}`) and signal channels. -### Cleanups, weak pointers, interning - -- **`runtime.AddCleanup`** (1.24) replaces `SetFinalizer`: several cleanups per object, no resurrection, and no leak when objects form a cycle. -- **`weak.Pointer`** (1.24) references an object without keeping it alive — for caches and canonicalization maps. -- **`unique.Make`** (1.23) interns comparable values, turning equality into a pointer compare. - ## Slices, maps, strings ### Slice mechanics @@ -142,12 +136,6 @@ Only the sender should close a channel; `for range ch` ends once it's closed and - **Range-over-func** iterators (`iter.Seq`, `iter.Seq2`, **1.23**) let `range` work over a function, powering the `slices`/`maps` iterator helpers. - **Since Go 1.22**, each iteration gets its own copy of variables declared by the loop (`:=`) — the classic closure-capture bug needs `go 1.21` semantics or a reused outer variable (`for i = 0; ...`). -### Newer language features - -- 1.21: `min` and `max` built-ins. 1.22: **`for i := range 10`** over integers. -- 1.24: generic type aliases. -- 1.26: **`new(expr)`** allocates and initializes in one step (`new(42)` → `*int`). - ## Errors, defer, panic ### Error wrapping @@ -168,6 +156,7 @@ Only the sender should close a channel; `for range ch` ends once it's closed and - The default **`http.Client` has no timeout** — a hung server blocks the goroutine forever; always set `Timeout` or use a context. - Always **close `resp.Body`** (and drain it) or the connection isn't reused and leaks. - `http.Server` needs `ReadHeaderTimeout`/`ReadTimeout`/`WriteTimeout`, or slow clients (Slowloris) hold connections open. +- **`ServeMux` patterns since 1.22** take methods and wildcards: `mux.HandleFunc("GET /items/{id}", h)` with `r.PathValue("id")`. ### encoding/json gotchas @@ -176,12 +165,6 @@ Only the sender should close a channel; `for range ch` ends once it's closed and - Unexported fields are silently skipped; unknown JSON fields are ignored unless `DisallowUnknownFields`; field-name matching is case-insensitive. - `omitempty` never omits a struct value (a zero `time.Time` included); **`omitzero`** (1.24) does. -### Routing, JSON, logging - -- **`ServeMux` patterns since 1.22**: methods and wildcards, `mux.HandleFunc("GET /items/{id}", h)` with `r.PathValue("id")`. -- **`encoding/json/v2`**: experimental in 1.25 (`GOEXPERIMENT=jsonv2`), standard in 1.27 — faster, and stricter defaults (e.g. case-sensitive field matching). -- **`log/slog`** (1.21) is the standard structured logger. - ## Modules and tooling ### Minimal version selection @@ -195,12 +178,6 @@ Only the sender should close a channel; `for range ch` ends once it's closed and - **`internal/`** packages are importable only from within the parent tree. - **`go.work`** (**1.18**) builds several local modules together without `replace` directives. -### Toolchains and tools - -- The `toolchain` line and **`GOTOOLCHAIN`** (1.21) let `go` download the toolchain a module requires. -- **`tool` directives** in `go.mod` (**1.24**) track dev tools, run with `go tool ` — replaces the `tools.go` hack. -- `go fix` (1.26) applies "modernizer" rewrites that adopt new idioms across a codebase. - ### Compatibility and GODEBUG - Potentially breaking changes ship behind **`GODEBUG`** settings whose defaults follow the main module's **`go` line**, so a toolchain upgrade alone keeps their old behavior (other runtime and performance changes still apply). @@ -210,7 +187,6 @@ Only the sender should close a channel; `for range ch` ends once it's closed and ### Test tooling -- Table-driven tests with `t.Run` subtests, `t.Parallel()`, `t.Cleanup()`. - Benchmarks use `b.Loop()` (**1.24**), which replaced the manual `for i := 0; i < b.N; i++` idiom and avoids some compiler over-optimization pitfalls. - Fuzzing (`func FuzzX`, **1.18**) generates inputs from a seed corpus. diff --git a/docs/topics/javascript.md b/docs/topics/javascript.md index f2ae6c4..d762b05 100644 --- a/docs/topics/javascript.md +++ b/docs/topics/javascript.md @@ -102,11 +102,6 @@ What experienced JavaScript engineers forget before an interview, grouped by sub - There is no default timeout: pass `signal: AbortSignal.timeout(ms)`. - Cookies go only to the same origin by default (`credentials: 'same-origin'`); cross-origin requests need `'include'` plus CORS credential headers. -### Promise helpers - -- **`Promise.withResolvers()`** (ES2024) returns `{ promise, resolve, reject }`. -- **`Promise.try()`** (ES2025) runs a function and turns both its result and a synchronous throw into a promise. - ## Modules ### CommonJS vs ESM @@ -155,6 +150,7 @@ What experienced JavaScript engineers forget before an interview, grouped by sub - An object is iterable if it has **`[Symbol.iterator]()`** returning `{ next() → { value, done } }`; `for...of`, spread, and destructuring use it. - Generators (`function*`) are lazy, pause at `yield`, and can receive values via `next(v)`; async generators power `for await`. +- **Iterator helpers** (`.map`, `.filter`, `.take`, `.drop` on iterators, ES2025) are lazy, unlike the array methods. ## Node.js runtime @@ -175,11 +171,10 @@ What experienced JavaScript engineers forget before an interview, grouped by sub - **`write()` returns `false`** once the buffer passes `highWaterMark`; stop writing until the `'drain'` event. - **`stream.pipeline()`** handles backpressure, errors, and cleanup of every stream in the chain — `.pipe()` doesn't forward errors. -### Workers, cluster, child processes +### Worker threads and cluster - **`worker_threads`**: threads in one process with separate V8 isolates, for CPU-bound JS; share memory through `SharedArrayBuffer`. - **`cluster`**: forks processes sharing one server port to use all cores — in containers, usually replaced by more replicas. -- `child_process`: runs other programs (`spawn` streams output, `exec` buffers it). ### AsyncLocalStorage @@ -200,22 +195,12 @@ What experienced JavaScript engineers forget before an interview, grouped by sub ## Recent language additions -### Array and object helpers - -- **`toSorted`, `toReversed`, `toSpliced`, `with`** (ES2023) return a new array instead of mutating. -- **`Object.groupBy`/`Map.groupBy`** (ES2024) group an iterable by a callback's key. - ### Temporal -- **`Temporal`** (Stage 4 in March 2026, **ES2026**) replaces `Date`: immutable values, explicit time zones (`ZonedDateTime`), calendar-safe arithmetic, separate types for dates, times, and instants. -- Shipped in Firefox 139 and Chrome 144; Safari has it only in Technology Preview, so it isn't Baseline yet. +- **`Temporal`** (Stage 4 in March 2026, **ES2026**) replaces `Date` with immutable values and separate types for instants, dates, times, and zoned date-times. +- Time zones are explicit (`ZonedDateTime`) and arithmetic is calendar-safe, unlike `Date`'s mutable, local-time-by-default API. ### Explicit resource management - **`using`** / `await using` (ES2026; TypeScript since 5.2) call **`[Symbol.dispose]()`** / `[Symbol.asyncDispose]()` when the block exits, even on throw — no `try/finally`. - **`DisposableStack`** collects several resources and disposes them in reverse order. - -### Sets and iterators - -- **Set methods** (`union`, `intersection`, `difference`, `isSubsetOf`, …) arrived in **ES2025**. -- **Iterator helpers** (`.map`, `.filter`, `.take`, `.drop` on iterators, ES2025) are lazy, unlike the array methods. diff --git a/docs/topics/networking.md b/docs/topics/networking.md index 47ac204..80699bb 100644 --- a/docs/topics/networking.md +++ b/docs/topics/networking.md @@ -12,18 +12,14 @@ What experienced engineers forget about networking before an interview, grouped ### Connection failure signatures -| Symptom | Usual cause | -|---|---| -| Connection refused | RST: host reachable, nothing listening on the port | -| Connect timeout | SYN dropped: firewall, security group, or dead host; Linux retries the SYN for **~127 s**, so set connect timeouts | -| Connection reset by peer | peer crashed, or a middlebox dropped the flow after its idle timeout | -| **502** from a proxy | upstream refused, reset, or sent an invalid response | -| **504** from a proxy | upstream didn't answer in time | - -### Debugging tools - -- `dig` (DNS answer, TTL), `curl -v` and `curl -w '%{time_connect} %{time_appconnect} %{time_starttransfer}'` (per-phase timing). -- `ss -tanp` (sockets and states), `traceroute`/`mtr` (path, TTL expiry), `tcpdump`/Wireshark (packets). +| Symptom | Usual cause | Check with | +|---|---|---| +| Name doesn't resolve, or resolves to an old IP | NXDOMAIN, stale cache, TTL not expired | `dig` (answer, TTL) | +| Connection refused | RST: host reachable, nothing listening on the port | `ss -tlnp` on the server | +| Connect timeout | SYN dropped: firewall, security group, or dead host; Linux retries the SYN for **~127 s**, so set connect timeouts | `traceroute`/`mtr`, `tcpdump` for SYNs | +| Connection reset by peer | peer crashed, or a middlebox dropped the flow after its idle timeout | `tcpdump`/Wireshark around the RST | +| **502** from a proxy | upstream refused, reset, or sent an invalid response | proxy error log, `ss -tanp` states | +| **504** from a proxy, or just slow | upstream didn't answer in time | `curl -w '%{time_connect} %{time_appconnect} %{time_starttransfer}'` per phase | ## TCP @@ -69,17 +65,12 @@ What experienced engineers forget about networking before an interview, grouped - TCP delivers bytes in order, so one lost packet stalls everything behind it — even data for unrelated HTTP/2 streams. - HTTP/1.1 blocks at the request level, HTTP/2 fixes that but not TCP's, and **QUIC** fixes both: streams are delivered independently, so a lost packet stalls only the streams whose data it carried. -### UDP - -- No handshake, ordering, retransmission, or congestion control — the application decides. -- Used where latency beats reliability or the protocol handles it itself: DNS, VoIP, games, **QUIC**. - ## HTTP ### HTTP/1.1 - Persistent connections (keep-alive), but **one outstanding request per connection** in practice (pipelining is unused). -- Browsers open about **6 connections per host** to parallelize — the reason for old tricks like domain sharding and sprite sheets. +- Browsers open about **6 connections per host** to parallelize. ### HTTP/2 @@ -89,6 +80,7 @@ What experienced engineers forget about networking before an interview, grouped ### HTTP/3 and QUIC +- UDP has no handshake, ordering, or retransmission, so QUIC implements them in user space; DNS, VoIP, and games use UDP directly and handle loss themselves. - QUIC runs over UDP with TLS 1.3 built in: **1-RTT** setup (0-RTT on resumption) and independent stream delivery, so no cross-stream head-of-line blocking; loss detection and congestion control stay per connection. - **Connection migration**: a connection ID survives an IP change (Wi-Fi → cellular). - Clients discover it via the `Alt-Svc` header or a DNS HTTPS record; many networks block UDP, so browsers fall back to TCP. diff --git a/docs/topics/os.md b/docs/topics/os.md index 4ae08e7..47a8827 100644 --- a/docs/topics/os.md +++ b/docs/topics/os.md @@ -4,16 +4,12 @@ What experienced engineers forget about Linux and OS internals before an intervi ## Processes and threads -### Processes vs threads - -- A **process** has its own address space, file descriptors, and credentials; **threads** share the address space and descriptors of their process. -- On Linux both are **tasks** created by `clone()` with different sharing flags; the scheduler treats them alike. - ### fork, exec, copy-on-write - **`fork()`** duplicates the process lazily: pages are shared **copy-on-write** until one side writes. - **`exec()`** replaces the program image, keeping the PID and open descriptors (unless `O_CLOEXEC`). - Forking a multi-threaded process copies only the calling thread — locks held by others stay locked forever in the child. +- On Linux, processes and threads are both tasks created by `clone()` with different sharing flags; the scheduler treats them alike. ### Process states @@ -156,11 +152,6 @@ What experienced engineers forget about Linux and OS internals before an intervi - All four **Coffman conditions** must hold: mutual exclusion, hold and wait, no preemption, **circular wait**. - Break one — usually circular wait, with a global **lock ordering** — or use `trylock` with timeouts. -### Priority inversion - -- A low-priority task holds a lock needed by a high-priority task while a medium-priority task starves it (Mars Pathfinder, 1997). -- **Priority inheritance** temporarily boosts the lock holder. - ### Atomics, CAS, and the ABA problem - **Compare-and-swap** writes only if the value still equals the expected one; retry loops build lock-free stacks, counters, and mutex fast paths. @@ -177,7 +168,6 @@ What experienced engineers forget about Linux and OS internals before an intervi ### Linux observability tools -- `top`/`htop` (CPU per process), `vmstat 1` (run queue, swap, context switches), `iostat -x 1` (disk utilization, await), `pidstat` (per-process CPU and I/O). - **`perf`** samples stacks with low overhead → flame graphs; **eBPF** tools (`bpftrace`, bcc) trace kernel events in production safely. - **`strace`** shows every syscall but slows the process heavily (ptrace) — avoid on hot production paths. diff --git a/docs/topics/python.md b/docs/topics/python.md index 1da958d..f5cace2 100644 --- a/docs/topics/python.md +++ b/docs/topics/python.md @@ -16,17 +16,17 @@ What experienced Python engineers forget before an interview, grouped by subtopi - The **free-threaded build** (no GIL) was experimental in 3.13 and is **officially supported since 3.14** (PEP 779); an incompatible C extension can force the GIL back on. - **`concurrent.interpreters`** (3.14, PEP 734) runs several interpreters in one process, each with its own GIL, talking over cross-interpreter queues. -### Specializing interpreter and JIT +### Specializing interpreter -- **3.11** added the adaptive specializing interpreter, roughly **25%** faster on average: hot bytecodes are rewritten into type-specialized versions. -- 3.13 added an experimental copy-and-patch **JIT**; 3.14's official Windows and macOS builds include it, off by default (`PYTHON_JIT=1`). +- **3.11** added the adaptive specializing interpreter, roughly **25%** faster on average. +- Hot bytecodes are rewritten in place into type-specialized versions, which fall back when the observed types change. ## Memory management ### Refcounting and the cyclic GC -- **Reference counting** frees an object the instant its count hits zero; a **generational cyclic GC** periodically frees reference cycles counting can't. -- 3.14.0–3.14.4 shipped an incremental GC; **3.14.5 reverted it** over production memory growth. +- **Reference counting** frees an object the instant its count hits zero. +- A **generational cyclic GC** periodically finds and frees reference cycles, which counting alone can't. ### Object identity and caching @@ -89,14 +89,11 @@ What experienced Python engineers forget before an interview, grouped by subtopi ## Gotchas -### Mutable default arguments +### Default arguments and late binding - Defaults are evaluated **once, at definition time** — `def f(x, cache=[])` shares one list across calls; default to `None` and create the object inside. - Dataclasses reject unhashable defaults (`list`, `dict`, `set`) — use **`field(default_factory=list)`**. - -### Late-binding closures - -- A closure captures the *variable*, not its value — `[lambda: i for i in range(3)]` all return `2`; bind early with `lambda i=i: i`. +- A closure captures the *variable*, not its value — `[lambda: i for i in range(3)]` all return `2`; a default binds early: `lambda i=i: i`. ### Scope and `UnboundLocalError` @@ -122,8 +119,8 @@ What experienced Python engineers forget before an interview, grouped by subtopi ### Mutation during iteration -- Removing items from a list inside `for` skips elements; resizing a dict raises `RuntimeError: dictionary changed size during iteration` — iterate over a copy. -- Dict insertion order is guaranteed **since 3.7**. +- Removing items from a list inside `for` skips elements. +- Resizing a dict while iterating raises `RuntimeError: dictionary changed size during iteration` — iterate over a copy. ### Import mechanics @@ -181,19 +178,7 @@ What experienced Python engineers forget before an interview, grouped by subtopi - **`__exit__` returning `True` suppresses** the exception; `contextlib.contextmanager` turns a one-`yield` generator into a context manager. - `try ... else` runs only when no exception was raised; **`except*`** (**3.11**) handles exception groups, e.g. from a `TaskGroup`. -## Recent language features - -### Structural pattern matching - -- `match` (**3.10**) destructures by shape: `case {"type": "click", "x": x}`, `case Point(x=0)`. -- A bare name in a `case` **binds**, it doesn't compare — `case RED:` matches everything; use dotted names (`Color.RED`) for constants. - -### Template strings - -- **t-strings** (`t"Hello {name}"`, **3.14**, PEP 750) produce a `Template` object with static parts and interpolated values kept separate. -- A library receiving it can escape values safely (SQL, HTML), unlike an f-string that arrives already joined. - -## Typing +## Typing and recent features ### Gradual typing and protocols @@ -206,6 +191,16 @@ What experienced Python engineers forget before an interview, grouped by subtopi - **PEP 695** syntax (`class Box[T]: ...`, `type Alias = ...`, 3.12) replaces manual `TypeVar` declarations with scoped type parameters. - Annotations are **evaluated lazily since 3.14** (**PEP 649**), making `from __future__ import annotations` largely unnecessary. +### Structural pattern matching + +- `match` (**3.10**) destructures by shape: `case {"type": "click", "x": x}`, `case Point(x=0)`. +- A bare name in a `case` **binds**, it doesn't compare — `case RED:` matches everything; use dotted names (`Color.RED`) for constants. + +### Template strings + +- **t-strings** (`t"Hello {name}"`, **3.14**, PEP 750) produce a `Template` object with static parts and interpolated values kept separate. +- A library receiving it can escape values safely (SQL, HTML), unlike an f-string that arrives already joined. + ## Tooling ### Packaging and tests diff --git a/docs/topics/rust.md b/docs/topics/rust.md index e644f28..dbf7bcd 100644 --- a/docs/topics/rust.md +++ b/docs/topics/rust.md @@ -87,16 +87,17 @@ What experienced Rust engineers forget before an interview, grouped by subtopic. - Every `Fn` is also `FnMut` and `FnOnce`; take the **loosest** bound your code allows (`FnOnce` if you call it once), so callers can pass more kinds of closures. - **`move`** changes *how* variables are captured (by value), not which trait is implemented — a `move` closure that only reads is still `Fn`. +- Async closures (`async || { ... }`, 1.85) can borrow from their captures across `.await`, which `|| async { ... }` couldn't; bound them with **`AsyncFn`/`AsyncFnMut`/`AsyncFnOnce`**. ### Iterators -- Iterator adapters (`map`, `filter`, …) are **lazy** and compile to the same code as a hand-written loop — a **zero-cost abstraction**; nothing runs until a consumer (`collect`, `sum`, `for`). -- `iter()` yields `&T`, `iter_mut()` `&mut T`, `into_iter()` `T` (consumes the collection). +- Iterator adapters (`map`, `filter`, …) are **lazy**: nothing runs until a consumer (`collect`, `sum`, `for`). +- They compile to the same code as a hand-written loop — a **zero-cost abstraction**. ### String vs &str -- **`String`** is an owned, growable UTF-8 buffer; **`&str`** is a borrowed slice of UTF-8 bytes — accept `&str` in parameters. - No indexing by integer (`s[0]` doesn't compile) because characters are variable-width; slicing at a non-char boundary **panics**. +- `len()` counts bytes; `chars()` yields Unicode scalar values, which still aren't user-perceived characters. ## Smart pointers and memory @@ -190,10 +191,6 @@ What experienced Rust engineers forget before an interview, grouped by subtopic. - Dropping a Tokio `JoinHandle` **detaches** the spawned task instead — cancel with `abort()`. - **Cancel safety**: in `select!`, a losing branch is dropped mid-await — `read_line` into a buffer can lose data, `recv()` on a channel can't. -### Async closures - -- **Async closures** (`async || { ... }`, **1.85**) can borrow from their captures across `.await`, which `|| async { ... }` couldn't; bound them with **`AsyncFn`/`AsyncFnMut`/`AsyncFnOnce`**. - ## Unsafe and FFI ### What `unsafe` allows @@ -221,5 +218,5 @@ What experienced Rust engineers forget before an interview, grouped by subtopic. ### Lock files and editions - Commit **`Cargo.lock`** for binaries; since 2023, Cargo's guidance is to commit it for libraries too, as a CI baseline (dependents ignore it). -- Editions are opt-in, per-crate language changes; **edition 2024** is available since Rust 1.85. -- Edition 2024 enables **let chains** (`if let Some(x) = a && x > 0`, 1.88) and makes `impl Trait` in return position capture all in-scope lifetimes by default. +- Editions are opt-in, per-crate language changes; crates on different editions link together freely. +- **Edition 2024** enables **let chains** (`if let Some(x) = a && x > 0`, 1.88) and makes `impl Trait` in return position capture all in-scope lifetimes by default. diff --git a/docs/topics/security.md b/docs/topics/security.md index 93e9b22..3a879ad 100644 --- a/docs/topics/security.md +++ b/docs/topics/security.md @@ -54,6 +54,7 @@ What experienced engineers forget about application security before an interview - A **strict CSP** uses per-response nonces or hashes (`script-src 'nonce-…' 'strict-dynamic'`); host allowlists are routinely bypassed through JSONP endpoints and CDN-hosted gadgets. - **`'strict-dynamic'`** lets a trusted script load further scripts and makes supporting browsers ignore host allowlists. +- **`frame-ancestors`** blocks framing, which stops clickjacking (a hidden frame tricking the user into clicking the real site); `X-Frame-Options` is the legacy header. - Roll out with `Content-Security-Policy-Report-Only` first. ### CSRF @@ -61,11 +62,6 @@ What experienced engineers forget about application security before an interview - The browser auto-attaches cookies to a forged cross-site request. - Defend with framework **CSRF tokens** plus `SameSite=Lax`/`Strict` cookies (**Lax is Chrome's default**); XSS defeats CSRF defenses, so it's no substitute. -### Clickjacking - -- A hidden frame tricks the user into clicking the real site. -- Block framing with CSP **`frame-ancestors`** (or legacy `X-Frame-Options`). - ### CORS - CORS is a **browser read policy**, not authentication or a firewall — non-browser clients ignore it. @@ -171,14 +167,6 @@ What experienced engineers forget about application security before an interview ## Cryptography -### Encoding vs encryption vs hashing - -| | Reversible? | Needs a key? | Purpose | -|---|---|---|---| -| Encoding (Base64) | yes | no | representation | -| Encryption | yes, with the key | yes | confidentiality | -| Hashing | no | no | integrity, fingerprint | - ### Secure randomness - Tokens, session IDs, nonces, and reset codes need a **CSPRNG**: `crypto.getRandomValues`/`crypto.randomBytes`, Python `secrets`, Go `crypto/rand`. @@ -232,7 +220,7 @@ What experienced engineers forget about application security before an interview - **HSTS** forces HTTPS on later visits after one HTTPS response (preload lists cover the first visit). - **Certificate pinning** resists CA compromise but makes key rotation painful — mostly limited to mobile apps now. -## Supply chain +## Secure development ### Dependency attacks @@ -244,8 +232,6 @@ What experienced engineers forget about application security before an interview - An **SBOM** (SPDX, CycloneDX) lists what's inside an artifact, so a new CVE can be matched to affected builds. - **SLSA** levels grade build provenance; **Sigstore** (cosign) signs artifacts with short-lived keys tied to a CI identity. -## Threat modeling - ### STRIDE | STRIDE threat | Violates | @@ -258,9 +244,3 @@ What experienced engineers forget about application security before an interview | Elevation of privilege | Authorization | - STRIDE finds threats at each trust boundary; it doesn't rank them — pair it with impact/likelihood. - -### OWASP Top 10:2025 - -- Broken Access Control, Security Misconfiguration, **Software Supply Chain Failures** (new), Cryptographic Failures, Injection, Insecure Design. -- Authentication Failures, Software/Data Integrity Failures, Security Logging and Alerting Failures, **Mishandling of Exceptional Conditions** (new). -- An awareness list, not a test checklist — name the edition when citing it. diff --git a/docs/topics/solidity.md b/docs/topics/solidity.md index 575c0bb..97beab3 100644 --- a/docs/topics/solidity.md +++ b/docs/topics/solidity.md @@ -21,13 +21,12 @@ What experienced Solidity engineers forget before an interview, grouped by subto - `_` marks where the function body runs; a `return` in the body only leaves the body, so code after `_` still runs **after the return**. - Modifiers apply left to right; `_` may run several times, and if it never runs the body is skipped and return values stay at their defaults. - Legacy codegen **inlines** modifier code at every use — move the logic into an internal function to shrink bytecode; via-IR emits modifiers as functions. -- `virtual` modifiers are deprecated since 0.8.31, ahead of 0.9. ### Libraries and user-defined types - `internal` library functions are inlined into the caller (a `JUMP`); `public`/`external` ones run through **`DELEGATECALL`** into a separately deployed, linked library. -- Libraries have no state variables and can't receive ETH; `using L for T` attaches their functions to a type, and `global` (0.8.13, user-defined types only) applies it in every file. -- **User-defined value types** (`type Price is uint256;`, 0.8.8) are zero-cost wrappers that stop mixing units; `using {add as +} for Price global` binds operators (0.8.19). +- Libraries have no state variables and can't receive ETH; `using L for T` attaches their functions to a type, and `global` (user-defined types only) applies it in every file. +- **User-defined value types** (`type Price is uint256;`, 0.8.8) are zero-cost wrappers that stop mixing units; `using {add as +} for Price global` binds operators. ### Arithmetic and casts @@ -54,7 +53,6 @@ What experienced Solidity engineers forget before an interview, grouped by subto - **`transient`** state variables (0.8.28, value types only) compile to `TSTORE`/`TLOAD`: 100 gas, cleared at the end of the transaction — see [ethereum.md](ethereum.md). - They can't have initializers, and they **persist across calls within one transaction** — a lock or flag must be reset explicitly, or a later call in a batch sees it. -- **`layout at `** (0.8.29) moves a contract's storage to a custom base slot; `layout at erc7201("my.app")` (0.8.35) uses an ERC-7201 namespace's base slot. ### Mapping and delete gotchas @@ -133,7 +131,6 @@ What experienced Solidity engineers forget before an interview, grouped by subto - **`block.prevrandao`** (0.8.18, replaced `difficulty`) is known to the proposer, who can bias it by withholding a block — use **Chainlink VRF** or commit-reveal. - `blockhash(n)` returns 0 for blocks older than **256**; EIP-2935 (Pectra) serves 8,191 hashes from a system contract, but the opcode is unchanged. - Anything derived from block data can be computed by an attacker's contract in the same transaction, which reverts when the outcome is bad. -- On L1, `block.timestamp` advances in fixed 12 s slots; L2 sequencers set it within looser bounds. ## Integration risks @@ -147,7 +144,7 @@ What experienced Solidity engineers forget before an interview, grouped by subto ### Oracle integration -- A DEX **spot price** can be moved within one transaction using a flash loan — use a TWAP or Chainlink; see [ethereum.md](ethereum.md). +- Never price assets off a DEX spot price — manipulation and TWAPs in [ethereum.md](ethereum.md). - Chainlink `latestRoundData`: check **staleness** (`updatedAt` against the feed's heartbeat) and `answer > 0`; on L2s also check the **sequencer uptime feed**. - Feeds have their own decimals (USD pairs use 8, ETH pairs 18) — scale before combining with token amounts. @@ -171,13 +168,12 @@ What experienced Solidity engineers forget before an interview, grouped by subto - **Pack** small variables that are read and written together into one slot. - **`constant`/`immutable`** values are embedded in bytecode — no `SLOAD`. - Cache storage reads in local variables inside loops; use `calldata` parameters. -- Custom errors are cheaper than revert strings; 0.8.22 made simple loop-counter increments unchecked automatically. +- Custom errors are cheaper than revert strings; the compiler already skips overflow checks on simple loop-counter increments, so `unchecked { ++i; }` is no longer needed there. ### Code size limit - Deployed code is capped at **24,576 bytes** (EIP-170) and initcode at 49,152 (EIP-3860, Shanghai). - Workarounds: move logic into external libraries, split into several contracts, lower optimizer `runs`, or use the Diamond pattern. -- **EIP-7954**, scheduled for Glamsterdam, raises the limits to 64 KiB and 128 KiB. ### Clones and factories @@ -220,7 +216,7 @@ What experienced Solidity engineers forget before an interview, grouped by subto - `require(cond, "msg")` and `revert("msg")` encode **`Error(string)`** (selector `0x08c379a0`). - `assert`, overflow, division by zero, and out-of-bounds access raise **`Panic(uint256)`** with codes `0x01`, `0x11`, `0x12`, `0x32`. - Before 0.8, `assert` hit the `INVALID` opcode and burned all remaining gas; now it reverts like any other error. -- **Custom errors** (0.8.4) encode a selector plus arguments; `require(cond, MyError())` works since 0.8.26 with via-IR and 0.8.27 with legacy codegen. +- **Custom errors** (0.8.4) encode a selector plus arguments; `require(cond, MyError())` accepts them too. ### try/catch limits @@ -271,6 +267,6 @@ What experienced Solidity engineers forget before an interview, grouped by subto ### Assembly gotchas - No overflow or bounds checks, and values narrower than 256 bits may carry **dirty upper bits** — mask them. -- Mark blocks **`assembly ("memory-safe")`** (0.8.13) so via-IR can still move variables to memory; the `/// @solidity memory-safe-assembly` comment is deprecated since 0.8.31. +- Mark blocks **`assembly ("memory-safe")`** (0.8.13) so via-IR can still move variables to memory. - `return` and `revert` in assembly end the whole call, not just the current function. - Storage variables expose `.slot` and `.offset`; calldata arrays expose `.offset` and `.length`. diff --git a/docs/topics/system.md b/docs/topics/system.md index 14d4f27..99549c7 100644 --- a/docs/topics/system.md +++ b/docs/topics/system.md @@ -80,7 +80,6 @@ Key system design building blocks and trade-offs, grouped by subtopic. For CAP, ### SQL vs NoSQL -- **SQL**: relational schema, ACID transactions, joins — the default for data needing correctness (payments, orders). - NoSQL families by access pattern: key-value, document, **wide-column** (heavy writes, time series), graph; model tables around queries, not entities. - Pick NoSQL only for a named reason (write volume, schema flexibility, access pattern). Internals in [database.md](database.md). @@ -161,9 +160,8 @@ Key system design building blocks and trade-offs, grouped by subtopic. For CAP, ### Monolith vs microservices -- Monolith: simple to develop, deploy, and debug, with in-process calls and local transactions; struggles with many teams or very different scaling needs. -- Microservices: independent deploys and scaling, at the cost of network failures, distributed transactions, and operational overhead. -- Default to a **modular monolith**; extract services for a concrete reason. Boundaries mirror teams (**Conway's law**). +- Default to a **modular monolith**: in-process calls and local transactions, with module boundaries that could later become services. +- Extract a service for a concrete reason (independent scaling, deploy cadence, team ownership); boundaries mirror teams (**Conway's law**). ### Service discovery @@ -265,7 +263,6 @@ Key system design building blocks and trade-offs, grouped by subtopic. For CAP, ### Leaderboard - A Redis **sorted set**: `ZINCRBY` updates a score and `ZREVRANK` returns a user's rank in O(log n); `ZRANGE ... REV` reads the top k in O(log n + k). -- `ZRANGE ... REV` replaces `ZREVRANGE`, deprecated since Redis 6.2. - Beyond one node, shard by score range or keep per-shard top-k and merge. ### Booking and inventory contention diff --git a/docs/topics/typescript.md b/docs/topics/typescript.md index 45f614c..a1ff83f 100644 --- a/docs/topics/typescript.md +++ b/docs/topics/typescript.md @@ -4,10 +4,6 @@ What experienced TypeScript engineers forget before an interview, grouped by sub ## Type system semantics -### Structural typing - -- Compatibility is by **shape**, not declared name — an object satisfies an interface just by having the members; no `implements` needed. - ### Excess property checks - Only **fresh object literals** get excess-property errors: `const p: Point = { x: 1, y: 2, z: 3 }` fails. @@ -51,16 +47,13 @@ What experienced TypeScript engineers forget before an interview, grouped by sub - `typeof`, `instanceof`, `in`, equality, and truthiness checks narrow a variable inside the branch where they're provably true. - **Discriminated unions**: a shared literal tag (`kind`) lets `switch (x.kind)` narrow each case. +- **Exhaustiveness**: in the `default` branch, assign the value to a `never` variable; adding a new union member then fails to compile until handled. ### Custom type guards - A **type predicate** (`x is Fish`) or an **`asserts x is T`** function packages narrowing the compiler can't infer. - **Inferred type predicates** (5.5): a boolean-returning function that already narrows gets `x is T` automatically, e.g. `arr.filter(x => x !== undefined)`. -### Exhaustiveness with `never` - -- In a `default` branch, assign the value to a `never` variable; adding a new union member then fails to compile until handled. - ### `as` vs `satisfies` vs `!` - **`x as T`** is an unchecked assertion — it only rejects conversions between unrelated types (bypass: `as unknown as T`). @@ -91,7 +84,7 @@ What experienced TypeScript engineers forget before an interview, grouped by sub ### Branded types -- Structural typing makes `UserId` and `OrderId` both plain `string`s; **brand** them for nominal-like safety: `type UserId = string & { readonly __brand: 'UserId' }`. +- Types are compatible by **shape**, not declared name (structural typing), so `UserId` and `OrderId` are both plain `string`s; **brand** them for nominal-like safety: `type UserId = string & { readonly __brand: 'UserId' }`. - Create values only through a validating function (`asUserId(s)`); the brand has no runtime cost. ## Compilation and tooling @@ -125,7 +118,6 @@ What experienced TypeScript engineers forget before an interview, grouped by sub ### TypeScript 7 native compiler - **TypeScript 7** (2026) ships the Go port of the compiler (`tsgo` in preview): roughly **10×** faster builds with parallel checking. -- Its stable programmatic API is planned for **7.1**, so some tools (typescript-eslint, Vue/Svelte/Angular language tooling) still need the 6.x JS compiler. ## Strictness flags From 52b8b4aff1cbb985883577d8d52d1f1c3cdfbd4d Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 30 Sep 2026 02:43:52 +0000 Subject: [PATCH 4/4] Remove the temporary coverage review Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FADC1PgtXHNSjrM55y3LdW --- coverage-review.md | 574 --------------------------------------------- 1 file changed, 574 deletions(-) delete mode 100644 coverage-review.md diff --git a/coverage-review.md b/coverage-review.md deleted file mode 100644 index 0e66cc4..0000000 --- a/coverage-review.md +++ /dev/null @@ -1,574 +0,0 @@ -# Brief coverage review - -Temporary working file (2026-09-29): tick the items to act on, then delete this file before merging. - -**Status (2026-09-30):** all 72 P1 items are applied (619 → 675 concepts) and ticked below; notes in *italics* say where placement differs from the proposal. The section limit in AGENTS.md is now 5–20. All cut, merge, restructure, and duplicate items are applied too (675 → 645 concepts). Two P2 items were pulled in because a trim depended on them: the Master theorem and Context performance. The rest of P2 and P3 is untouched. - -**Legend** - -- **P1**: commonly asked and missing (or only implied). Add first. -- **P2**: comes up in senior or deep-dive rounds. Worth a bullet or a short concept. -- **P3**: niche or role-specific. Add only if it matches the roles you target. -- **new** = new `###` concept in the *section* named · **extend** = add bullets to an existing concept · **cut / merge** = trim candidates. -- Each item carries the proposed facts so it can be judged on its own. Versions and numbers come from memory; re-verify them when writing the prose. -- Where a new concept would push a section past 8 concepts, the item says what to merge or split. - -## Summary - -| Brief | Concepts | Verdict | Biggest gaps (P1) | -|---|---|---|---| -| Algorithms | 35 | Solid core | input-size heuristics, heap patterns, Kadane, random sampling | -| Databases | 39 | Strong PostgreSQL/InnoDB internals | join pitfalls, "why isn't my index used", Redis memory, document stores | -| Distributed Systems | 38 | Strong | delivery guarantees, CDC, monotonic clocks, Kafka partition changes | -| Networking | 22 | Good, smallest brief | failure signatures, TCP loss recovery, routing tables, client IP behind proxies | -| Operating Systems | 28 | Good | process states, atomic file replace, CAS/ABA, memory hierarchy | -| System Design | 37 | Strong | Little's law, percentile/cardinality pitfalls, multi-region/DR, video streaming | -| Go | 32 | Strong runtime; some tooling trivia | JSON gotchas, nil maps, context cancel, work stealing | -| JavaScript | 32 | Good; stdlib listings | async ordering, `fetch` semantics, hidden classes | -| Python | 32 | Strong | spawn/pickling, shared class attributes, numeric gotchas, recursion limit | -| Rust | 33 | Strong; "Unsafe and FFI" has no FFI | overflow and casts, Eq/Ord/Hash, layout/niches, `tokio::spawn` bounds | -| Solidity | 36 | Very thorough; longest file; version trivia | clones, admin keys and governance, ERC-1271 checks, slippage | -| TypeScript | 28 | Good | runtime validation, `{}`/`object`, function assignability | -| Backend | 30 | Good | schema evolution, multi-tenancy, time handling | -| Frontend | 36 | Good | effect data fetching, state snapshots, browser storage, error boundaries | -| Security | 40 | Strong | CORS simple requests, CSPRNG, password reset, resource-exhaustion attacks | -| AWS | 24 | Good, compact | ALB vs NLB, cross-account access, S3/CloudFront access, cost drivers | -| DevOps | 33 | Good | Pod security, `count` vs `for_each`, HPA mechanics, incident response | -| AI Engineering | 38 | Strong on serving and RAG | training pipeline, parallelism and GPU memory, filtered vector search | -| Ethereum | 26 | Good | precompiles, RPC block tags and reorgs, SNARK vs STARK, EIP-7702 risks | - -## Cross-cutting - -### New briefs to consider - -- [ ] **P1 if your loop has a low-level design round**: `ood.md` (Fundamentals). SOLID with one concrete violation each (Square/Rectangle for LSP), composition over inheritance, the GoF patterns interviewers name (strategy, observer, decorator, adapter, factory, builder, state, command, chain of responsibility; singleton pitfalls), dependency injection, the LLD interview flow (use cases → entities → interfaces → state and concurrency), classic prompts (parking lot, elevator, vending machine, expense splitting). -- [ ] P3: split `devops.md` into `kubernetes.md` + `devops.md` if Kubernetes keeps growing (it is now 5 of 9 sections). -- [ ] P3 if targeting data roles: `data.md`. Batch vs stream (Lambda/Kappa), Spark shuffle and skew, columnar files (Parquet) and table formats (Iceberg, Delta), orchestration and idempotent backfills. -- Not recommended: a separate concurrency brief. It's covered across os, golang, and rust; add CAS/ABA to os.md instead. - -### Ownership gaps - -No file owned these; each is now named in the AGENTS.md ownership table (merged into the existing owner rows). - -- [x] Change data capture → distributed (stream processing); referenced from database, system, backend (all three already mention CDC). -- [x] Little's law and capacity math → system; referenced from os (thread pools) and backend (pool sizing). -- [x] Monotonic vs wall-clock time → distributed (clocks); referenced from os and golang. -- [x] Schema evolution and compatibility (Protobuf, Avro, JSON) → backend; referenced from distributed (event schemas). -- [x] Timestamps and time zones → backend for app rules; database owns `timestamptz` behavior. -- [x] Disaster recovery tiers → system; aws lists only the AWS services. -- [x] Browser storage APIs → frontend; security keeps the token-storage guidance. - -### Duplicates - -- [x] solidity `Oracle integration` bullet 1 repeats ethereum `Oracle manipulation` bullet 1 (owner: ethereum). Keep only the link in solidity. -- [x] backend `File uploads` bullet 1 repeats system `CDN and object storage` bullet 2 (presigned URLs, metadata only). Keep one. -- [x] aws `KMS and envelope encryption` bullet 1 re-explains envelope encryption (owner: security). Keep the AWS-specific facts: `GenerateDataKey` and the 4 KB `Encrypt` limit. -- [x] distributed `Effectively-once processing` would overlap the proposed Delivery guarantees concept. Merge them. *Done: replaced by Delivery guarantees.* - -### Structure - -- Section counts: no brief exceeds the new 20-section limit (javascript has 12, system 11), so no merges are needed for that reason. -- [ ] Many sections have only 2 concepts (guide: 3–8). The P1 items filled backend Service calls, ai Training and fine-tuning, and rust Error handling; *new* P2 items would fill devops CI/CD, ethereum Consensus, rust Unsafe and FFI, and security Supply chain. Merge the rest where they stay thin. -- [ ] Growth budget: P1 added 56 concepts (619 → 675) and the trims removed 30 (→ 645). The remaining 105 P2 and 51 P3 items include 58 *new* P2 concepts; pair each add with a trim in the same brief to keep skimming and quizzes fast. - -## Fundamentals - -### Algorithms - -Solid on arrays, DP, and graphs. Missing the problem-solving heuristics and a few patterns that come up constantly in coding rounds. - -**Add** - -- [x] P1 · new · *Complexity and problem solving* › **Input size → target complexity**: at ~10⁸ simple operations per second, n ≤ 10 → O(n!), n ≤ 20 → O(2ⁿ), n ≤ 500 → O(n³), n ≤ 5,000 → O(n²), n ≤ 10⁶ → O(n log n), beyond → O(n) or O(log n). Reading the constraints picks the algorithm. -- [x] P1 · new · *Data structures* › **Heap patterns**: **k-way merge** of k sorted lists with a size-k min-heap, O(n log k); **two heaps** (max-heap for the lower half, min-heap for the upper) give a running median in O(log n) per insert; lazy deletion for removals. -- [x] P1 · new · *Arrays and sequences* › **Maximum subarray (Kadane)**: `cur = max(x, cur + x)`, `best = max(best, cur)`, O(n) time and O(1) space; circular variant = max(best, total − minimum subarray) unless every value is negative. The section reaches 8 concepts. -- [x] P1 · new · *Sorting and selection* (rename "Sorting, selection, and sampling") › **Random sampling and shuffling**: **reservoir sampling** keeps the i-th item with probability k/i (one pass, O(k) memory, unknown stream length); **Fisher–Yates** swaps `a[i]` with `a[rand(0..i)]`; drawing from the whole array at each step is biased. -- [x] P2 · extend · **Recurrence patterns** with the **Master theorem**: `T(n) = aT(n/b) + f(n)`; compare f(n) with n^(log_b a): smaller → Θ(n^(log_b a)), equal → Θ(n^(log_b a) · log n), larger → Θ(f(n)). Replaces the two worked examples. -- [ ] P2 · extend · **Knapsack and one-dimensional DP**: coin change with coins in the outer loop counts **combinations**; with the amount in the outer loop it counts **permutations**. -- [ ] P2 · extend · **Shortest-path choices** table: 0/1 weights → **0-1 BFS** with a deque, O(V+E); all pairs → **Floyd–Warshall** O(V³) (negative edges fine; a negative diagonal entry means a negative cycle); Dijkstra skips stale heap entries (lazy deletion). -- [ ] P2 · new · *Trees and graphs* › **Cycle detection and bipartiteness**: directed → DFS with three colors (reaching a gray node = back edge = cycle); undirected → a visited neighbor that isn't the parent, or union-find; bipartite ⇔ BFS 2-coloring succeeds ⇔ no odd cycle. -- [ ] P2 · new · *Trees and graphs* › **Grid and multi-source BFS**: a grid is an implicit graph (4 or 8 neighbors), O(rows × cols); seed the queue with every source at distance 0 to get "distance to the nearest X" in one pass. -- [ ] P2 · extend · **Tree traversal and BST ordering**: validate a BST with inherited (min, max) bounds, not parent–child comparisons; lowest common ancestor from post-order return values, or **binary lifting** for O(log n) repeated queries. -- [ ] P2 · extend · **Comparison sorts** with what standard libraries use: Python **Timsort** (stable), C++ `std::sort` introsort (unstable), Go pdqsort (unstable, since 1.19), Rust `sort` driftsort / `sort_unstable` ipnsort (since 1.81), JavaScript stable since ES2019. -- [ ] P2 · extend · **Binary search boundaries**: in a rotated sorted array one half is always sorted; check whether the target lies in it. Duplicates degrade the worst case to O(n). -- [ ] P2 · extend · **Quickselect and top-k**: **3-way partition** (Dutch national flag: `<`, `=`, `>` regions in one pass) keeps quicksort and quickselect fast with many duplicates. -- [ ] P3 · new · *Trees and graphs* › **Strongly connected components**: Tarjan (one DFS with low-links) or Kosaraju (DFS on the graph, then on its reverse), O(V+E); the condensation is a DAG. -- [ ] P3 · new · *Greedy, backtracking, and hardness* › **Number theory toolkit**: Euclid's gcd O(log min(a, b)), fast modular exponentiation O(log e), sieve of Eratosthenes O(n log log n), modular inverse via Fermat when the modulus is prime. -- [ ] P3 · extend · **LRU cache** with LFU in O(1): frequency → doubly linked list of keys, plus a pointer to the minimum frequency. - -**Trim** - -- [x] cut · **Time and space bounds** bullet 1's opening ("state the input size…"): generic advice. Keep the Ω(k) output-size point. -- [x] cut · **Recurrence patterns** bullets 1–2: two textbook recurrences, superseded by the Master theorem. *Replaced by the Master theorem, with merge sort and binary search as one-line examples.* -- [x] cut · **LRU cache** bullet 2: library API listing (low confidence; handy mid-interview). *Split the remaining bullet in two.* - -### Databases - -Strong on PostgreSQL and InnoDB internals. Weaker on everyday SQL pitfalls, index diagnosis, and non-relational breadth (no document store). - -**Add** - -- [x] P1 · new · *SQL gotchas* › **Join pitfalls**: a condition on the right table in `WHERE` turns a `LEFT JOIN` into an inner join, so put it in `ON`; joining two one-to-many children multiplies rows and inflates `SUM`/`COUNT` (aggregate each in a subquery first); `EXISTS`/`NOT EXISTS` are semi/anti-joins and never duplicate rows. -- [x] P1 · new · *Query execution and tuning* › **Why an index isn't used**: low selectivity (the planner prefers a sequential scan when many rows match), leading-wildcard `LIKE '%x'` (needs a trigram GIN index), `LIKE 'x%'` needs C collation or `text_pattern_ops`, implicit casts, `OR` across columns, stale statistics. Scan types: Seq, Index, Index Only, **Bitmap Heap** (combines several indexes). Absorbs **Reading EXPLAIN ANALYZE**. -- [x] P1 · new · *Non-relational stores* › **Redis eviction, expiry, and messaging**: `maxmemory-policy` defaults to **`noeviction`**, so writes fail when memory is full; caches use `allkeys-lru`/`allkeys-lfu`, while `volatile-*` evicts only keys with a TTL; expired keys are removed lazily on access plus by periodic sampling; pub/sub is fire-and-forget, Streams add persistence, consumer groups, and acks. -- [x] P1 · new · *Non-relational stores* › **Document stores (MongoDB)**: embed what's read together, reference unbounded or shared data; **16 MB** document limit; write concern `w: "majority"` (default since 5.0), since `w: 1` can lose acknowledged writes on failover; multi-document transactions (4.0 for replica sets, 4.2 sharded) are costly, so design for single-document atomicity. -- [ ] P2 · new · *Transactions and isolation* › **Implementing serializability**: actual serial execution (Redis, VoltDB: one thread, short transactions), **two-phase locking** (readers and writers block each other; MySQL `SERIALIZABLE`, SQL Server), **SSI** (optimistic, aborts on dangerous conflicts; PostgreSQL, CockroachDB). -- [ ] P2 · extend · **Anomalies × isolation levels** table: add lost-update and write-skew columns and a snapshot-isolation row, so PostgreSQL RR vs MySQL RR read off one matrix; then shorten the two engine concepts. -- [ ] P2 · new · *Schema design* › **Timestamps and time zones**: `timestamptz` stores a UTC instant and converts on display; `timestamp` (no zone) silently changes meaning when the session zone changes; `now()` is the transaction start time, `clock_timestamp()` the actual time. App-level rules go in backend. -- [ ] P2 · new · *SQL gotchas* › **Hierarchies and recursive CTEs**: `WITH RECURSIVE` = anchor + recursive term (`UNION`, or the `CYCLE` clause in PostgreSQL 14+, stops cycles); models: adjacency list (simple writes), materialized path/`ltree` (fast subtree reads), closure table (all ancestor pairs; fast reads, heavy writes). -- [ ] P2 · extend · **Physical vs logical replication**: an inactive **replication slot** retains WAL until the disk fills (`max_slot_wal_keep_size`, PostgreSQL 13+); long queries on a hot standby get canceled by replay conflicts unless `hot_standby_feedback` is on, which bloats the primary. -- [ ] P2 · extend · **Surrogate keys**: sequences are non-transactional, so rollbacks leave **gaps** and IDs don't follow commit order; gapless invoice numbers need a counter row updated under a lock. -- [ ] P2 · extend · **Upsert**: `ON CONFLICT DO NOTHING ... RETURNING` returns nothing for existing rows; `MERGE` (PostgreSQL 15+) isn't a concurrency-safe upsert, since concurrent inserts can still raise unique violations. -- [ ] P2 · new · *MVCC and locking* › **Slow COUNT(*)**: PostgreSQL checks each row's visibility, so `COUNT(*)` scans (an index-only scan helps while the visibility map is current); dashboards use `pg_class.reltuples` estimates or a counter table. -- [ ] P2 · new · *Schema design* › **JSONB vs columns**: JSONB for sparse or variable attributes, GIN (`jsonb_path_ops`) for containment queries; no per-key statistics (bad estimates), and updating one key rewrites the whole value, so promote hot keys to columns. -- [ ] P3 · new · *Storage engines and durability* › **Buffer pool vs page cache**: InnoDB's buffer pool takes ~50–80% of RAM with `O_DIRECT`; PostgreSQL's `shared_buffers` ~25%, relying on the OS page cache (double buffering); TOAST stores values over ~2 KB compressed and out of line. -- [ ] P3 · extend · **Write-ahead log**: relaxed durability (`synchronous_commit = off`, `innodb_flush_log_at_trx_commit = 2`) loses the last moments of commits on a crash but never corrupts data. -- [ ] P3 · extend · **PostgreSQL MVCC**: `VACUUM FULL` rewrites the table under `ACCESS EXCLUSIVE`; `pg_repack` rebuilds it online. -- [ ] P3 · extend · **Connection pooling**: prepared statements may switch to a generic plan after five executions (`plan_cache_mode`), which can be far worse for skewed values. - -**Trim** - -- [x] cut · **Redis persistence and licensing** bullet 3: license history is trivia; at most "Valkey is the drop-in open-source fork". *Dropped entirely; the concept is now *Redis persistence and replication*.* -- [x] cut · **OLTP vs OLAP** bullet 1: definition-level. Keep the column-store bullet. -- [x] merge · **InnoDB MVCC** (one bullet) into **MySQL InnoDB isolation**. *The merged concept is *InnoDB isolation and MVCC*.* -- [x] merge · **Deep pagination cost** (one bullet) into the new index concept; backend owns pagination. -- [x] merge · **Materialized views** (one bullet) into **OLTP vs OLAP** or the denormalization bullet in **Normalization**. *Merged into OLTP vs OLAP.* - -### Distributed Systems - -Strong and dense. - -**Add** - -- [x] P1 · new · *Transactions across services* › **Delivery guarantees** (absorbs Effectively-once processing): at-most-once = ack or commit the offset **before** processing; at-least-once = after (a crash between effect and ack redelivers); exactly-once *delivery* is impossible, exactly-once *effect* = at-least-once + idempotent handling, or one transaction covering the effect and the offset. -- [x] P1 · extend · **Physical clocks and TrueTime**: measure durations, timeouts, and leases with the **monotonic clock** (`CLOCK_MONOTONIC`, Go's `time.Since`, `performance.now()`); wall-clock time jumps on NTP steps, leap-second smearing, and VM migration. -- [x] P1 · new · *Stream processing* › **Change data capture**: log-based CDC (Debezium) reads the WAL or binlog, so it sees every change in commit order, deletes included, with no dual writes; polling `updated_at` misses deletes and same-timestamp rows; start from a consistent snapshot, then stream from its log position; ordering holds per key. -- [x] P1 · extend · **Kafka ordering and consumer groups**: adding partitions remaps `hash(key) % partitions` and **breaks per-key ordering** for existing keys, and the count can't be decreased, so size partitions up front; consumer **lag** is the health metric to alert on. -- [ ] P2 · new · *Partitioning* › **Rebalancing partitions**: `hash % N` moves almost every key when N changes; either a **fixed, large number of partitions** moved whole between nodes (Kafka, Elasticsearch, Couchbase) or **dynamic splitting** of large ranges (HBase, MongoDB, CockroachDB, Spanner); automatic rebalancing during a failure can cascade. -- [ ] P2 · new · *Consensus and coordination* › **Coordination services**: ZooKeeper ephemeral nodes and etcd leases vanish with the session, tying membership and locks to liveness; watches notify on change; a lock = sequential node + watching only the predecessor (no herd effect); ZooKeeper reads come from any replica and can be stale (`sync()` first), etcd reads are linearizable by default. -- [ ] P2 · extend · **Raft**: **Pre-Vote** stops a node rejoining after a partition from bumping the term and deposing a healthy leader; typical timing is a ~100 ms heartbeat and ~1 s election timeout (etcd defaults). -- [ ] P2 · new · *Stream processing* › **Exactly-once in stream processors**: Flink injects checkpoint **barriers** (Chandy–Lamport style) and snapshots operator state together with source offsets; end-to-end exactly-once needs a replayable source and a transactional (two-phase commit) or idempotent sink; transactional output becomes visible only when the checkpoint commits. -- [ ] P2 · extend · **Two-phase commit**: when each participant is itself a consensus group (Spanner runs 2PC over Paxos groups), a coordinator crash no longer blocks; XA across heterogeneous systems still does. -- [ ] P3 · extend · **Session guarantees**: consistent prefix reads (writes are seen in the order they happened); breaks when partitions replicate independently. -- [ ] P3 · extend · **Quorums**: `W + R > N` alone isn't linearizable; a concurrent write can be seen by one read and missed by a later one unless readers repair before returning. -- [ ] P3 · extend · **Multi-leader and leaderless**: give each record a **home region** that takes its writes, avoiding conflicts; move the home when a region fails. -- [ ] P3 · new · *Failure handling* › **Metastable failures**: a trigger (spike, cache flush) pushes a system into an overload that retries and timeouts sustain after the trigger is gone; recovery needs explicit load shedding, and retry budgets and bounded queues prevent it. -- [ ] P3 · extend · **Failure detection**: gossip spreads membership and metadata to all N nodes in O(log N) rounds (Cassandra, Serf). - -**Trim** - -- [x] merge · **Window types** (one bullet) into **Event time and watermarks**; frees a slot in Stream processing for CDC. -- [x] merge · **Effectively-once processing** into the Delivery guarantees concept above. - -### Networking - -The smallest brief (5 sections, 22 concepts). Good fundamentals, light on troubleshooting and routing. - -**Add** - -- [x] P1 · new · *End to end* › **Connection failure signatures**: **refused** = RST (host reachable, nothing listening); **timeout** = SYN dropped (firewall, security group, dead host), and Linux retries a SYN for ~**127 s** by default, so set connect timeouts; **reset by peer** mid-stream = the peer crashed or a middlebox hit its idle timeout; a proxy's **502** = upstream refused or reset, **504** = upstream too slow. -- [x] P1 · new · *TCP* › **Retransmission and loss recovery**: the RTO comes from smoothed RTT, with a Linux floor of **200 ms** (initial 1 s) and doubling per retry, so one lost packet on a quiet connection adds ≥ 200 ms (a classic p99 spike); **fast retransmit** after 3 duplicate ACKs; SACK names exactly which segments are missing. -- [x] P1 · new · *IP and routing* › **Routing tables**: the most specific route wins (**longest prefix match**: `/32` beats `/24` beats `0.0.0.0/0`); the default route points at the gateway; ARP resolves the next hop's MAC on the local link, so MACs change per hop while IPs stay end to end unless NAT rewrites them. -- [x] P1 · new · *HTTP versions* (rename "HTTP") › **Client IP behind proxies**: L7 proxies append `X-Forwarded-For`, and clients can forge the earlier entries, so trust only those added by your own proxies (count from the right); L4 load balancers preserve the source IP or pass it with the **PROXY protocol**; rate limits and audit logs depend on getting this right. -- [ ] P2 · new · *TCP* › **Connection states for debugging** (table): SYN_SENT (no SYN-ACK: filtered?), SYN_RECV (half-open: SYN flood?), ESTABLISHED, FIN_WAIT_2 (peer hasn't closed), CLOSE_WAIT (your app hasn't closed), TIME_WAIT (you closed first). Absorbs the CLOSE_WAIT bullet from **Teardown and TIME_WAIT**. -- [ ] P2 · extend · **Handshake and connection queues**: the listen backlog is capped by `net.core.somaxconn` (4096 since Linux 5.4); `SO_REUSEPORT` lets several processes bind one port, each with its own kernel-balanced accept queue (Nginx, Envoy). -- [ ] P2 · extend · **Resolution path**: Kubernetes Pods resolve with `ndots:5`, so an external name with fewer dots first tries every search domain (several wasted lookups per call); use FQDNs with a trailing dot or lower `ndots`. -- [ ] P2 · extend · **NAT**: NAT traversal. STUN learns the public mapping for UDP hole punching; symmetric NATs defeat it, so WebRTC falls back to a **TURN** relay (ICE tries candidates in order). -- [ ] P3 · new · *IP and routing* › **L3/L4 load distribution**: ECMP hashes flows across equal-cost paths; L4 balancers use consistent hashing (Maglev) so flows survive balancer changes; direct server return sends responses straight from the backends. -- [ ] P3 · extend · **Loading a URL**: light in fiber covers ~200 km per ms, about 1 ms of RTT per 100 km, so a transatlantic round trip costs ~70 ms whatever the bandwidth. -- [ ] P3 · extend · **HTTP/2**: Rapid Reset (2023). Clients open and immediately cancel streams to exhaust servers; servers now cap resets per connection. - -**Trim** - -- [x] merge · **UDP**: definition-level. Move "DNS, VoIP, games, QUIC" into **HTTP/3 and QUIC** or **Head-of-line blocking**. -- [x] cut · **HTTP/1.1** bullet 2's history (domain sharding, sprite sheets). Keep "~6 connections per host". -- [x] merge · **Debugging tools**: a tool list. Fold it into the failure-signatures concept as symptom → tool. *Now a *Check with* column in the failure-signatures table.* - -### Operating Systems - -Good coverage of memory and I/O. Missing process states, a safe file-replace pattern, lock-free basics, and latency intuition. - -**Add** - -- [x] P1 · extend · **Durability and fsync**: **atomic file replace**. Write a temp file → `fsync` it → `rename` it over the target (atomic on POSIX) → `fsync` the directory; readers see the old or the new file, never a torn one. *Done as a separate concept,* Atomic file replace. -- [x] P1 · new · *Processes and threads* › **Process states** (table): R (running or runnable), S (interruptible sleep), **D** (uninterruptible, usually disk or NFS I/O; even `SIGKILL` waits, and it counts in load average), Z (zombie), T (stopped). -- [x] P1 · new · *Synchronization* › **Atomics, CAS, and the ABA problem**: compare-and-swap loops build lock-free structures and mutex fast paths; **ABA** = a value goes A → B → A and a stale CAS succeeds, fixed with version-tagged pointers or safe reclamation (hazard pointers, epochs); under heavy contention CAS loops thrash the cache line; x86 is TSO, ARM weakly ordered (orderings in [rust.md](rust.md)). -- [x] P1 · new · *Performance analysis* › **Memory hierarchy latencies**: L1 ~1 ns, L2 ~4 ns, L3 ~10–40 ns, DRAM ~100 ns, NVMe read ~10–100 µs; sequential access and contiguous layouts (arrays over linked lists, struct-of-arrays) win through prefetching and cache lines. system.md keeps its short interview list. -- [ ] P2 · new · *Processes and threads* › **IPC mechanisms**: pipes (one-way byte stream), Unix domain sockets (two-way, faster than loopback TCP, pass file descriptors via `SCM_RIGHTS`), shared memory + a lock (no copies), signals (no payload); the Docker and containerd APIs listen on Unix sockets. -- [ ] P2 · new · *Memory* › **Heap allocators and RSS growth**: `malloc` serves large requests (≥ 128 KB by default) with `mmap` and small ones from arenas; glibc creates up to 8 arenas per core on 64-bit, so multi-threaded services fragment and RSS only grows; `MALLOC_ARENA_MAX=2`, or jemalloc/tcmalloc/mimalloc. Memory already has 8 concepts: merge **Page faults** into **Virtual memory and the TLB** to make room. -- [ ] P2 · extend · **CPU quotas and throttling**: pool sizing. CPU-bound ≈ number of cores (or the quota); blocking I/O ≈ cores × (1 + wait/compute), or derive it from **Little's law** (see system.md). -- [ ] P3 · new · *Files and I/O* › **File locks**: `flock` locks a whole file per open file description; POSIX `fcntl` locks are per process and **released when any descriptor to the file closes**; both are advisory. -- [ ] P3 · new · *Files and I/O* › **Write-back and direct I/O**: dirty pages flush in the background past `dirty_background_ratio` and throttle writers at `dirty_ratio`, so a bulk write can stall unrelated writes; `O_DIRECT` bypasses the page cache (databases with their own buffer pool). -- [ ] P3 · new · *Processes and threads* › **Process memory layout**: text, data/BSS, heap, mmap region (shared libraries, large allocations, thread stacks), stack with a guard page (overflow → `SIGSEGV`); ASLR randomizes the bases. -- [ ] P3 · new · *Performance analysis* › **Virtualization**: VMs (own kernel, hardware isolation) vs containers (shared kernel) vs microVMs (Firecracker, behind Lambda and Fargate) vs gVisor (user-space kernel); `st` time shows what the hypervisor takes. - -**Trim** - -- [x] cut · **Processes vs threads** bullet 1: definition-level. Keep the `clone()` bullet, merged into **fork, exec, copy-on-write**. *The concept is gone; its `clone()` bullet moved to fork, exec, copy-on-write.* -- [x] cut · **Priority inversion**: rarely asked outside real-time roles (low confidence; Mars Pathfinder is a good memory hook). -- [x] cut · **Linux observability tools** bullet 1: a tool list. Keep the perf/eBPF/strace bullets, or turn the concept into a symptom → tool table. - -### System Design - -Strong building blocks and classic designs. Missing capacity math, metric aggregation pitfalls, multi-region/DR, and a couple of classic prompts. - -**Add** - -- [x] P1 · extend · **Back-of-envelope conversions**: **Little's law** L = λ × W, so in-flight requests = throughput × latency (1,000 RPS × 200 ms = 200 concurrent requests → threads, connections, pool sizes). -- [x] P1 · extend · **Observability**: percentiles **can't be averaged** across hosts or windows, so merge histograms and then take p99; **high-cardinality labels** (user ID, request ID) multiply Prometheus time series, so keep them in logs and traces. -- [x] P1 · new · *Reliability and operations* › **Multi-region and disaster recovery**: tiers by RTO/RPO, from backup and restore (hours) → pilot light → warm standby → active-active (near zero); async cross-region replication means RPO > 0; active-active needs conflict handling or per-record home regions, plus global routing (GeoDNS, anycast); rehearse failover. Absorbs the RPO/RTO bullet from **Availability math**. -- [x] P1 · new · *Classic designs: user-facing* › **Video streaming**: upload to object storage → transcoding DAG (split into chunks, encode in parallel) → renditions at several bitrates → **HLS/DASH** segments (2–10 s) plus a manifest → CDN; the player picks a rendition per segment (**adaptive bitrate**); pre-warm popular content at the edge. -- [ ] P2 · extend · **Load balancing**: **power of two choices**. Sample two backends and pick the less loaded: near-optimal balance without global state, and no herding onto the one server stale stats call "least loaded". -- [ ] P2 · new · *Classic designs: user-facing* › **Top-K and trending**: per-window counts in a stream processor; exact counts + a min-heap for moderate cardinality, **count-min sketch + heap** for huge key spaces; merging per-partition top-k is approximate, so fetch k′ > k per partition; sharded counters for view and like counts. -- [ ] P2 · new · *Classic designs: data and infrastructure* › **Distributed key-value store**: the Dynamo-style synthesis. Consistent hashing + virtual nodes, N replicas with W/R quorums, hinted handoff, Merkle anti-entropy, vector clocks or LWW, gossip membership; each piece links to distributed.md. -- [ ] P2 · new · *Data storage choices* › **Replication vs erasure coding**: 3× replication survives 2 losses at 200% overhead; Reed–Solomon 6+3 survives 3 losses at 50% overhead, but reads and repairs touch many nodes, so it suits cold and blob storage (S3, HDFS EC). -- [ ] P2 · new · *Reliability and operations* › **Blast-radius reduction**: **cell-based architecture** (independent full stacks, each serving a slice of customers); **shuffle sharding** (each customer gets a random subset of workers, so one poison tenant rarely shares all of another's); static stability (keep serving when the control plane is down). -- [ ] P3 · new · *Asynchronous processing* › **Lambda vs Kappa architecture**: Lambda = batch layer (complete, recomputable) + speed layer (fresh, approximate), two codebases to keep in sync; Kappa = one streaming pipeline that reprocesses by replaying the log into a new output. -- [ ] P3 · extend · **CDN and object storage**: an origin shield collapses edge misses into one origin fetch; normalize the cache key (drop tracking parameters); `stale-while-revalidate` and `stale-if-error` at the edge. -- [ ] P3 · new · *Classic designs: data and infrastructure* › **Order matching**: one single-threaded matching engine per symbol with an in-memory order book (price-time priority), fed by a sequencer and an event log for recovery and replicas (fintech and crypto loops). -- [ ] P3 · extend · **Back-of-envelope conversions**: 2¹⁰ ≈ 10³, 2²⁰ ≈ 10⁶, 2³⁰ ≈ 10⁹, 2⁴⁰ ≈ 10¹². - -**Trim** - -- [x] cut · **Leaderboard** bullet 2: Redis command deprecation trivia. -- [x] cut · **SQL vs NoSQL** bullet 1: definition-level. -- [x] cut · **Monolith vs microservices** bullets 1–2: well-known pros and cons. Keep "modular monolith by default" and Conway's law. - -## Languages - -### Go - -Strong runtime and concurrency coverage. Missing several everyday gotchas; a few tooling and syntax items are low value. - -**Add** - -- [x] P1 · new · *Standard library gotchas* › **encoding/json gotchas**: numbers decode into `any` as **float64**, so IDs above 2⁵³ lose precision (`Decoder.UseNumber`); a nil slice encodes as `null`, an empty one as `[]`; unexported fields are silently skipped; `omitempty` never omits a struct, `omitzero` (1.24) does; unknown fields are ignored unless `DisallowUnknownFields`. -- [x] P1 · extend · **Maps**: reading a nil map returns zero values, but **writing panics**, so `make` it first (a nil slice, by contrast, works with `append`). -- [x] P1 · extend · **context.Context**: every `WithCancel`/`WithTimeout`/`WithDeadline` returns a `cancel` you must call (`defer cancel()`), or the child and its timer live until the parent ends; `go vet` reports it (`lostcancel`). -- [x] P1 · extend · **Scheduler (GMP)**: each P has a local run queue (256 goroutines) plus a `runnext` slot; an idle P **steals half** of another P's queue; the global queue is checked every 61st scheduling round for fairness. -- [ ] P2 · new · *Standard library gotchas* › **time gotchas**: `time.Time` carries a location and a monotonic reading, so compare with `Equal`, not `==`, and don't use it as a map key; `time.Since` uses the monotonic clock; bare integers are nanoseconds (`time.Sleep(5)` sleeps 5 ns). -- [ ] P2 · new · *Standard library gotchas* › **Graceful shutdown**: `signal.NotifyContext` for SIGTERM → `srv.Shutdown(ctx)` stops accepting and waits for in-flight requests, but not for hijacked connections (WebSockets); `net/http` recovers a handler panic per request, but a panic in a goroutine you started kills the process. -- [ ] P2 · extend · **Error wrapping**: `%w` makes the wrapped error part of your API (callers can match it), `%v` hides it; sentinel (`io.EOF`) vs typed (`*fs.PathError`) vs opaque errors; `:=` inside a block shadows the outer `err`. -- [ ] P2 · extend · **Garbage collector**: **GC assist**. Goroutines that allocate during a cycle are drafted into marking, so allocation-heavy paths see latency spikes; background marking targets ~25% of `GOMAXPROCS`. -- [ ] P2 · new · *Modules and tooling* › **Static binaries and cgo**: `CGO_ENABLED=0` gives a fully static binary (for `scratch` or distroless images); with cgo, DNS may go through libc's resolver (`netgo` vs `netcgo`); cgo calls cost tens of nanoseconds and occupy a thread; cross-compile with `GOOS`/`GOARCH`. -- [ ] P3 · extend · **Method sets and embedding**: use pointer receivers when methods mutate, the struct is large, or it holds a `sync.Mutex`; don't mix receiver kinds on one type. -- [ ] P3 · new · *Types and interfaces* › **Package initialization**: imported packages initialize first, then package-level variables in dependency order, then `init()` functions in file order; keep `init` free of I/O. - -**Trim** - -- [x] cut · **Newer language features**: syntax trivia (`min`/`max`, range over int, generic type aliases). Keep `new(expr)` at most. *`new(expr)` dropped too.* -- [x] cut · **Toolchains and tools**: `GOTOOLCHAIN`, `tool` directives, and `go fix` modernizers are rarely asked. -- [x] cut · **Routing, JSON, logging** bullets 2–3: json/v2's status keeps moving and "`log/slog` exists" is trivia. Replace them with the encoding/json gotchas concept. *The remaining ServeMux bullet moved into net/http clients and servers.* -- [x] cut · **Test tooling** bullet 1: table-driven tests and `t.Run`/`t.Parallel`/`t.Cleanup` are basics. -- [x] cut · **Cleanups, weak pointers, interning**: niche runtime APIs (low confidence). - -### JavaScript - -Good language-semantics coverage, but light on async ordering and engine internals; several concepts are standard-library listings. - -**Add** - -- [x] P1 · new · *Async* › **async/await ordering**: the `Promise` executor runs **synchronously**; `.then` callbacks and the code after `await` always run as microtasks, even for resolved values; inside `try`, `return promise` bypasses the `catch`, so write `return await`; an `async` function always returns a new promise. -- [x] P1 · new · *Async* › **fetch semantics**: `fetch` rejects only on network failure; HTTP 4xx/5xx resolve with `res.ok === false`; the body can be read once (`res.clone()` to reuse it); there's no default timeout (`AbortSignal.timeout`). -- [x] P1 · new · *Memory* › **Hidden classes and inline caches**: V8 gives objects built with the same properties in the same order a shared hidden class (shape); property-access sites cache shapes: monomorphic is fast, more than 4 shapes goes **megamorphic**; initialize every field in the constructor and avoid `delete` on hot objects. -- [ ] P2 · new · *Coercion and equality* › **Strings and Unicode**: strings are UTF-16, so `'😀'.length === 2` and indexing can split a surrogate pair; `for...of` and spread iterate code points; user-perceived characters need `Intl.Segmenter`; `normalize('NFC')` before comparing. -- [ ] P2 · new · *Coercion and equality* › **Object vs Map**: object keys are strings or symbols (numbers coerce), ordered integer-like keys ascending, then strings by insertion, then symbols; `Map` keeps any key type in insertion order, has `size`, and handles frequent adds and deletes better; `JSON.stringify` turns a `Map` into `{}`. -- [ ] P2 · new · *Node.js runtime* › **EventEmitter gotchas**: listeners run **synchronously** in registration order; an `'error'` event without a listener **throws** and crashes the process; more than 10 listeners logs a leak warning; `events.once()` returns a promise. -- [ ] P2 · extend · **Microtasks vs macrotasks**: nested `setTimeout` is clamped to ≥ **4 ms** after 5 levels; hidden tabs throttle timers to once per second, and Chrome can throttle chained timers to once per minute after 5 minutes hidden. -- [ ] P2 · extend · **Type-check quirks**: `Array.prototype.sort` is stable since ES2019 and sorts in place (`toSorted` copies); `??` replaces only `null`/`undefined`, while `||` also replaces `0` and `''`. -- [ ] P2 · extend · **CommonJS vs ESM**: in an import cycle ESM sees uninitialized bindings (TDZ `ReferenceError`), CommonJS a partially filled `exports` object. -- [ ] P3 · extend · **Typed arrays**: browsers expose `SharedArrayBuffer` only to cross-origin-isolated pages (COOP `same-origin` + COEP `require-corp`). - -**Trim** - -- [x] cut · **Array and object helpers**: standard-library listing (`toSorted`, `with`, `groupBy`). -- [x] cut · **Promise helpers**: API listing (`withResolvers`, `try`). -- [x] cut · **Sets and iterators** bullet 1: Set method list. Keep the lazy iterator-helpers bullet. *The iterator-helpers bullet moved into Iterators and generators.* -- [x] cut · **Temporal** bullet 2: browser support status goes stale within months. -- [x] cut · **Workers, cluster, child processes** bullet 3: `spawn` vs `exec` basics. *Renamed *Worker threads and cluster*.* - -### Python - -Strong on the runtime, object model, and asyncio. Missing a few classic gotchas and the server and deployment angle. - -**Add** - -- [x] P1 · extend · **multiprocessing start methods**: with `spawn`/`forkserver` (defaults on macOS since 3.8 and on Linux since 3.14) children **re-import the main module**, so guard entry code with `if __name__ == "__main__":`; arguments and results must pickle (no lambdas, local functions, or open sockets). -- [x] P1 · new · *Gotchas* › **Shared class attributes**: a mutable class attribute (`items = []` in the class body) is shared by every instance; `self.items.append(x)` mutates the shared list, while `self.items = [...]` creates an instance attribute that shadows it. *Done in* Object model *instead, to keep Gotchas at 8.* -- [x] P1 · new · *Gotchas* › **Numeric gotchas**: `//` and `%` floor toward −∞ (`-7 // 2 == -4`, `-7 % 2 == 1`), unlike C, Go, Rust, and JavaScript; `round()` rounds half to even (`round(2.5) == 2`); ints never overflow; use `decimal.Decimal` for money. -- [x] P1 · new · *Gotchas* › **Recursion depth**: the default limit is **1000** (`RecursionError`) and there's no tail-call optimization, so deep DFS or memoized recursion needs an explicit stack or a careful `sys.setrecursionlimit`. -- [ ] P2 · new · *Concurrency* › **WSGI vs ASGI servers**: WSGI (Flask, Django) handles one request per worker thread or process; ASGI (FastAPI, Starlette) runs an event loop per worker; Gunicorn pre-forks workers, and refcount updates dirty the copy-on-write pages; `gc.freeze()` (3.7) before forking and **immortal objects** (3.12, PEP 683) keep them shared. -- [ ] P2 · new · *Concurrency* › **contextvars**: a `ContextVar` carries request-scoped state; each asyncio task runs in a **copy** of the context taken at creation, making it the async-safe replacement for thread-locals. -- [ ] P2 · extend · **Descriptors** (or new **Attribute lookup**): `obj.x` checks data descriptors on the type → the instance `__dict__` → non-data descriptors and class attributes → `__getattr__` (only on failure); `__getattribute__` runs on every access. -- [ ] P2 · extend · **Context managers and exceptions**: `raise New() from err` sets `__cause__`, implicit chaining sets `__context__`; `return` or `break` in `finally` swallows the exception (SyntaxWarning since 3.14, PEP 765). -- [ ] P2 · extend · **dict and set internals**: `defaultdict` **inserts** the key on any missing-key read, so `if d[k]:` grows the dict; use `k in d` or `.get`. -- [ ] P2 · extend · **Threads vs processes vs asyncio**: `concurrent.futures` executors are the high-level API for threads and processes; `asyncio.Semaphore` bounds concurrency; `asyncio.timeout()` (3.11) sets deadlines. -- [ ] P3 · extend · **Gradual typing and protocols**: `TypeIs` (3.13) narrows both branches, `TypeGuard` only the true one; runtime validation needs Pydantic or similar, since dataclasses don't validate. - -**Trim** - -- [x] cut · **Refcounting and the cyclic GC** bullet 2: patch-release GC history won't be asked. -- [x] cut · **Mutation during iteration** bullet 2: "dict order since 3.7" repeats dict internals. -- [x] merge · **Late-binding closures** (one bullet) into **Mutable default arguments** (same `i=i` fix) or **Scope and `UnboundLocalError`**. *Merged into *Default arguments and late binding*.* -- [x] cut · **Specializing interpreter and JIT** bullet 2: the JIT is off by default (low confidence). *Renamed *Specializing interpreter*.* -- [x] restructure · merge Recent language features + Typing (2 concepts each). *Now *Typing and recent features*.* - -### Rust - -Strong on ownership, traits, and async. Missing numeric semantics, the standard trait contracts, layout, and any actual FFI content. - -**Add** - -- [x] P1 · new · *Error handling* › **Integer overflow and casts**: overflow **panics in debug and wraps in release** (unless `overflow-checks = true`), so state intent with `checked_`, `wrapping_`, `saturating_`, or `overflowing_`; `as` truncates between integer types and saturates float → int (NaN → 0). -- [x] P1 · new · *Traits and generics* › **Eq, Ord, and Hash**: `PartialEq`/`PartialOrd` allow incomparable values (NaN), `Eq`/`Ord` promise a total order; `f64` implements neither, nor `Hash`, so it can't key a `HashMap` or use `.sort()` (use `total_cmp` or an ordered wrapper); `Hash` must agree with `Eq`; derived `Ord` compares fields in declaration order. -- [x] P1 · new · *Smart pointers and memory* › **Layout and niche optimization**: `Option<&T>`, `Option>`, and `Option` are the size of the inner type (the null or zero niche encodes `None`); the default `repr(Rust)` may reorder fields, `repr(C)` is for FFI; `&str`, `&[T]`, and `&dyn Trait` are two words; an enum is its largest variant plus a tag. -- [x] P1 · extend · **Futures and executors**: `tokio::spawn` needs a `Send + 'static` future, so move owned data or `Arc` clones in; Tokio's default runtime is multi-threaded work-stealing, and `current_thread` + `LocalSet` runs non-`Send` futures; `JoinSet` manages groups of tasks. -- [ ] P2 · new · *Unsafe and FFI* › **FFI boundaries**: `#[repr(C)]` types and `extern "C"` functions; `CString`/`CStr` for NUL-terminated strings (a pointer from a temporary `CString` dangles); a panic escaping an `extern "C"` function **aborts since 1.81** (UB before), so use `extern "C-unwind"` or `catch_unwind`; bindgen and cbindgen generate the bindings. -- [ ] P2 · new · *Lifetimes* › **Variance and PhantomData**: `&'a T` is covariant; `&'a mut T` is **invariant** in `T` (otherwise a shorter-lived reference could be written through it); `Cell` is invariant; `PhantomData` declares ownership and variance for types that hold raw pointers. -- [ ] P2 · new · *Smart pointers and memory* › **Collections gotchas**: `HashMap` hashes with randomly keyed SipHash-1-3, which resists HashDoS but is slow, so swap in FxHash or ahash for trusted keys; the `entry` API avoids a double lookup; `BTreeMap` for ordered iteration and ranges; `swap_remove` is O(1). -- [ ] P2 · extend · **Borrow rules and NLL**: borrows split across struct fields but not slice indices (`split_at_mut`, or `get_disjoint_mut` since 1.86); closures capture disjoint fields since edition 2021. -- [ ] P2 · extend · **Static vs dynamic dispatch**: a closed set of variants → enum + `match` (exhaustive, no allocation); an open set → `dyn Trait`; trait upcasting (`&dyn Sub` → `&dyn Super`) since 1.86. -- [ ] P3 · extend · **Interior mutability** table: `LazyLock`/`LazyCell` (1.80) replace `lazy_static` and `once_cell::Lazy`. -- [ ] P3 · new · *Macros and Cargo* › **Tests and release builds**: unit tests in `#[cfg(test)] mod tests` reach private items, `tests/` sees only the public API, doc tests run too; release profile knobs (`lto`, `codegen-units = 1`, `panic = "abort"`); debug builds can be 10–100× slower, so benchmark in release. - -**Trim** - -- [x] cut · **Iterators** bullet 2: `iter`/`iter_mut`/`into_iter` basics. -- [x] cut · **String vs &str** bullet 1: basics. Keep the no-indexing and char-boundary panic bullet. -- [x] cut · **Lock files and editions** bullet 2's version note ("edition 2024 since 1.85"). Keep what edition 2024 changes. -- [x] merge · **Async closures** (one bullet) into **Futures and executors** or **Fn, FnMut, FnOnce**. *Merged into Fn, FnMut, FnOnce.* - -### Solidity - -The most thorough brief (254 lines). Few additions; trimming version trivia matters more here. - -**Add** - -- [x] P1 · new · *Gas optimization* (deployment cost) or *Upgradeability* › **Clones and factories**: an **EIP-1167 minimal proxy** (45 bytes of runtime code delegating to a fixed implementation) makes deploying many instances cheap; `CREATE2` + salt gives addresses known before deployment; clones can't be upgraded and need an initializer; bind the salt to the deployer and parameters so a front-runner can't claim the address with other arguments. *Done in* Gas optimization. -- [x] P1 · extend · **Access control** with admin keys and governance: `Ownable2Step` makes the new owner accept, so a typo can't brick ownership; admin actions go through a **timelock** (plus a multisig) that gives users an exit window; flash-loan governance attacks (Beanstalk, April 2022, ~$182M) are stopped by snapshotting voting power at proposal creation (`ERC20Votes` checkpoints) and by voting delays. *Done as a separate concept,* Admin keys and governance. -- [x] P1 · extend · **Signature replay and malleability**: to accept signatures from smart-contract wallets (Safe, ERC-4337, 7702-delegated EOAs), verify through **`SignatureChecker`** (ECDSA or ERC-1271 `isValidSignature`); ERC-6492 wraps signatures from wallets not yet deployed. -- [x] P1 · new · *Security* › **Front-running and slippage**: public-mempool transactions can be front-run or sandwiched, so swap and liquidity functions take a `minAmountOut` and a `deadline` chosen off-chain (never derived on-chain from the manipulable spot price); commit-reveal for bids and games. MEV mechanics live in ethereum.md. Security reaches 9 concepts: split it into *Security* (reentrancy, access, signatures, randomness, DoS) and *Integration risks* (tokens, oracles, front-running, rounding). *Security is now split into* Security *and* Integration risks. -- [ ] P2 · new · *Gas optimization* › **Merkle allowlists**: store one root instead of a mapping and verify proofs with OpenZeppelin `MerkleProof`; **double-hash the leaves** so a 64-byte internal node can't pass as a leaf (second preimage); record claims in a bitmap to block double claims. -- [ ] P2 · extend · **Proxy storage and initializers**: legacy **storage gaps** (`uint256[50] __gap`) in upgradeable base contracts; shrink the gap by the slots you add. ERC-7201 namespaces replace them. -- [ ] P3 · new · *Security* › **Emergency controls**: `Pausable` with a guardian role, per-window outflow limits (bridges, lending) to cap losses during an exploit; pausing is itself a centralization risk to disclose. - -**Trim** (keep the mechanism, drop the release number) - -- [x] cut · **Modifiers** bullet 4: `virtual` modifier deprecation (0.8.31). -- [x] cut · **Libraries and user-defined types**: the `global` (0.8.13) and operator-binding (0.8.19) version details. -- [x] cut · **Transient and relocated storage** bullet 3: `layout at` (0.8.29/0.8.35) is niche. -- [x] cut · **Error types** bullet 4: the 0.8.26 vs 0.8.27 split for `require(cond, Error())`. -- [x] cut · **Assembly gotchas** bullet 2's deprecated-comment clause, and **Gas optimization patterns** bullet 5's 0.8.22 note. -- [x] cut · **Code size limit** bullet 3: EIP-7954 and Glamsterdam are still moving; re-add once shipped. -- [x] cut · **Oracle integration** bullet 1: duplicate of ethereum.md (owner). *Now one line linking to ethereum.md.* -- [x] cut · **Randomness and block data** bullet 4: the timestamp slot detail is minor. - -### TypeScript - -Good type-system depth. The biggest gap is the runtime boundary (types vanish), plus two assignability surprises. - -**Add** - -- [x] P1 · new · *Typing patterns* › **Runtime validation at boundaries**: types are erased, so `JSON.parse`, `res.json()`, env vars, and `as` casts yield unchecked data; parse with a schema library (Zod, Valibot, ArkType) and derive the type from the schema (`z.infer`) so the two can't drift; type untrusted input as `unknown`, not `any`. -- [x] P1 · new · *Type system semantics* › **`{}`, `object`, and index signatures**: **`{}` means any non-nullish value** (strings and numbers included), not "empty object"; `object` = any non-primitive; `Record` is a truly empty object; an index signature makes every key "present" unless `noUncheckedIndexedAccess` is on. -- [x] P1 · new · *Type system semantics* › **Function assignability**: a function returning a value is assignable to one returning `void` (so `arr.forEach(x => out.push(x))` compiles); a function with fewer parameters is assignable to one with more (callbacks may ignore arguments). -- [ ] P2 · new · *Declarations and runtime features* › **`private` vs `#private`**: TS `private`, `protected`, and `readonly` are compile-time only, visible at runtime and reachable via `obj['x']`; ECMAScript `#x` is engine-enforced and hidden from `Object.keys` and JSON. -- [ ] P2 · new · *Narrowing* (rename "Narrowing and widening") › **Literal widening**: `let x = 'a'` is `string`, `const x = 'a'` is `'a'`; object literal properties widen (`{ kind: 'a' }` → `{ kind: string }`) unless `as const`, `satisfies`, or a contextual type applies; the usual cause of "string is not assignable to 'a' | 'b'". -- [ ] P2 · extend · **Conditional types**: `C` distributes over an empty union and yields `never`, so test with `[T] extends [never]`; `infer U extends string` (4.7) constrains the inferred type. -- [ ] P2 · extend · **The `strict` family**: `useUnknownInCatchVariables` (in `strict` since 4.4) types `catch (e)` as `unknown`; narrow with `instanceof Error` before reading `.message`. -- [ ] P2 · extend · **Custom type guards**: a hand-written `x is T` isn't verified, so a wrong predicate lies to the compiler just like `as`. -- [ ] P2 · new · *Compilation and tooling* › **Project references and build speed**: `composite` projects built with `tsc -b` compile a monorepo incrementally in dependency order; slow checks come from huge unions, deep conditional types, and large inferred literals (`--extendedDiagnostics`, `--generateTrace`). - -**Trim** - -- [x] merge · **Structural typing** (one definition-level bullet) into **Branded types**, which exists because of it. -- [x] cut · **TypeScript 7 native compiler** bullet 2: tooling compatibility status will change within months. -- [x] merge · **Exhaustiveness with `never`** (one bullet) into **Control-flow narrowing** (low confidence). - -## Web - -### Backend - -Good API and reliability patterns. Missing schema evolution, tenancy, time handling, and service-to-service auth. - -**Add** - -- [x] P1 · new · *API design* › **Schema evolution**: **backward compatible** = new readers read old data, **forward compatible** = old readers read new data; Protobuf: never reuse or renumber a field (mark it `reserved`), adding fields is safe, proto3 has no `required`, unknown fields survive round trips; Avro + Schema Registry enforces BACKWARD/FORWARD/FULL modes; JSON consumers must ignore unknown fields (tolerant reader). *Done in* Service calls *instead, since API design already had 8.* -- [x] P1 · new · *Data access* › **Multi-tenancy models**: shared tables with a `tenant_id` (cheapest; every query must filter, so enforce it with PostgreSQL **row-level security**, which the table owner bypasses unless `FORCE ROW LEVEL SECURITY`) → schema per tenant → database per tenant (strongest isolation, per-tenant restore, most operations work); move noisy tenants to their own shard. -- [x] P1 · new · *Data access* › **Time handling**: store and send instants in UTC (RFC 3339 with an offset); for future local-time events (meetings, schedules) store the local time + an **IANA zone**, since offsets and DST rules change; a DST switch skips or repeats local times, so a 02:30 cron runs twice or never. -- [ ] P2 · new · *Service calls* › **Service-to-service authentication**: mTLS with workload identities (SPIFFE, a mesh), OAuth client credentials (short-lived JWTs with `aud`), or signed requests (HMAC, AWS SigV4); API keys are long-lived bearer secrets, so store them hashed, give them a scannable prefix, and rotate them. Mechanisms in security.md. -- [ ] P2 · extend · **Timeouts and deadline propagation**: a short connect timeout (~1 s) separate from the read or overall timeout; propagate the W3C `traceparent` header along with the deadline. -- [ ] P2 · new · *Lifecycle and config* › **Service internals**: hexagonal architecture (ports and adapters) keeps the domain free of framework and database imports; a DDD **aggregate** is the consistency and transaction boundary (one aggregate per transaction, others referenced by ID); **bounded contexts** map to service boundaries. -- [ ] P3 · new · *API design* › **Batch endpoints**: per-item results (207 Multi-Status or a result array), per-item idempotency, and a maximum batch size. -- [ ] P3 · extend · **Integration tests with real dependencies**: prefer fakes (working in-memory implementations) over mocks for stateful dependencies; mocks couple tests to call sequences. - -**Trim** - -- [x] cut · **Resource modeling**: REST naming basics. -- [x] cut · **Configuration and secrets**: 12-factor generics. Keep "validate config at startup" at most. *Cut entirely; the section is now *Service lifecycle*.* -- [x] cut · **File uploads** bullet 1: duplicates system.md. Keep the multipart/resumable bullet. *Shortened to a link to system.md.* -- [x] cut · **Queue vs direct call**: system.md's **Queue semantics** covers it (low confidence). - -### Frontend - -Good breadth. Missing the React data-fetching and state-update gotchas that interviews probe, plus browser storage. - -**Add** - -- [x] P1 · new · *React hooks pitfalls* › **Data fetching in effects**: responses can arrive out of order, so ignore stale ones in cleanup (an `ignore` flag or `AbortController`); effect-based fetching causes **waterfalls** (parent fetch → child mounts → child fetch), so hoist fetching to route loaders or a query library; Strict Mode fires the request twice in development. -- [x] P1 · new · *React rendering model* › **State snapshots and keys**: state is a **snapshot** per render, so `setCount(count + 1)` twice adds 1 while `setCount(c => c + 1)` twice adds 2; changing a component's `key` resets its state; `useRef` holds mutable values without re-rendering. -- [x] P1 · new · *Caching* › **Browser storage**: cookies (~4 KB, sent with every request), `localStorage` (~5 MB per origin, **synchronous**, strings only), `sessionStorage` (per tab), **IndexedDB** (async, large, structured, available in workers), the Cache API (for service workers); any XSS can read all of them (tokens in security.md). -- [x] P1 · new · *React rendering model* › **Error boundaries**: they catch render and lifecycle errors in a subtree and show a fallback; still written as **class components** (or `react-error-boundary`); they don't catch errors in event handlers or async code. -- [ ] P2 · new · *React hooks pitfalls* › **useLayoutEffect vs useEffect**: `useEffect` runs after paint; `useLayoutEffect` runs after DOM mutation but **before paint**, for measuring layout without flicker, at the cost of blocking paint. -- [ ] P2 · extend · **Core Web Vitals**: rankings use **field data** (CrUX, p75 over 28 days, mobile and desktop separately); a page-load Lighthouse run is lab data and can't measure INP, so it reports TBT as a proxy. -- [ ] P2 · new · *Performance* › **Long lists**: **virtualize** (render only the visible rows: TanStack Virtual, react-window) beyond a few hundred complex rows; keep stable keys for infinite scroll. -- [x] P2 · new · *State management* › **Context performance** (replaces **Where state lives**): every consumer re-renders when the provider `value` changes identity, so memoize it, split state and dispatch into separate contexts, or use a store with selectors (`useSyncExternalStore`). -- [ ] P2 · new · *Performance* › **Web fonts**: `font-display: swap` shows fallback text instead of invisible text but causes a swap shift; `size-adjust` and metric overrides reduce that CLS; preload the one critical font; subset and self-host. -- [ ] P2 · extend · **Semantic HTML and ARIA**: dynamic messages (toasts, form errors) need an **`aria-live`** region; every input needs a programmatic label; test with axe and a keyboard. -- [ ] P3 · new · *State management* › **Signals**: fine-grained reactivity (Solid, Preact, Vue, Angular signals) updates only the dependents without a VDOM diff; a TC39 Signals proposal exists. -- [ ] P3 · extend · **Service workers** (or new **bfcache**): the back/forward cache restores pages instantly; `unload` listeners make a page ineligible, so use `pagehide`. -- [ ] P3 · new · *Accessibility* (rename "Accessibility and testing") › **Frontend testing**: Testing Library queries by role and label (tests behavior and rewards accessible markup); MSW mocks the network layer; Playwright covers end-to-end flows. - -**Trim** - -- [x] cut · **CSS layout and specificity** bullet 1: flexbox vs grid basics. *Renamed *Specificity and the cascade*.* -- [x] cut · **Modern CSS features**: feature listing and Baseline status. Keep container queries and `:has()`. *The nesting and `subgrid` clause went too.* -- [x] cut · **View transitions** bullet 2: Baseline status details go stale. *Kept the multi-page opt-in, dropped the Baseline status.* -- [x] cut · **Where state lives**: generic advice (replaced by Context performance). *Replaced by Context performance (P2 item ticked).* -- [x] cut · **Controlled vs uncontrolled inputs**: basic React (low confidence). - -### Security - -Strong. Missing a few browser-policy nuances, randomness, account recovery, and denial-of-service classes. Server-side attacks would reach 9 concepts: split it into *Injection* (SQL, command/template/XXE, deserialization, prototype pollution) and *Server-side request and resource attacks* (SSRF, smuggling, path traversal, resource exhaustion, race conditions, file uploads). - -**Add** - -- [x] P1 · extend · **CORS**: **simple requests** (GET, HEAD, or POST with form or `text/plain` bodies and no custom headers) go out without a preflight, and the server acts on them even when the browser hides the response, so CORS is no CSRF defense; everything else preflights with `OPTIONS`, cached by `Access-Control-Max-Age`. -- [x] P1 · new · *Cryptography* › **Secure randomness**: tokens, IDs, nonces, and reset codes need a **CSPRNG** (`crypto.getRandomValues`/`randomBytes`, Python `secrets`, Go `crypto/rand`); `Math.random`, `random`, and `math/rand` are predictable from a few outputs; use ≥ 128 bits for unguessable tokens. -- [x] P1 · new · *Authentication and sessions* › **Password reset and recovery**: single-use, short-lived, high-entropy tokens stored **hashed**; revoke other sessions after a reset; identical responses whether or not the account exists; build reset links from a configured origin, not the `Host` header (host-header poisoning); recovery is often the weakest login path (SIM swap, support desk). -- [x] P1 · new · *Server-side attacks* › **Resource-exhaustion attacks**: **ReDoS** (catastrophic backtracking on patterns like `(a+)+$`; use linear-time engines such as RE2 or Go's `regexp`, or timeouts), decompression and zip bombs (cap the output size), XML billion laughs, hash flooding (randomized hash seeds), unbounded JSON or GraphQL depth. -- [ ] P2 · extend · **CSRF**: "same-site" means same scheme + **registrable domain** (eTLD+1), so `evil.example.com` is same-site with `app.example.com` and SameSite doesn't stop attacks from a compromised or user-controlled subdomain; `Lax` still sends cookies on top-level GET navigations, so never change state on GET. -- [ ] P2 · new · *TLS* › **SNI, ALPN, ECH**: **SNI** carries the hostname in the ClientHello, so one IP serves many certificates and L4 proxies can route TLS without terminating it; **ALPN** negotiates `h2`/`http/1.1` in the handshake; **ECH** encrypts the inner ClientHello, hiding SNI from the network. -- [ ] P2 · new · *TLS* › **Certificate lifecycle**: the CA/Browser Forum (2025) cuts the maximum certificate lifetime to 200 days (March 2026), 100 days (2027), and **47 days (2029)**, so automate with ACME; revocation checking is weak (Let's Encrypt shut down OCSP in 2025), so short lifetimes do the work; monitor Certificate Transparency logs for your domains. -- [ ] P2 · extend · **Browser token storage**: current guidance for SPAs is a **BFF**: the backend runs the OAuth flow and keeps the tokens, and the browser gets only an `HttpOnly` session cookie. -- [ ] P2 · new · *Cryptography* › **Cipher modes and broken hashes**: **ECB** leaks patterns (equal blocks → equal ciphertext); CBC without a MAC enables **padding-oracle** decryption; use an AEAD (AES-GCM, ChaCha20-Poly1305); MD5 and SHA-1 are broken for collisions. -- [ ] P2 · new · *Supply chain* › **Secrets management**: prefer short-lived, dynamically issued credentials (Vault, cloud IAM) over static keys; scan commits and block pushes containing secrets; a leaked secret must be rotated, since deleting the commit doesn't un-leak it; env vars leak through `/proc//environ`, crash dumps, and child processes. -- [ ] P2 · new · *Server-side attacks* › **Race-condition attacks**: limit-overrun bugs, such as redeeming a coupon or withdrawing twice with parallel requests (HTTP/2's single-packet attack lands them within ~1 ms); fix with atomic conditional updates, unique constraints, or row locks. -- [ ] P2 · extend · **XSS**: frameworks escape text, but `dangerouslySetInnerHTML`, `v-html`, `innerHTML`, `javascript:` URLs in `href`, and template `|safe` filters bypass it; **Trusted Types** make DOM sinks reject plain strings. -- [ ] P2 · new · *Server-side attacks* › **File upload handling**: check the type by content (magic bytes), not the extension or `Content-Type`; store files outside the web root under generated names; serve user files from a separate sandbox domain with `Content-Disposition: attachment` and `nosniff`; re-encode images. -- [ ] P3 · new · *Browser-side attacks* › **Web cache poisoning and deception**: an unkeyed header (`X-Forwarded-Host`) reflected into a cached page poisons it for everyone; cache deception tricks a CDN into caching a private page under a static-looking path (`/account/x.css`). -- [ ] P3 · new · *Browser-side attacks* › **Subdomain takeover**: a dangling CNAME to a deleted cloud resource lets an attacker claim it, and the subdomain is same-site for your cookies. -- [ ] P3 · extend · **OAuth 2.0 vs OIDC**: SAML still dominates enterprise SSO; XML signature-wrapping bugs are its classic flaw. - -**Trim** - -- [x] cut · **Encoding vs encryption vs hashing**: definition-level table. -- [x] merge · **Clickjacking** into **Content Security Policy** (`frame-ancestors`) (low confidence). *Now a bullet in Content Security Policy.* -- [x] cut · **OWASP Top 10:2025**: keep only if you expect "name the list" questions (low confidence). *Cut; Threat modeling would have had one concept left, so it merged with Supply chain into *Secure development*.* - -## Infrastructure - -### AWS - -Compact and accurate. Missing the load balancer choice, cross-account access, S3 and CloudFront access control, and where the money goes. - -**Add** - -- [x] P1 · new · *Networking* › **ALB vs NLB** (table): ALB is L7 (host, path, and header routing; WebSockets; gRPC; OIDC auth; WAF); NLB is L4 TCP/UDP/TLS with a **static IP per AZ**, preserves the client IP, supports TLS passthrough and very high throughput, and fronts PrivateLink services; GWLB is for inline appliances; cross-zone balancing is on for ALB and off by default for NLB (cross-AZ charges). -- [x] P1 · new · *Identity and access* › **Cross-account access**: within one account, an allow in the identity **or** the resource policy suffices (KMS key policies and role trust policies excepted); across accounts **both** sides must allow; third parties assume your role with an **`sts:ExternalId`** condition (confused deputy); `aws:PrincipalOrgID` limits resource policies to your organization. -- [x] P1 · new · *Storage and databases* › **S3 access and CloudFront**: new buckets block public access and disable ACLs ("bucket owner enforced") since April 2023, and encrypt with SSE-S3 since January 2023; serve private buckets through CloudFront with **Origin Access Control**; signed URLs or cookies for private content at the edge. -- [x] P1 · extend · **Capacity and cost guardrails** (or new **Cost drivers**): NAT gateway data processing (~$0.045/GB; add S3/DynamoDB gateway endpoints), **cross-AZ traffic** (~$0.01/GB each way), internet egress, CloudWatch Logs ingestion; Savings Plans and RIs (up to ~72% off for 1–3 year commitments), Spot (up to ~90% off), Graviton (~20% cheaper). *Done as a new concept,* Cost drivers, *in Operations.* -- [ ] P2 · extend · **Managed database behavior**: **RDS Proxy** pools connections for Lambda bursts (each concurrent environment opens its own) and shortens failover; read replicas are asynchronous. -- [ ] P2 · new · *Events and workflows* › **Streams with Lambda**: Kinesis and DynamoDB Streams deliver in order per shard, so one failing record **blocks the shard** until it expires; set `BisectBatchOnFunctionError`, `MaximumRetryAttempts`, and an on-failure destination; a Kinesis shard takes 1 MB/s or 1,000 records/s in and 2 MB/s out; DynamoDB Streams keep 24 h; async Lambda invocations retry twice. -- [ ] P2 · new · *Compute* › **EC2 Auto Scaling**: target tracking (hold a metric such as requests per target) over step or scheduled policies; a health check grace period; lifecycle hooks for bootstrap and drain; warm pools for fast scale-out; T instances drop to baseline CPU when their credits run out (`unlimited` mode bills instead). -- [ ] P2 · extend · **DynamoDB partitions and indexes**: conditional writes (`ConditionExpression`, a version attribute) for optimistic locking and create-if-absent; on-demand vs provisioned capacity; single-table design keys items by access pattern. -- [ ] P2 · new · *Identity and access* › **Multi-account structure**: Organizations and OUs; SCPs cap member accounts' permissions (not the management account's); IAM Identity Center for human SSO; separate accounts per environment or workload as blast-radius and billing boundaries. -- [ ] P2 · extend · **Infrastructure changes and secrets**: Parameter Store's standard tier is free (4 KB values, no managed rotation); Secrets Manager charges per secret and adds rotation and cross-Region replication. -- [ ] P3 · extend · **Public and private subnets**: AZ names (`us-east-1a`) map to different physical AZs per account; align across accounts with AZ IDs (`use1-az1`). -- [ ] P3 · new · *Operations* › **Disaster recovery services**: the tiers live in system.md; here the AWS pieces: AWS Backup, S3 cross-Region replication, Aurora Global Database (typically < 1 s lag), DynamoDB global tables, Route 53 failover. -- [ ] P3 · new · *Networking* › **EKS Pod networking**: the VPC CNI gives every Pod a VPC IP, which exhausts subnets; use prefix delegation or secondary CIDRs. - -**Trim** - -- [x] cut · **ECS service mechanics**: definitions (task definition, service). -- [x] cut · **Lambda limits and concurrency** bullet 2: Managed Instances' 90-minute limit is new and niche (low confidence). -- [x] cut · **Capacity and cost guardrails** bullet 2: Budgets vs Cost Explorer trivia. -- [x] cut · **KMS and envelope encryption** bullet 1's re-explanation (owner: security). Keep `GenerateDataKey` and the 4 KB limit. - -### DevOps - -Good Kubernetes and Terraform coverage. Missing workload security, a key Terraform gotcha, autoscaling mechanics, and the delivery and incident practices DevOps interviews ask about. Kubernetes operations already has 8 concepts: move ServiceAccounts, ConfigMaps and Secrets, and NetworkPolicy into a new *Kubernetes security* section (with Pod security below), and Packaging and extension into *Kubernetes architecture*. - -**Add** - -- [x] P1 · new · *Kubernetes security* › **Pod security**: Pod Security Admission levels (privileged, baseline, **restricted**) per namespace, since PodSecurityPolicy was removed in 1.25; `securityContext`: `runAsNonRoot`, `readOnlyRootFilesystem`, `allowPrivilegeEscalation: false`, drop all capabilities, `seccompProfile: RuntimeDefault`; Kyverno or OPA Gatekeeper for custom policy. *Kubernetes security holds Pod security, ServiceAccounts, ConfigMaps and Secrets; NetworkPolicy stays in Kubernetes networking; Packaging and extension moved to Kubernetes architecture.* -- [x] P1 · new · *Terraform* › **count vs for_each**: `count` addresses resources by index, so removing one element shifts every later index and **recreates** those resources; `for_each` keys them by stable map or set keys. -- [x] P1 · extend · **Autoscaling**: HPA utilization is a percentage of **requests**, so without requests there's no CPU-based scaling; scale-down waits out a 5-minute stabilization window; **KEDA** scales on queue length or events, down to zero; Karpenter provisions right-sized nodes and consolidates underused ones. -- [x] P1 · new · *Deployment and release* › **Incident response**: roles (incident commander, communications, operations); **mitigate first** (roll back, flip a flag), find the root cause later; a blameless postmortem with a timeline, contributing factors, and owned action items; track MTTD and MTTR; link runbooks from alerts. -- [ ] P2 · new · *CI/CD and GitOps* › **DORA metrics**: deployment frequency, lead time for changes, change failure rate, failed-deployment recovery time; high performers improve speed and stability together; recent reports add rework rate. -- [ ] P2 · extend · **Deployment strategies** table: **shadow** (mirror live traffic to the new version and discard its responses; watch for side effects); A/B tests split by user for product metrics, not safety; Argo Rollouts and Flagger automate canary analysis. -- [ ] P2 · new · *Kubernetes workloads* › **Jobs and CronJobs**: `backoffLimit`, `activeDeadlineSeconds`, `ttlSecondsAfterFinished`; `concurrencyPolicy: Forbid` prevents overlapping runs; schedules use the controller's time zone (usually UTC) unless `timeZone` (GA 1.27) is set. -- [ ] P2 · new · *Kubernetes operations* › **Cluster upgrades**: control plane first, one minor version at a time; kubelets may lag the API server by up to 3 minor versions (since 1.28); drain nodes (PDBs apply) or roll new node groups; check for removed APIs first; each minor release gets ~14 months of patches. -- [ ] P2 · new · *Kubernetes operations* › **Quotas and priority**: `ResourceQuota` caps a namespace's total requests, limits, and object counts; `LimitRange` sets defaults for Pods without requests; `PriorityClass` lets critical Pods **preempt** others when the cluster is full. -- [ ] P2 · extend · **CI pipeline practices**: `pull_request_target` workflows that check out PR code run it with secrets (a "pwn request"); least-privilege `GITHUB_TOKEN`; OIDC to the cloud instead of stored keys; no untrusted PRs on self-hosted runners. -- [ ] P3 · new · *Deployment and release* › **Chaos engineering**: state a steady-state hypothesis, inject a failure (instance, AZ, latency) with a small blast radius, and compare against SLOs; game days rehearse incident response. -- [ ] P3 · new · *Terraform* › **Mutable vs immutable infrastructure**: configuration management (Ansible) patches servers in place and drifts; immutable images (Packer, containers) replace them. - -**Trim** - -- [x] cut · **Container networking and storage**: Docker basics (`EXPOSE` vs `-p`, volumes vs bind mounts). -- [x] cut · **Modules, workspaces, licensing** bullet 3: license history. Keep "OpenTofu is the open fork" (low confidence). *Renamed *Modules, workspaces, OpenTofu*.* -- [x] cut · **Node components** bullet 3: kube-proxy modes by version (low confidence). -- [x] cut · **Workload types**: definition-level for Kubernetes users. Keep "never run a bare Pod" (low confidence). *The bare-Pod bullet moved to Control plane.* - -## Domains - -### AI Engineering - -Strong on inference, serving, RAG, and agents. Missing how models are trained (including reasoning models), multi-GPU serving, and filtered retrieval. LLM fundamentals already has 8 concepts: move **Structured output** and **Tool calling** into *Tools and integration* to make room. - -**Add** - -- [x] P1 · new · *Fine-tuning* (rename "Training and fine-tuning") › **Training pipeline**: **pretraining** (next-token prediction on trillions of tokens; Chinchilla-optimal is ≈ 20 tokens per parameter, and modern models train far past it to be cheaper at inference) → SFT → preference tuning (RLHF, DPO) → **RL with verifiable rewards** (math and code graded automatically, e.g., GRPO), which is how reasoning models learn long chains of thought. -- [x] P1 · new · *Inference and serving* › **Model parallelism and GPU memory**: memory ≈ weights + KV cache + activations; **tensor parallelism** splits each layer across GPUs (needs NVLink-class links, so within a node); **pipeline parallelism** splits layers across nodes (pipeline bubbles); data parallelism replicates for throughput; **disaggregated serving** runs prefill and decode on separate GPU pools. -- [x] P1 · extend · **Vector index types**: **filtered search**. Post-filtering the top-k returns too few hits for selective filters, and pre-filtering breaks HNSW graph connectivity; use filter-aware engines or partition indexes by tenant. -- [ ] P2 · new · *LLM fundamentals* › **Positional encoding**: attention is order-blind; **RoPE** rotates query and key vectors by position so scores depend on relative distance; longer contexts come from RoPE scaling (position interpolation, YaRN) plus long-context training, and quality degrades past the trained length. -- [ ] P2 · new · *Fine-tuning* › **Distillation**: train a small student on a large teacher's outputs or logits for most of the quality at a fraction of the serving cost (also how small reasoning models are made); fine-tuning can cause catastrophic forgetting, which LoRA limits by freezing the base. -- [ ] P2 · extend · **Eval sets and metrics**: **pass@k** for code and agent tasks (the probability that at least one of k samples passes); precision/recall (PR-AUC when labels are imbalanced) for classifier-style checks; public benchmarks suffer from contamination. -- [ ] P2 · new · *Retrieval and RAG* › **Query transformation**: rewrite follow-ups into standalone queries; **HyDE** embeds a hypothetical answer instead of the question; decompose multi-hop questions; extract metadata filters (dates, product) from the query. -- [ ] P2 · extend · **Prompt injection**: jailbreaks (the user attacks the model's policy) vs prompt injection (third-party content attacks your application) are different threat models with different defenses. -- [ ] P2 · extend · **Batching and PagedAttention**: bigger batches raise tokens/s per GPU but also time per output token, so the latency SLO sets the batch size. -- [ ] P3 · new · *LLM fundamentals* › **Attention variants**: sliding-window attention, multi-head latent attention (DeepSeek; compresses the KV cache), and state-space or linear-attention hybrids (Mamba) with constant memory per token. -- [ ] P3 · extend · **Embeddings and similarity**: Matryoshka embeddings truncate to fewer dimensions; int8 or binary quantized vectors shrink the index 4–32×, then the top candidates are rescored at full precision. -- [ ] P3 · new · *Evaluation* › **Classic ML basics** (only for ML-adjacent roles): bias–variance and overfitting, regularization, train/validation/test splits and leakage, ROC-AUC vs PR-AUC. - -**Trim** - -- [x] cut · **Browser automation as a fallback**: generic. Move "approve irreversible submits" into **Human approval gates**. *Moved into Human approval gates.* -- [x] cut · **Model routing and caching** bullet 3: "measure cost per completed task" is generic (low confidence). -- [x] cut · **Stop conditions** bullet 2: generic (low confidence). - -### Ethereum - -Good protocol coverage. Missing precompiles, node and RPC practicalities, ZK proof systems, and EIP-7702's risks. - -**Add** - -- [x] P1 · new · *EVM* › **Precompiles**: fixed low addresses for cryptography too costly in bytecode: `0x01` ecrecover, `0x02` SHA-256, `0x05` modexp, `0x06`–`0x08` BN254 add/mul/pairing (SNARK verifiers), `0x0a` KZG point evaluation (EIP-4844), **BLS12-381** (Pectra, EIP-2537), **P-256** verification (Fusaka, EIP-7951; passkey wallets); they have no code, so `extcodesize` is 0. -- [x] P1 · new · *Accounts and transactions* › **RPC block tags and reorgs**: `latest` can reorg, **`safe`** (justified) rarely does, and **`finalized`** can't without slashing ⅓ of the stake; `eth_call` simulates against a block; `eth_estimateGas` binary-searches and can underestimate state-dependent paths, so add headroom; indexers store block hashes and roll back on reorg, or index only finalized blocks. -- [x] P1 · new · *Scaling* › **ZK proof systems**: **SNARKs** (Groth16, PLONK) have small proofs, cheap L1 verification via BN254 pairings, and often a trusted setup; **STARKs** need no trusted setup, are hash-based (plausibly post-quantum), and have larger proofs, often wrapped in a SNARK for L1; zkEVM types trade Ethereum equivalence against proving cost. -- [x] P1 · extend · **Account abstraction**: EIP-7702 risks. One authorization signature hands the EOA to the delegate's code (a phishing target); an authorization with `chain_id = 0` is valid on **every chain**; the delegate's storage lives in the EOA, so switching delegates can collide layouts (use namespaced storage). -- [ ] P2 · new · *Consensus (PoS)* › **Execution and consensus clients**: since the Merge a node = execution client (Geth, Nethermind, Besu, Erigon, Reth) + consensus client (Prysm, Lighthouse, Teku, Nimbus, Lodestar) linked by the authenticated **Engine API**; a bug in a client with > ⅔ of the stake could finalize an invalid chain, hence client diversity; full vs archive nodes. -- [ ] P2 · extend · **Transaction lifecycle**: a replacement needs the same nonce and ≥ 10% higher fees (Geth's default; 100% for blob transactions); private RPCs (Flashbots Protect) skip the public mempool. -- [ ] P2 · new · *Scaling* › **L2 fees and messaging**: an L2 fee = L2 execution + the **L1 data fee** (blob or calldata cost, usually the larger part); deposits through the canonical bridge can be force-included; withdrawals wait for the fraud window or a validity proof; L2BEAT stages 0–2 grade how much users rely on a security council vs proofs. -- [ ] P2 · new · *Consensus (PoS)* › **Validator lifecycle**: deposit → activation queue → active → exit queue → withdrawable (the churn limit rate-limits entries and exits); withdrawal credentials `0x01` (balance above 32 ETH swept) vs `0x02` compounding (Pectra); liquid staking (stETH) and restaking (EigenLayer) add contract and slashing risk. -- [ ] P2 · new · *Consensus (PoS)* › **Network upgrades** (table): Merge (Sep 2022, PoS) → Shapella (Apr 2023, withdrawals) → Dencun (Mar 2024, blobs, transient storage, EIP-6780) → Pectra (May 2025, 7702, 7251, 7623, BLS) → Fusaka (Dec 2025, PeerDAS, 7825, P-256) → Glamsterdam (planned: ePBS, block-level access lists). -- [ ] P2 · new · *DeFi and MEV* › **Bridge designs**: canonical rollup bridges (inherit L1 security, slow withdrawals), external validator or multisig bridges (fast, trust a committee, e.g., Ronin), light-client and ZK bridges, liquidity networks and intents (fast; LPs front the funds). -- [ ] P3 · new · *Signatures and standards* › **Wallet keys**: BIP-39 mnemonic → BIP-32 HD tree → path `m/44'/60'/0'/0/i`; MPC wallets split one key for threshold signing, vs multisig (on-chain M-of-N, visible, deployed per chain). -- [ ] P3 · extend · **Blobs and PeerDAS**: blob gas has its own EIP-1559-style base fee with a per-block target and max; EIP-7918 (Fusaka) ties the blob base fee floor to the execution base fee. -- [ ] P3 · new · *DeFi and MEV* › **Stablecoin designs**: fiat-backed (USDC; the issuer can freeze), overcollateralized crypto-backed (DAI), algorithmic (UST's 2022 death spiral). - -**Trim** - -- [x] cut · **Bridge exploits**: historical hack list. Keep one lesson per incident, or fold it into Bridge designs (low confidence). *Kept as one lesson per incident.* -- [x] cut · **Account model** bullet 1: definition-level for Ethereum roles (low confidence). *Renamed *Account nonces*.*