Blog · one post a day

Keeping AI-Written Code Under Control: Field Notes from AllyOS

Each post takes one real problem from AllyOS and walks through the problem, the fix and the measured numbers. Client and internal company data are never published.

  • Architecture Decisions ·

    Self-hosted LLM with cloud fallback: what timeout should you set?

    Give the self-hosted hop its own timeout, or a hung local server means the cloud fallback never runs. Use 25 seconds when a person watches a page and 60 for background jobs, so "local timeout + one cloud call" fits the platform's 150-second limit. Fall back on a local 401/403 or HTML page, but still stop on a cloud 401.

  • Incident Review ·

    Why does incremental sync by updated_at silently miss records?

    If a sync asks for "updated_at > last max timestamp" and each run has a page cap, a cap that cuts through records sharing one timestamp loses the rest of that group for good. Fix it by storing "within this instant, read up to id X" next to the watermark, and never let a failed run blank the cursor. Measured 2026-12-01: 6 of 7 reproduction tests failed before the fix, all 7 pass after.

  • AI Dev Pipeline ·

    Add plpgsql_check to CI Without Drowning in Legacy Errors

    PostgreSQL plans PL/pgSQL queries only on first run, so a dropped column silently breaks functions that still name it. Run plpgsql_check in CI inside a rolled-back transaction, report only until you know the backlog, then freeze it in a shrink-only baseline that fails on any new error. Of 1,632 functions, 7 had errors; 2 were real bugs.

  • Weekly Numbers ·

    Claude Code in Production: One Week of Real Engineering Numbers

    From Nov 22 to Nov 28, 2026, the AllyOS integration branch took 160 merged pull requests and 378 non-merge commits, 94% of them co-authored by Claude. Test commits (90) outnumbered feature commits (79), 294 test files were added, and pre-push guards grew from 109 to 121. Production was updated 25 times, but only 7 of those were scheduled releases; the other 18 were hotfixes, which is the number I most need to fix.

  • Tools & Tips ·

    Fix Python subprocess UnicodeDecodeError on Windows for good

    Without an explicit encoding, Python decodes subprocess output and encodes print() with the OS code page (gbk on Chinese Windows). Telling the AI in project instructions was not enough, so AllyOS runs two AST checks before every push - every text-mode subprocess call must pass encoding="utf-8", and every script's main() must pin stdout to UTF-8. Scanning 612 files takes about 1.5 s, and the checks caught 7 AI misses in 30 days.

  • Incident Review ·

    Why Claude Code Subagent Worktrees Silently Break Your Git Hooks

    When Claude Code creates a worktree, including a subagent's isolated worktree, it rewrites the relative core.hooksPath in the shared .git/config to an absolute path, so every unpinned worktree runs the main checkout's hooks. Run one idempotent repair script from SessionStart, PostToolUse (EnterWorktree) and SubagentStart; we measured recovery in 68 ms.