Deployment, CI and release for flap #1

Merged
mikluko merged 39 commits from flap-4fh into main 2026-11-13 02:55:32 +00:00
Owner

Summary

Deployment, CI and release for flap (REQ-011..REQ-015), built from implementation convoy flap-p12. Review verdict: approved, no unresolved findings.

  • CI and release workflows after jmap-mcp: ubuntu-latest, ko image build, OIDC registry login
  • Helm chart with ingress for saraksh (traefik class, sarak.sh/dns, letsencrypt issuer)
  • Memory measured on Linux; budget set at idle 16 MiB, peak 32 MiB

Remaining risks

  • The workflows have not run on the Forgejo runner; the first push shows whether OIDC accepts the flap repository.
  • owner-decisions.md names a changelog action URL that returns 404; the implementation uses https://sarak.sh/mikluko/changelog, as jmap-mcp does.
  • The image job uses go-version: stable because ko needs a newer Go than go.mod.
  • Linux memory was measured on one arm64 VM with the golang image, not the scratch image the chart deploys. Headroom is 6.6 MiB idle and 11.6 MiB peak.
  • REQ-016 (live install at https://flap.sarak.sh, /hang and /drop through the real ingress) is deferred by owner decision; unverified.

Full report: request-1/final-report-gcg-888833.md, request-1/review-report-gcg-888839.md.

🤖 Generated with Claude Code

## Summary Deployment, CI and release for flap (REQ-011..REQ-015), built from implementation convoy `flap-p12`. Review verdict: approved, no unresolved findings. - CI and release workflows after jmap-mcp: ubuntu-latest, ko image build, OIDC registry login - Helm chart with ingress for saraksh (traefik class, `sarak.sh/dns`, letsencrypt issuer) - Memory measured on Linux; budget set at idle 16 MiB, peak 32 MiB ## Remaining risks - The workflows have not run on the Forgejo runner; the first push shows whether OIDC accepts the `flap` repository. - `owner-decisions.md` names a changelog action URL that returns 404; the implementation uses `https://sarak.sh/mikluko/changelog`, as jmap-mcp does. - The image job uses `go-version: stable` because ko needs a newer Go than `go.mod`. - Linux memory was measured on one arm64 VM with the `golang` image, not the `scratch` image the chart deploys. Headroom is 6.6 MiB idle and 11.6 MiB peak. - REQ-016 (live install at `https://flap.sarak.sh`, `/hang` and `/drop` through the real ingress) is deferred by owner decision; unverified. Full report: `request-1/final-report-gcg-888833.md`, `request-1/review-report-gcg-888839.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
internal/schedule maps an int64 millisecond UTC instant to outage state with
integer arithmetic only: period index and offset, SplitMix64 (mix64 plus
counter stream), outage count from count or availability (round half up,
min-1 clamp, capacity and 10 000 caps) and even placement with a seeded
shift. Exposes Windows, Down and NextChange. Scattered and grid placements
follow in story 1.2.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Add internal/schedule/params.go: duration and decimal percent parsers in
integer arithmetic, one parameter table driving parsing, validation and
docs, defaults, bounds, unknown/duplicate/empty parameter rejection, and a
ParamError carrying client-facing messages. Fuzz target for the parsers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
cmd/flap reads env-only config (FLAP_ADDR, FLAP_BASE_URL, FLAP_MAX_HANG,
FLAP_MAX_HANGS, FLAP_MAX_DROP_BYTES, FLAP_LOG_LEVEL, FLAP_DRAIN_DELAY),
fails fast on invalid values and shuts down on SIGTERM/SIGINT: readyz 503,
drain delay, base context cancel, Server.Shutdown with a 10 s deadline.

internal/server routes with Go 1.22 mux patterns, writes exactly one slog
JSON access line per request (also on panic and hijack) through a wrapper
that implements Unwrap, serves /healthz and /readyz, and provides the shared
failure-endpoint helpers: no-store, X-Flap-State and Accept-negotiated
parameter errors. Time enters only through an injected Clock.

Stacked on flap-320 (story 1.1), which supplies go.mod and CHANGELOG.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Multi-stage scratch Dockerfile (non-root 65532, static binary, version via
build arg), .dockerignore (un-ignored in .gitignore), charts/flap with two
replicas, PDB, node spread, probes, hardened security context, preStop sleep
tied to the drain delay, and a TLS ingress for flap.sarak.sh whose proxy
timeout is validated against FLAP_MAX_HANG. Adds scripts/check-chart.sh,
README docs and a changelog entry.

Stacked on flap-v39 (stories 1.1 and 2.1 are not yet on main).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
CI runs gofmt, go vet, go test -race, and guarded helm lint/template and
docker build on pull requests and pushes to main. The release workflow
builds and pushes the image and chart to the sarak.sh registry on v* tags,
with a workflow_dispatch dry run. The README replaces the stub.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Scattered draws N sorted offsets from the free space F = P - N*L and
spaces them by L; grid picks N of P/L slots with a partial Fisher-Yates
over a virtual array, so 1 ms slots cost nothing. Down binary searches a
list generated on each call, keeping Schedule an immutable value. New
rejects grid periods that are not a multiple of the outage (ErrGridDivisible)
and counts above the slot count (ErrCount, ErrGridSlots).

testdata/golden.json pins the windows of 67 parameter sets across all
placements; the golden test fails on drift and only writes with -update.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
charts/flap/values-saraksh.yaml layers the saraksh deployment on the chart
defaults (two replicas, host flap.sarak.sh, TLS secret) and marks the open
cluster decisions: ingress class, cert issuer (rendered empty rather than a
bogus issuer), registry path and pull secret.

docs/deploy.md is the operator runbook: open decisions with defaults, DNS and
TLS, helm and GitOps install, rollback, and what remains for a human. The live
install is not done, so AC-16 stays unmet until then.

scripts/verify-deploy.sh is a read-only check of /healthz with a verified
certificate chain, ready replicas via kubectl, and identical /inspect windows
across repeated calls. A missing /inspect is a FAIL, never a pass.

check-chart.sh also lints and renders the new values file.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
Inside an outage /hang holds the response for min(time to outage end,
duration), capped by FLAP_MAX_HANG, then answers 200; outside an outage
it answers 200 at once. A hold is released on client disconnect and on
server shutdown. Above FLAP_MAX_HANGS concurrent holds it answers 429
with X-Flap-Reason. The hold uses an injectable timer so tests use a
fake one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Answers any method with the chosen status (200 to 599) inside an outage and
200 ok outside. retry_after=<seconds>|remaining adds Retry-After during an
outage (remaining rounded up, at least 1). Schedule parameters, retry_after
and the code are validated before the clock is read, so an invalid request
is a 400 that never reaches the failure path.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
/inspect reports the schedule around an instant and never triggers a
failure: state, next change, achieved availability, the windows
overlapping the current period and links for status, hang and drop that
carry the same schedule parameters. format=json|html|svg forces the
format, otherwise Accept ranks text/html above application/json for HTML
and everything else gives JSON. at=<RFC 3339 or unix seconds> evaluates
another instant. HTML and SVG are placeholders behind a renderer seam.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
In an outage, /drop hijacks the connection, writes a head declaring one
more Content-Length byte than it sends, writes `bytes` body bytes
(default 0, capped by FLAP_MAX_DROP_BYTES), then sets SO_LINGER=0 and
closes so the peer sees a TCP reset. Outside an outage it answers 200
"ok". Schedule parameters and bytes are validated first; invalid input
is a 400 and never reaches the hijack.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Shut the write side before the linger-0 close so the client always sees an
end of stream, instead of losing the RST and waiting for its own timeout.
Add a real-TCP test at the default 65536 cap that fails on a stall.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Add internal/web: an html/template renderer, embedded with go:embed, that
implements server.InspectRenderer. The SVG timeline is computed from the
window offsets over the period length in integer tenths of a unit, clipped to
the period so a wrapping outage shows a tail from the left edge and a head to
the right edge, with a minimum width per outage and overlapping rects merged
so 10 000 windows stay a few hundred rects. The HTML page inlines the same SVG
and adds the schedule, state, next change, window table and failure links.
cmd/flap now installs the renderer in place of the placeholder.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts:
#	CHANGELOG.md
#	internal/server/server.go
# Conflicts:
#	CHANGELOG.md
#	internal/server/server.go
# Conflicts:
#	CHANGELOG.md
#	internal/server/server.go
# Conflicts:
#	CHANGELOG.md
#	internal/server/server.go
# Conflicts:
#	CHANGELOG.md
GET /docs renders schedule parameters from schedule.ParamTable, the
endpoint-specific parameters from a new server.EndpointParams table (each
row tested against its handler), failure kinds, caps from the live Config,
the inspect JSON shape (checked against server.Inspection by reflection)
and the ingress caveats. Every curl example on the page is extracted from
the rendered HTML and executed against a test server.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Story 3.3 (flap-pnk): a single embedded HTML page with vanilla JavaScript.
It has one input per row of the schedule parameter table, plus the optional
`at` instant, and fetches /inspect (JSON for the values, SVG for the picture)
as the inputs change, with a debounce and last-edit-wins. Blank fields are
omitted because /inspect rejects empty values. Server text is shown with
textContent only and links are checked before use. The page is served with a
content security policy that allows only its own script and style by hash.

It is registered on "GET /{$}" so unknown paths stay 404.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
scripts/loadtest.sh builds the binary like the Dockerfile and runs two
instances on loopback with the chart's GOMEMLIMIT and GOGC: one carries steady
requests plus the maximum concurrent hangs (the 257th is proven refused with
429), the other stays idle. Idle and peak RSS (ps samples and the kernel's
ru_maxrss) are compared with the 10 MiB and 25 MiB budgets and a miss exits
non-zero.

go test -run Determinism starts two real processes from the built binary with
a pinned FLAP_BASE_URL and compares raw /inspect?at= bodies, then restarts
each and compares again.

docs/loadtest.md records the measured numbers. On macOS the budget is not met
(13.4 MiB idle, 29 MiB loaded); the budget is unchanged and the
language-choice question is opened there.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A hold that failed to connect, or was refused with 429 because the cap
probe briefly borrowed a slot, was never re-opened, so the cap was
unreachable and TestProfileSmoke failed after 30 s under load. Holds now
retry those cases with backoff, record why a hold ended early, and the cap
check fails at once with that reason.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Measure memory on Linux and set the budget: idle 16 MiB, peak 32 MiB
All checks were successful
CI / chart (pull_request) Successful in 5s
CI / shellcheck (pull_request) Successful in 9s
CI / changelog (pull_request) Successful in 4s
CI / test (pull_request) Successful in 37s
b80ecfd018
Linux (Apple container, linux/arm64) reads 9.4 MiB idle and 20.4 MiB
loaded with the chart's settings, so the budget is met and Go stays.
cmd/loadtest gains -gomemlimit and -gogc to try the levers; the budget
lives in scripts/loadtest.sh. Figures and levers are in docs/loadtest.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/flap!1
No description provided.