Commit graph

3 commits

Author SHA1 Message Date
monkopedia-coder
69a826f603
Upload the Google AAB to Play testing tracks from release.yml (#798)
Some checks failed
Android CI / test (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Build & Test (push) Has been cancelled
* Upload the Google AAB to Play testing tracks from release.yml

Play releases were uploaded by hand. Jason set up keyless Workload Identity
Federation for a play-publisher service account limited to testing tracks;
this wires it in.

play-upload.yml (workflow_dispatch + workflow_call) downloads the -google.aab
already attached to a tag's GitHub release -- no rebuild, signing stays in
release.yml -- authenticates via google-github-actions/auth, and runs
scripts/play-upload.sh, which drives the Android Publisher v3 edit directly
with curl: insert, bundles.upload, tracks.update, validate, then commit, or
on a dry run (the default for manual runs) list tracks and delete the edit.
Any failure deletes the edit and prints the HTTP status and body. Production,
FOSS artifacts and bundles whose manifest package is not com.rousecontext are
refused before any request.

release.yml gains a play-upload job (tag pushes only, after build) calling
it with track alpha, dry_run false. The build job is untouched.

scripts/tests/play-upload-test.sh runs the script against a mock Publisher
server and is wired into ci.yml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYSPuh9bZEJkrzvnEpY1QK

* Address review on #798: push-only Play job, fail-closed dry run

- release.yml: the play-upload job now also requires
  github.event_name == 'push'. A manual dispatch of release.yml on a tag
  ref satisfies startsWith(github.ref, 'refs/tags/v') and DOES re-run
  "Create GitHub Release"; it must not also commit to Play. Comment
  corrected to say so.
- play-upload.sh: --dry-run takes a value and commits only on exactly
  `false`; omitted, empty, True, FALSE, 0, typos are all dry runs. The
  workflow passes inputs.dry_run through verbatim.
- aab_manifest.py: bounds-check 64- and 32-bit fixed fields.
- Harness: fail-closed cases (11 values + omitted + missing value) and
  truncated fixed-field cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYSPuh9bZEJkrzvnEpY1QK

---------

Co-authored-by: Monkopedia <monkopedia@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 17:50:18 -04:00
monkopedia-coder
8cbcc40eb1
Gate: a broad catch must be preceded by a cancellation clause (#674) (#720)
* Gate: a broad catch must be preceded by a cancellation clause (#674)

`CancellationException` extends `IllegalStateException` on the JVM, so all
four of `Exception`, `Throwable`, `RuntimeException` and
`IllegalStateException` receive it. Source order within one try/catch chain
is the only thing that decides delivery, and the Kotlin compiler diagnoses
neither an unreachable nor a mis-ordered clause -- which is why six
human-directed sweeps in two days (#660, #662/#665, #666/#669, #670/#673,
#638/#672, #667) each found what the previous one had not looked at.

The gate:

  scripts/lib/kotlin-catch-chains.awk   per-file scanner
  scripts/check-cancellation-catch-order.sh
  scripts/tests/check-cancellation-catch-order-test.sh
  scripts/cancellation-catch-allowlist.tsv   reasoned exemptions (1 entry)
  scripts/cancellation-catch-backlog.tsv     known-unfixed defects (60)

A scanner rather than a regex, because the property is order WITHIN ONE
CHAIN and neither half survives a line match: this tree has a four-line
clause (McpTool.kt:170) no line regex parses, and adjacent chains a line
regex would credit to each other. Comments and string literals are blanked
in place, then tokens are walked tracking brace depth.

RED ON A KNOWN-BAD HISTORICAL TREE
----------------------------------
Run against 9b50f469, the commit before #660: exit 1, 87 findings. Run
against 8479cf56 (#660 applied): exit 1, 75 findings. The 12 that
disappear are exactly the twelve #660's own commit message lists, file for
file and count for count:

    CertProvisioningFlow.kt   2 -> 1
    CtLogMonitor.kt           3 -> 1     (check x2)
    KtorWebSocketFactory.kt   1 -> 0
    MuxDemux.kt               1 -> 0     (sendPingAwaitPong)
    OnboardingFlow.kt         1 -> 0
    RelayApiClient.kt         2 -> 1     (executeRequest)
    SelfCertVerifier.kt       3 -> 0
    TunnelClientImpl.kt       2 -> 0     (runKeepaliveLoop, healthCheck)
                                  net -12

The positive fires on the defect and the negative goes quiet on the fix.
A reduced form of the pre-#660 CtLogMonitor shape is in the self-test, so
that pairing is pinned in CI rather than observed once.

TWO CONTROLS, EVERYWHERE
------------------------
Every rule is asserted in both directions -- an empty pattern matches
everything and a filtered search reaches nothing, and both look clean. All
four broad types, three narrow types, all three spellings of the guard,
guard-after-broad, a guard on a neighbouring try, a guard earlier in the
same chain with a clause between, the multi-line annotated clause, prose in
a KDoc, a guard quoted in a string literal, `Flow.catch { }`.

Part 6 mutates the gate itself: a copy that recognises no broad type, and a
copy that ignores the cancellation guard. Each must make the suite go red
and SAY so. Without those, an `expect 1` proves only that something went
red and an `expect 0` only that something was quiet.

The gate also refuses to report clean for a tree in which it parsed zero
catch clauses: a scanner that reaches nothing and a tree that has nothing
print the same empty result.

WHAT IT FINDS ON MAIN
---------------------
61 violations across 54 <path, function> keys, from 177 catch clauses in
278 files across 12 production source sets. One is exempt with a written
reason (IntegrationSetupViewModel.pushIntegrationSecrets -- no suspension
point in the try, pinned by IntegrationSecretsPersistCancellationTest).
The other 60 are recorded in the backlog file, which is not an allowlist:
they are defects, they cite #667, and the gate prints the outstanding count
on every run rather than reporting the tree as clean. None of them is fixed
here; the gate is the deliverable.

Both files are exact-match ratchets in BOTH directions, so fixing a site
fails the gate until its entry is lowered or removed. That is what stops
either file becoming the place things go to be forgotten, and it is
asserted by the self-test.

Two scanner defects found and fixed while measuring, both of which had
mis-attributed real findings: an ordinary `"` string whose `${ ... }`
template spans lines (TestRelayFixture.kt:392) was read as code from the
newline on, shifting the depth counter for the rest of the file; and
`fun interface`, brace-less interface members and default parameter values
each disarmed the function-header parser.

Closes #674.

Claude-Session: https://claude.ai/code/session_01YYSPuh9bZEJkrzvnEpY1QK
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* Repoint the backlog rows at #722, and say what the citation check does not do

All 53 backlog rows cited #667, which closed on 2026-09-02 -- the day before
this branch's head commit -- and which was scoped to its own six
`app/src/main` sites, never to this list. #674 closes when this PR merges.
So on the day this landed, 60 recorded defects would have cited two closed
issues and no open issue would have tracked them: invisible to any
open-state triage, in a file whose header says its purpose is not to become
the place things go to be forgotten.

#722 is the open tracker for this debt, and it records the triage rule
(reachability before severity), so the rows are not read as 60 mechanical
edits. Every row now cites it.

Also removes the two remaining places #667 was used as a POINTER rather
than as history: the allowlist entry's reason, which now stands on the
in-tree comment and `IntegrationSecretsPersistCancellationTest` alone, and
the gate's developer-facing failure text. The remaining mentions are
factual provenance -- the list of six sweeps, and which issue established
that both spellings of `CancellationException` are live -- and the sweep
list now says outright that all six are closed and that #722 is the tracker.

The gate itself cannot catch this class, and now says so at length rather
than implying otherwise. `read_ledger` matches `#[0-9]+` and never asks
whether the number resolves to anything, let alone to anything open;
`#999999` passes. Resolving it means a GitHub API call, and this gate runs
from a plain checkout with no token, offline on a developer machine, and
inside the throwaway repo its own self-test builds -- which has no remote.
A network check would have to fail closed in all three (a gate nobody can
run) or skip silently (a gate that reports clean without having looked,
which is the exact failure mode this file exists to prevent). So the check
is not made, the gap is written down, and the reviewer of a citation is a
human. The related ceiling problem is noted as #721 and is not fixed here.

No change to the gate's logic, the scanner, the self-test's assertions or
any production Kotlin. The self-test's two ledger fixtures move to #722 for
consistency; they only ever exercised the `#[0-9]+` shape.

Closes #674.

Claude-Session: https://claude.ai/code/session_01YYSPuh9bZEJkrzvnEpY1QK
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Monkopedia <monkopedia@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-03 06:59:24 -04:00
monkopedia-coder
d6b7bf7454
Share one anchoring helper across the grep gates (#597) (#697)
Three gates shipped the same defect -- a post-filter meant for ONE field of
`grep`'s `path:line:content` output, applied unanchored to the whole line, so
real violations dropped silently out of the results while the gate reported
clean (#577/#588, #590/#593, #594/#598). This does #597's recommended cheap
half: one small library with the two anchors as named functions and the
reasoning written down once.

`scripts/lib/gate-filters.sh`:

  skip_comment_continuations   content field   ^[^:]*:[0-9]+:[[:space:]]*\*
  exempt_path <basename>       path field      ^([^:]*/)?<basename>:[0-9]+:

Two functions, not one parameterised regex, on purpose: the three instances were
two DIFFERENT anchor shapes, and the bug each time was a category error --
applying a field-specific filter to the whole line -- not a typo. Naming the
field is the remedy. No gate framework; the grep-then-filter shape is fine.

Converted: check-no-production-runblocking.sh, check-no-manual-json.sh.
Deferred: check-no-sensitive-logging.sh, because #692 / PR #695 is live in that
exact file; tracked as #696. check-zombie-screens.sh and
check-apk-distribution.sh have no post-filter of this shape and deliberately do
not source the library.

THE LOAD-BEARING PART IS A COMMENT

The helper is not what caught these bugs, and the file says so before it says
anything about anchoring: every scripts/check-*.sh MUST ship a matching
scripts/tests/<gate>-test.sh wired into CI, because the harness -- not the
shared filter -- is what catches an unanchored post-filter. The same pointer
sits above the `source` line in each converted gate, since a fourth gate will
start life as a copy of a third.

REVIEW RECORD

Reviewed at ec5fee37 (changes requested) and c45035b4 (approved).

The first pass blocked on the library's own header: it documented a calling
convention both of its call sites abandoned in the same PR -- `|| true` on the
pipeline and `$(git rev-parse --show-toplevel)` resolution, against the gates'
`set +e` bracket and `${BASH_SOURCE[0]}`. Transcribed verbatim into a gate and
run through the phase-1 invocation check-shell-lint.sh uses (shellcheck 0.11.0,
-o check-extra-masked-returns,check-set-e-suppressed), the documented example
produced 3 findings and exit 1: SC2312 on the source line, SC2310 twice on the
pipeline. A shared library asserting a false property about itself is the exact
failure mode this file exists to end. c45035b4 corrects it -- comment-only, 14
executable lines identical -- and the corrected example is exit 0 / 0 findings
under the same harness, with the old example retained as a positive control so
the pass means something.

Behaviour preservation was established on a seeded probe corpus planted
identically at ac1b0284 and at the head, since the real tree is clean and
exercises none of the filter: stdout+stderr+exit byte-identical per gate, and
non-vacuous -- both `: *`-carrying real violations survive, nested
AuditDetailScreen.kt is exempt, while MyAuditDetailScreen.kt,
AuditDetailScreenTest.kt and a file that merely names the exempt file stay
reported. All seven pre-existing self-test logs byte-identical; suite 91 -> 111
`ok:` lines. check-shell-lint-test.sh is red identically on both sides for an
environmental reason (actionlint absent locally), not a regression.

One finding worth keeping, because this PR's subject is a shared filter whose
failure mode is being silently wrong: during mutation testing of
gate-filters-test.sh, the dot-escaping mutation first came back GREEN. The test
had not passed -- the `sed` anchor never matched, so nothing was mutated. A
mutation that never applied is indistinguishable from a test with no teeth, and
the two conclusions are opposite. Re-applied with the substitution verified, it
goes red as it should. All six mutations are red: unanchored content filter,
unanchored path filter, the `^[^:]*<base>:[0-9]+:` near-miss #594 recommended
and #598 rejected, dot escaping removed, basename guard removed, and both
filters replaced by `cat`. M1 fails only content-field cases and M2/M3 only
path-field cases, so the two anchor shapes are genuinely discriminated.

Per #657's policy the `|| true` pipelines became `set +e` brackets rather than
`# shellcheck disable=` comments.

Closes #597
2026-09-03 00:31:25 -04:00