Skip to content

neurophone follow-up: JNI surface (#110), proofs, RSR, Trustfile, docs#156

Merged
hyperpolymath merged 2 commits into
mainfrom
claude/neurophone-repo-setup-envzix
Jul 1, 2026
Merged

neurophone follow-up: JNI surface (#110), proofs, RSR, Trustfile, docs#156
hyperpolymath merged 2 commits into
mainfrom
claude/neurophone-repo-setup-envzix

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Follow-up to the merged #154 (which landed the rand build-fix + CI re-pin). Continues
driving neurophone toward fully-proven / fully-engineered: issue disposition, QA +
security, proofs, RSR compliance, the estate Trustfile, and docs. Draft — actively in
progress
; this body tracks live state.

Landed so far

  • ci: remove retired scorecard-enforcer.yml — the standards governance staleness
    gate (check-workflow-staleness.sh) hard-errors on this legacy file and on its
    per-push-only SARIF upload to Code Scanning. The estate retired it in favour of
    scorecard.yml → standards scorecard-reusable.yml. Deleting it is how the running
    gate is satisfied (solutions at source). Verified: staleness check passes locally.
  • feat(build(#83): port NativeLib JNI to crates/neurophone-android (Rust) #110): real NativeLib JNI surface — the 6-line stub in
    crates/neurophone-android becomes the full 11-method ai.neurophone.NativeLib
    boundary from docs/migrations/JNI-SURFACE-AUDIT.adoc. jni 0.22 safe
    EnvUnowned::with_env (no unsafe code; panics caught at the boundary). Bridge logic
    is JVM-free and host-tested; reset consumes the core shutdown(self) typestate
    (Active→Down, once), wiring the resource-lifecycle property. Adds QueryRoute +
    query_routed + get_neural_context to core (non-breaking; query delegates).
    Gossamer-independent. Ground truth: 155 tests, clippy -D warnings clean, fmt clean.

In progress

  • Proofs (proof: first-principles proof-obligation map (foundations → non-trivial) #84): Lifecycle.cfg + TLC, trybuild use-after-shutdown, extend proptest;
    honest proofs/README.adoc + spectral_radius misnomer note.
  • Estate Trustfile (v2026.2.5-final) from the standards baseline.
  • RSR: substrate → canonical descriptiles/, GOVERNANCE.adoc, k9 validators.
  • Docs refresh (stale .claude/CLAUDE.md), STATE.a2ml, PMPL→MPL-2.0 correction.

FLAGS — external / owner-plane (cannot resolve here)

🤖 Generated with Claude Code

https://claude.ai/code/session_0172RBMz3qYjb1ttzD2i7RNh


Generated by Claude Code

claude added 2 commits July 1, 2026 11:14
The standards governance staleness gate (governance-reusable @7c9db0e running
scripts/check-workflow-staleness.sh) hard-errors on this file:

  ::error:: scorecard-enforcer.yml is retired. Use scorecard.yml -> standards
            scorecard-reusable.yml instead.
  ::error:: OSSF Scorecard must not upload SARIF to GitHub Code Scanning unless
            it runs for every PR head commit.

The estate has retired the hand-rolled enforcer in favour of the canonical
scorecard.yml -> standards scorecard-reusable.yml path (which runs Scorecard in
JSON mode and uploads an artifact, without pushing per-push-only SARIF into
Code Scanning). Deleting the legacy file is how the running governance gate is
satisfied — solutions at source, not a local patch. scorecard.yml (re-pinned to
7c9db0e) remains as the canonical Scorecard runner.

Verified: check-workflow-staleness.sh now reports "All workflow staleness checks
passed" against standards HEAD.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172RBMz3qYjb1ttzD2i7RNh
Turns the 6-line stub into the full 11-method JNI boundary specified in
docs/migrations/JNI-SURFACE-AUDIT.adoc (class `ai.neurophone.NativeLib`),
gossamer-independent — gossamer changes who loads the cdylib, not this ABI.

crates/neurophone-android:
  - lib.rs: 11 `#[unsafe(no_mangle)] extern "system"` exports (init, start,
    stop, isRunning, processSensor, query, queryLocal, queryClaude,
    getNeuralContext, getState, reset). Uses jni 0.22's safe `EnvUnowned::
    with_env` + `resolve::<ThrowRuntimeExAndDefault>()`, so no unsafe *code*
    (the crate is the sanctioned FFI boundary; the JNI export attribute is the
    sole reason it can't `forbid(unsafe_code)`). Panics are caught by with_env
    and never unwind across FFI.
  - state.rs: the JVM-free bridge — `OnceLock<Mutex<Option<RuntimeState>>>`
    holder + init/start/stop/process/query/reset. `reset` consumes the running
    system through the core `shutdown(self)` typestate (Active -> Down, dropped
    exactly once), wiring the resource-lifecycle property (#93/obligation 2.3)
    through the boundary.
  - sensor_map.rs: Android Sensor.TYPE_* id -> canonical name (moved out of the
    former Kotlin shim per the audit).
  - error.rs: JniBridgeError bridging jni + neurophone-core failures.
  - Cargo.toml: crate-type ["lib","cdylib"] so host `cargo test` runs the
    bridge tests; add thiserror; inherit license/authors/repository.

crates/neurophone-core:
  - Add `QueryRoute` {Auto, ForceLocal, ForceCloud} + `query_routed` +
    `select_model`; `query(msg, prefer_local)` now delegates, preserving the
    historical contract exactly. `queryLocal`/`queryClaude` need this hard
    routing that `prefer_local` alone cannot express.
  - Add `get_neural_context()` composing the LLM-context string from real
    SystemState fields (no invented salience).

Ground truth: cargo build/test OK (155 tests, +9), cargo clippy --all-targets
--workspace -- -D warnings clean, cargo fmt --check clean. Bridge logic is
host-tested (sensor map, full lifecycle, reset-preserves-state, bad-config).

Refs #110, #84 (2.3).

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

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath marked this pull request as ready for review July 1, 2026 11:31
@hyperpolymath
hyperpolymath merged commit c786bb2 into main Jul 1, 2026
30 of 32 checks passed
@hyperpolymath
hyperpolymath deleted the claude/neurophone-repo-setup-envzix branch July 1, 2026 11:31
hyperpolymath added a commit that referenced this pull request Jul 1, 2026
## Summary

Continues the neurophone hardening (follow-up to the merged #154, #156).
Two chunks:

### Proofs — honest staged path (#84)
- **2.1 lifecycle: TLC-model-checked.** Added `proofs/tla/Lifecycle.cfg`
+ a
`WorkBound` constraint; TLC now reports **"No error has been found"**
(13 states) —
`TypeOK`, `NoUseBeforeInit`, and the `NoUseAfterShutdown` property all
hold.
- **2.1 (type level) + 2.3 release-once: compile-fail verified.** Three
`compile_fail`
doc-tests on `NeuroSymbolicSystem` prove the typestate rejects
use-before-init,
use-after-shutdown, and double-shutdown — `cargo test` fails if any
starts compiling.
- **0.1 panic-freedom + 0.2 numeric containment** on the core
operational paths:
  `neurophone-core/tests/proptest_core.rs`.
- `proofs/README.adoc` rewritten to reflect reality
(property/checked/open), and
corrected: the `spectral_radius` misnomer is **already fixed** in `esn`
(power
iteration), so 1.1's precondition holds — only the formal contraction
proof remains.
- `Justfile`: `proof-tla` (fetches `tla2tools.jar`, self-skips without
java), `proof`,
  and the RSR `quality` gate.

### Estate Trustfile (owner's explicit ask)
- `.machine_readable/contractiles/trust/Trustfile.a2ml` upgraded from 23
lines to the
full **A2ML Trustfile v2026.2.5-final** baseline, specialised for
neurophone: threat
model for an on-device app, real seams, the honest 0.1–3.2
`PROOF_ARTIFACTS` map with
explicit `non_claims`, capability gateway, crypto-agility. Owner-only
crypto
(Ed448+Dilithium5 / SPHINCS+, hashes, transparency entries) left as
`{{PLACEHOLDER}}`.
- New SHA-pinned `.github/workflows/trustfile.yml` gate: structural lint
+ placeholder
policy (WARN on branches / ERROR on main) + integrity-hash drift report
+ runnable checks.

Ground truth: `cargo test` **160 pass**, `cargo clippy --all-targets --
-D warnings`
clean, `cargo fmt --check` clean; TLC verified locally.

## FLAGS — external / owner-plane (unchanged)
- `gossamer` + `conative-gating` clones remain **403-blocked** → #83
epic and #103 staged.
- OPEN obligations 1.1 / 1.2 (formal) / 2.2 / 3.1 residual — honest,
with completion paths.
- Owner fills the Trustfile `{{PLACEHOLDER}}` crypto at signing time.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_0172RBMz3qYjb1ttzD2i7RNh

---
_Generated by [Claude
Code](https://claude.ai/code/session_0172RBMz3qYjb1ttzD2i7RNh)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants