@davoodmehraban89 / LifeMate / commits / 780a1fa
Fork 0

LifeMate — Personal, Family & Learning Companion

docs: scope owner-local signing inspection preparation [skip ci]

Quinn White committed Oct 23, 2026 at 10:38 UTC 780a1fa78dc2e634aa796abd51f89e6d7b59b1b9
2 files changed +123
docs/superpowers/plans/2026-10-23-local-signing-preflight.md new
+64
@@ -0,0 +1,64 @@
1 +# Local signing preflight implementation plan
2 +
3 +Spec: [local signing preflight](../specs/2026-10-23-local-signing-preflight.md).
4 +Base: PR45 `5f0c4da`; branch `feat/local-signing-preflight`.
5 +Owner/coordinator: root; Java helper owner: signing inspector implementer;
6 +independent review: separate reviewer. No owner key/device/data actions.
7 +
8 +## Task 1 — JDK inspector and synthetic integration tests
9 +
10 +Files owned: `scripts/java/LifeGuideKeyInspector.java`,
11 +`scripts/tests/test_signing_java.py`, `scripts/tests/signing_test_support.py`.
12 +Use the exact binary protocol and helper JSON schema in the spec. Success:
13 +`schemaVersion: 1`, `status: INSPECTED`, four public fields named there; exit0.
14 +Failure: `schemaVersion:1,status:REFUSED,reason:<fixed code>`; exit2.
15 +Reason enum: `invalid_request`, `keystore_unreadable`, `private_key_unavailable`,
16 +`unsupported_key_algorithm`, `key_proof_failed`, `inspection_failed`.
17 +Reject trailing bytes and unsupported entry types. Sanitize all exceptions.
18 +Remove password byte/char arrays best-effort. No dependencies beyond JDK17.
19 +
20 +First write/run tests against absent helper (RED), then implementation (GREEN).
21 +Actual keytool fixture generation is test-only in TemporaryDirectory; use
22 +per-process random credentials via keytool `:env` flags and capture its output.
23 +Never print test credentials or raw subprocess errors; no artifact upload.
24 +Run `python3 -m unittest scripts.tests.test_signing_java -v`.
25 +Expected: all tests pass with real JDK; fixture source hash unchanged.
26 +
27 +## Task 2 — Python CLI and read-only/error guards
28 +
29 +Files owned: `scripts/signing_preflight.py`,
30 +`scripts/tests/test_signing_preflight.py`. Root implements independently of Java
31 +files, consuming the exact protocol. Load baseline via existing verifier. Reuse
32 +`read_bounded` for encrypted key file. `check` is default; `inspect --keystore
33 +PATH --alias ALIAS --acknowledge-owner-local-inspection` is explicit/TTY-only.
34 +Errors are JSON with safe fixed codes, never argparse argument interpolation.
35 +No password env/CLI support, no key generation, no input searching, no file
36 +writes. Java child options in env stripped, captured stdout strictly validated,
37 +stderr discarded, timeout enforced. Tool report always delivery BLOCKED.
38 +
39 +First write/run tests before implementation. Run
40 +`python3 -m unittest scripts.tests.test_signing_preflight -v`.
41 +Expected: safety gates fail closed, real inspector integration uses only fixtures.
42 +
43 +## Task 3 — CI, guide, regression and independent review
44 +
45 +Add `.github/workflows/signing-preflight-qa.yml`: paths-limited ubuntu/windows,
46 +Python3.11/JDK17, contents read, no secrets/APK/device/network-dependent tests,
47 +no test-key/report artifacts. Add Persian guide with check command and future
48 +owner-only inspect command clearly gated by separate authorization. Explain
49 +matching/different/debug results, no uninstall or sharing keys/passwords, limits.
50 +Run new suites + existing Python tool/recovery suites; inspect every output.
51 +Independent whole-packet review for secret leakage/file mutation/gate bypass.
52 +Record actual commands/output and CI results in evidence JSON; record unrun
53 +platforms/owner operations as UNVERIFIED. Update PROJECT_STATE. Open small PR on
54 +PR45; no merge/release/deploy. Stop after handover.
55 +
56 +## Execution ledger
57 +
58 +- Setup: clean isolated worktree at `5f0c4da`; inherited AGENTS/state read.
59 +- Preflight: Java→Python exact protocol/JSON shared; no overlapping implementation
60 + files. Tests and docs use baseline reader without alternative baseline input.
61 +- Ruling: no new key-generation/transfer feature; read-only inspection is the
62 + smallest prep dependency. A wrong scope choice costs deferred usable transfer,
63 + not a change to installed data or approved policy.
64 +- Status: implementation/tests/CI UNVERIFIED until recorded below.
docs/superpowers/specs/2026-10-23-local-signing-preflight.md new
+59
@@ -0,0 +1,59 @@
1 +# Local signing preflight — preparation only
2 +
3 +Scope: a read-only host tool for a future, explicitly chosen owner-local key
4 +inspection. This packet implements and exercises it with ephemeral synthetic
5 +keys only. ADR0018's preparation-only boundary is unchanged. It does not create
6 +an owner key, configure signing, transfer child data or unlock APK delivery.
7 +
8 +## Problem and approach
9 +
10 +The installed APK's public signer is recorded in the delivered baseline. Its
11 +private key's availability is UNVERIFIED. Existing release automation signs the
12 +online application on GitHub; it is unsuitable for inspecting an offline owner's
13 +key locally. Parsing verbose keytool output could expose certificate identity.
14 +Use Python for explicit CLI/guards and a small local JDK17+ helper for typed
15 +KeyStore inspection instead. No network, device or signing/build commands.
16 +
17 +Default `check` reads only the public baseline and checks Java availability.
18 +`inspect` requires an explicit file, alias, acknowledgement and a non-echoing
19 +interactive terminal. Passwords have no argument/environment interface. The
20 +tool never searches for keys, copies/exports/generates one, prints identities,
21 +writes reports automatically, or modifies the selected file. Output is JSON
22 +containing only a fingerprint, public compatibility facts and fixed codes.
23 +
24 +The encrypted file is read once with the existing bounded no-follow regular-file
25 +reader (2 MiB maximum). A local subprocess receives bounded binary stdin, no
26 +secret/path/alias arguments: `LGKI`, then four unsigned big-endian 32-bit lengths
27 +and their byte strings: keystore, UTF-8 alias (1–256 bytes), store password
28 +(1–4096 bytes), key password (1–4096 bytes). EOF required. Passwords reject NUL,
29 +CR and LF. Java supports JKS and PKCS12; it decrypts a PrivateKeyEntry, signs a
30 +random internal challenge and verifies it with the certificate's public key.
31 +RSA/SHA256withRSA and EC/SHA256withECDSA only. Challenge/signature/private key
32 +are never output. Fixed helper JSON v1 has `certificateSha256`, `debugCertificate`,
33 +`privateKeyProof` (true) and `certificateCurrentlyValid` booleans, or a refusal
34 +code. Python validates the exact schema. Child timeout 30 seconds, heap 96 MiB.
35 +
36 +Comparison is against the reviewed delivered baseline, with no caller override.
37 +A matching debug signer remains a compatibility fact; the tool must separately
38 +refuse to label it production-ready. Every report keeps `delivery: BLOCKED`,
39 +`releaseReadiness: UNVERIFIED`, `installedDeviceVerification: UNVERIFIED` and
40 +`dataPreservation: UNVERIFIED`. A successful inspection is not release approval.
41 +
42 +## Acceptance and boundaries
43 +
44 +- Real temporary JKS/PKCS12 fixtures: repeated inspection, encrypted fixture copy,
45 + wrong store/key passwords, missing/certificate-only aliases, corrupt input,
46 + debug certificate. Source bytes remain equal. Fixture identity is fictional.
47 +- CLI acknowledgement/TTY before file access; malformed arguments/errors, helper
48 + corruption/timeout cannot leak canary passwords, paths, aliases or raw output.
49 +- No symlink, FIFO, directory, oversized file or baseline override. No plaintext
50 + file writes or secret arguments. JVM environment options that can inject
51 + agents/options are removed from the helper child environment.
52 +- Ubuntu/Windows CI uses ephemeral test keys only and uploads no key material.
53 +- Windows interactive prompts/ACL, owner keys/device, actual signing/upgrade,
54 + data transfer and Android acceptance remain UNVERIFIED until separately done.
55 +- Python/JVM memory zeroization, hostile administrators/JDKs, parent-directory
56 + symlink confinement and adversarial local filesystems are not guaranteed.
57 +
58 +No Flutter/backend/Gradle/package/version/workflow-delivery-policy changes.
59 +No merge, deploy, DNS, public release, owner key operation or real-data operation.