Skip to content

ASoC: apple: draft playback energy contract and ledger prototype - #495

Closed
RyanTheTide wants to merge 24 commits into
integration/aurorafrom
fix/playback-energy-gate
Closed

RyanTheTide wants to merge 24 commits into
integration/aurorafrom
fix/playback-energy-gate

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Playback energy gate design — integrated review draft

The sense PCM reports past output. This design limits future output by spending
finite per-speaker energy on private PCM copies at the ADMAC descriptor boundary.
The daemon issues grants from both thermal models and retains the V/I guard.
Unqualified routes and kernels without the contract keep conservative protection.
This is a draft, with qualification and acceptance work still outstanding.

Descriptor boundary and ownership

ADMAC copies each submitted period into coherent storage, runs the gate, orders
those writes, then publishes the finite hardware descriptor. The writable mmap
ring is never its source after publication. Every cyclic repeat spends again.
Eight private slots cover the four-entry FIFO, an active descriptor and report
lag. A slot is retained until its FIFO completion token retires exactly once.
Pool, report and accounting errors stop submission. A failed stop quarantines
the storage and channel rather than recycling DMA memory.

Macaudio prepares both playback front ends through the DMAengine adapter. Live
speaker/headphone mux and pin changes are excluded while any playback FE is
open. Shutdown must prove ADMAC quiescence even for an unfiltered headphone FE;
a failed or unsupported proof retains route exclusion and faults protection.
Restart requires prepare. Suspend revokes the grant before userspace freezes.
The AOP speaker path can use its existing DMAengine runtime, but firmware and
codec transforms require their own qualification; none is inferred from MCA.

Existing lock, grant ABI and epochs

The optional Speaker Energy Grant ALSA BYTES control has a fixed, versioned
512-byte little-endian layout. The same control file must own all volume and
amp-gain controls, Speaker Volume Unlock, and the grant control. No independent
unlock mechanism, module parameter or boot flag is added. DT supplies topology;
packaged profiles supply card identity, model constants and physical slot order.
J616's playback order differs from its profile order and is explicitly mapped.

A receipt contains the boottime epoch, grant sequence, format/rate/map, transfer
identifier, lifetime submitted/completed and source counters, safe refunds,
unbudgeted raw-prefix debt, absolute ceilings and per-speaker Q31 gains.
Owner/route/format changes cannot reuse permission. Ordinary DMA traffic does
not change the grant sequence: concurrent spending against the same absolute
ceiling cannot add credit. Grants and revocations change the nonce, so replay
fails. Invalid requests revoke; no arithmetic overflow becomes fresh credit.

A grant renews the existing volume lease/work, capped at an absolute deadline
no more than 250 ms away. Idle and suspend do not pause an energy deadline.
The old magic ping cannot extend it. Absent, expired or exhausted credit yields
the safe-level envelope. Already submitted copies retain their full heat debt;
completion or a proven stop retires them conservatively as possibly played.

While all hardware caps are proved safe, private copies may retain raw PCM.
Before raising any cap a grant must pay all still-pending raw copies atomically.
If unaffordable, admission installs protected-copy mode and returns EAGAIN
without unlocking; new protected copies replace the raw prefix as it drains.
A safe-epoch marker refunds a charged copy only if its entire lifetime was
provably below the safe hardware cap. Possible partial playback is never refunded.

Energy and thermal proof

Counters use Q20 normalized frames at a fixed reference rate of 48000 Hz;
rate epochs never reinterpret lifetime totals. S16_LE, S24_LE-in-32 and S32_LE
are normalized separately; output quantization goes toward zero before billing.
Transfer 1 meters squared amplitude and needs a complete certified energy norm.
Transfer 2 meters absolute amplitude and needs certified voltage/current bounds;
|V| Imax then covers arbitrary V/I phase. Source counters always meter squared
raw PCM for the existing source power budgets. These transfer identifiers are
contracts, not assertions that a particular amplifier has been qualified.

The production model charges integer differences completed - refunded once,
placing each uncertain increment at the latest possible time. Submitted but
uncompleted energy remains future heat debt. V/I has a separate observer that
may tighten the projection and retains the existing fault and ramp checks;
it cannot forgive queued energy or add the same output heat twice. Existing
state restore and clean-save gates remain in force; an active contract cannot
be silently dropped in favour of a less informed model.

For each positive two-node model, set b = Rm/taum and
k = max(Rc/tauc,b). Any nonnegative dose E has a future magnet increment at
most bE and a future coil increment at most kE. With indefinite safe power Ps,
use M = max(Tm,Ta+Ps*Rm) and C = max(Tc,M+Ps*Rc). Both M+bE and C+kE
must remain below their working ceilings with numerical margin. Pending energy,
remaining credit and every downstream residual tail must fit inside that dose.
The daemon replaces absolute ceilings and rounds additional credit downward.
It checks both nodes/models and delivered-energy windows before issuing credit.
This sufficient envelope is conservative; it does not establish a loudness pass.

Transfer qualification and fallback

TAS2764/TAS2770 helpers read back output gain, channel source, slots and HPF state.
They deliberately return no transfer certificate. The public TI datasheets give
gain equations and cutoff selectors, but do not specify the complete transient
energy norm and residual filter-state bound needed here:
TAS2764, section 8.4.2 and
TAS2770, section 8.4.3.
A cutoff alone is insufficient. No coefficients, firmware gains or speaker
constants are invented. Consequently this draft cannot authorize louder real
TAS output until an approved, complete bound is supplied and implemented.
Unknown profiles retain the existing conservative daemon/kernel behaviour.

Implementation uses public Linux sources and newly authored code. The shared
ledger/payload helpers and host adapter are dual GPL-2.0-only OR MIT; no existing
Linux driver or test was relicensed. No Apple implementation or tuning file,
recording, credential or private lab record is copied into public source.

Version 2 units and residual state

The unshipped ABI is now version 2 with Q20 normalized units. Ten years of
continuous full-scale input fit in the lifetime counters; Q30 could naturally
saturate within days. Per-sample billing still rounds upward and grants down.

The final 24 bytes carry immutable per-speaker tail_us bounds: residual
energy expressed as full-input-power-equivalent microseconds. Every grant,
power window and temperature projection reserves that debt. A qualified bound
must cover arbitrary prior input and allowed route/rate/gain/clock transitions,
including DSP state populated by safe-cached raw data before DVC. Ticket refunds
cannot erase that state. Unknown tails remain unqualified; the actual TAS
helpers still return NONE. No coefficients or bounds are guessed.

Required acceptance

KUnit exercises the ledger, payload ownership and actual macaudio control/trigger
handlers. A host wrapper of the same C core and payload helper supports immutable
queue simulations; it has no device access and cannot qualify a real transfer.
The 30,144 retained continuous cases, historical rows, 63 unchanged listening
replays and crash/stall/expiry tests must pass on the integrated source. Listening
metrics must include sample attenuation as well as control gain: <=1 dB and
exactly 0 dB on J616 at 30%/60%. No old test is waived or its limit raised.

The software validation described here used no hardware, speaker playback,
recording or deployment. Physical qualification requires its own approved
measurement procedure; no physical certificate is claimed by these results.
The orchestrator files the independent review after implementation and evidence.

Mandatory admission and composable grant bounds

Speaker/Speakers backends now require an enabled supported amplifier/layout
and a negative configured safe volume. The legacy unsafe parameter cannot
admit generic/unsupported backends, suppress protection setup errors or expose
fixed transforms. SPKR_NONE is refused. The independent small hardening PR is
Linux #510, against aurora-wip,
so it can be reviewed ahead of this energy-gate series.

Every daemon takeover retains an authenticated delivered-history envelope.
For either enabled window W, let C0 be the first kernel lifetime completed-
minus-refunded dose in joules, F the charged full-input power, and dt elapsed
boottime since that receipt. Pre-takeover dose still in the window is bounded
by min(C0,F*max(0,W-dt)). Grants subtract it in addition to new completions,
pending copies, downstream residual B and the joint safe baseline. This covers
clean restore, delayed qualification and repeated owners without trusting
source-history timing or resetting lifetime counters. The uncertainty ages
out independently at 1s and 60s; queued and residual debt remains.

The per-speaker certificate requires the joint baseline bound
P0 + F_certificate*g_fallback^p <= Ps for every applicable model and allowed
route/rate/gain/clock/owner/exhaustion epoch. Background and unbilled safe PCM
share one Ps reservation; they cannot each consume it. Paid PCM is charged in
full. Storage needs the uniform bound at every reachable boundary, mixed terms
and nonincreasing or separately paid epoch jumps. Unknown composition means
NONE. The current TAS helpers still return NONE; no physical certificate is
enabled by these changes or by the exact mathematical examples.

Validation and acceptance status

Fresh final software validation on the pinned committed source, using normal
buildbox resource admission (8 CPUs, 8 GiB, nice 10, offline locked dependencies,
network-disabled containers and no devices):

Check Result
Integrated KUnit 32/32 pass
Standalone admission KUnit (#510) 1/1 pass on exact driver/test files with retained UML dependencies
New takeover regressions / release build 3/3 pass / pass
Both repository exact-rational checkers PASS; 72 joint-baseline witnesses, 450 thermal-kernel examples, 152 windows, 16 paid storage cycles and 60 filter trajectories
Full standard suite 324 pass / 2 fail / 1 ignored, 327 selected; Cargo exit 101 retained
Explicit extended gate campaign 30,144 cases / 221,844 rows, zero failures; 14,251 synthetic-reference gated, 15,893 fallback
Retained counterexamples with gate 865 cases / 7,734 rows, zero failures; 189 reference gated, 676 fallback
Crash/owner-death, stalls, expiry, restart and failed stop Pass in the full software suite

The pre-fix generic-admission regression fails; the authenticated predecessor
ledger formerly permits 1.873119047230 J against 1 J and now gets zero new
credit
. Both window boundaries, late qualification, repeated owners, eventual
credit recovery and separate pending/refund debt pass. The old certificate
premise fails the new exact double-spend regression. The intermediate incorrect
new 60s fixture and canceled run remain preserved; the final complete run uses
the corrected committed fixture. No existing limit or original listening test
changed. These results qualify no physical amplifier, firmware or MMIO boundary.

The two strict ordinary-listening assertions remain required pending failures:
ordinary_quiet_programme_costs_at_most_one_db and
j616_ordinary_quiet_programme_has_zero_extra_attenuation. They retain the
600-second programme, 477 active measured seconds, native-word plus analogue
loss, <=1 dB generally and exact zero for J616 at 30%/60%. Neither is ignored,
expected-panic or waived. The default suite therefore remains red. The single
ignored extended continuous test is run separately, not counted as skipped
acceptance. A synthetic tighter transfer cannot be selected only for listening.

All 63 original sense-recording row identities remain retained. None of the
seven archives contains native queued playback; zero justified pre-DAC mappings
or valid integrated original-listening acceptance results currently exist.
Physical TAS2764/TAS2770/AOP transfer and uniform arbitrary-state/epoch/residual
qualification remains open. Prior 72 shared historical fallback rows passed;
two different-source older Neo rows remain explicitly unmatched. Neither a
finite probe nor a convenient inverse closes these requirements.

The task-ready follow-up packet asks the orchestrator to assign an independent
adversarial re-review of the three t-3270 corrections and retained boundaries.
It is a draft proposal, not a completed favourable review or acceptance.
No hardware request/access, speaker playback, microphone recording, deployment,
merge or protection weakening was performed by this continuation. Keep both
energy-gate PRs draft; the orchestrator owns review and deployment gating.

Companion draft: aurora-silicon/speakerguardd#21

Describe immutable descriptor submission, cumulative grants, queued debt and the safe exhaustion tail. Runtime wiring and acceptance remain prerequisites; no capability is advertised.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Bound normalized samples by per-speaker cumulative ceilings, retain queued energy through revocation and require single-use FIFO completions. Exercise expiry, stale renewals, shared slots, queue exhaustion and integer boundaries. Build only for KUnit; no playback adapter or userspace ABI is enabled.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Keep the previous rate and energy counters available for outstanding completion debt, but mark the mapping unusable until a successful reconfiguration. A fresh snapshot after a rejected route must not restore credit to the old physical mapping.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
…sion

Add an opt-in kernel-client playback filter at the actual finite-descriptor boundary. Copy each period into coherent storage, retain the copy through its completion report and spend again on every cyclic repeat. Stop on pool or accounting errors. Quarantine storage and the channel if stop cannot be proven, keeping unresolved energy debt. KUnit uses the production payload ownership helpers to cover mmap mutation, repeats, delayed completions, pool exhaustion and failed stop. No client has enabled the hook yet.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
…e lease

Add the versioned receipt and absolute-ceiling ABI, per-speaker PCM metering, safe-prefix admission and lifetime completion accounting. Reuse the existing owner and timeout authority. Exclude live route changes and require a proven ADMAC stop even on unfiltered headphone front ends. Read codec gain, source, HPF and slot state, retaining conservative protection when no qualified transfer bound exists. Exercise actual control/trigger handlers and preserve the STOP/refill fallback.

Assisted-by: LLM

Signed-off-by: Ryan Murray <[email protected]>
…the host

Build only newly authored dual-licensed accounting and payload sources against small host primitives. Expose the syscall receipt and immutable descriptor queue to daemon simulation tests without devices or driver registration. Preserve exact source hashes and reject mismatched vendored inputs. This reference plant is not a hardware transfer certificate.

Assisted-by: LLM

Signed-off-by: Ryan Murray <[email protected]>
…ransactions

Remove write access from fixed speaker ASI, HPF and OCE controls rather than relying on the ALSA INACTIVE UI hint. Keep headphone controls separate. Report a timed-out grant as ETIMEDOUT so userspace can reconcile a fresh receipt. Add handler regressions for both cases and match the host adapter timeout semantics.

Assisted-by: LLM

Signed-off-by: Ryan Murray <[email protected]>
…d-back

Reject a PDM source, diagnostic generator mode or bypassed HPF rather than treating the slot and gain registers as a valid PCM path. These read-back checks still do not supply a transfer certificate.

Assisted-by: LLM

Signed-off-by: Ryan Murray <[email protected]>
Hold gate-capable TAS paths at their existing safe caps until a qualified grant. Cover automatic jack/DAPM routes by excluding any open raw or stale front end from permission. Revoke at startup before DMA can run, expose REQUIRED separately from readiness and notify when prepare completes. Refuse unsupported PCM formats before publication. Fix the TAS2764 power-register symbol found by the buildbox compile and test raw-route grant refusal.

Assisted-by: LLM

Signed-off-by: Ryan Murray <[email protected]>
…n ABI v2

Replace the unshipped Q30 prototype with upward-rounded Q20 units, allowing over ten years of continuous full-scale input before counter saturation. Preserve fixed reference-rate normalization and downward grant rounding. Expose immutable per-speaker residual-state bounds in full-power-equivalent microseconds; an unknown bound still cannot qualify a transfer. The reservation covers state accumulated before DVC while safe-cached raw copies played. Test bound identity and the full-scale lifetime horizon.

Assisted-by: LLM

Signed-off-by: Ryan Murray <[email protected]>
Check the DT-derived slot range and uniqueness before indexing per-speaker residual bounds. Do not let an invalid map become transfer metadata.

Assisted-by: LLM

Signed-off-by: Ryan Murray <[email protected]>
A single Q20 energy unit permits a Q31 magnitude of 2^21. Retain the exact one-unit clamp and saturation assertions rather than the old Q30 amplitude literal caught by KUnit.

Assisted-by: LLM

Signed-off-by: Ryan Murray <[email protected]>
Retain the safe transfer qualification block and record the stricter J616 synthetic budget check. A necessary energy inequality shows why limiter tuning alone cannot close the current linear accounting gap.

Assisted-by: LLM

Signed-off-by: Ryan Murray <[email protected]>

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent adverse review: playback-energy gate

Reviewed Linux #495 at 7c8da6bf2a5e2e78cdfec511f1e5c78837499026 and speakerguardd #21 at 036f082bc4d78790c47f6a921f042a5b3fc68e13. Both advertised heads matched these pins and were draft when scope was established. The packet was an index, not evidence of correctness. This review reads the pinned implementation, ALSA ownership core, transfer argument, tests, and independently generated witnesses.

Disposition: the absolute safety requirements are not established. Findings below distinguish an inherited configuration bypass, a new takeover-accounting defect, and an insufficient certificate condition. The latter two concern reference/future qualified paths: the pinned real TAS helpers still return transfer NONE, so these are not claims of demonstrated over-temperature on a current physical TAS machine. No hardware, playback, recording, deployment, branch pushes, approvals, or request-changes reviews were performed.

Ranked findings

1. P1 — The inherited unsafe parameter can still create a speaker path with neither protection nor the energy gate

Scope: Linux; inherited from the PR base, not introduced by #495. It nevertheless violates this task's explicit “never disable speaker protection” and “no module parameter or boot flag may bypass qualification” requirements.

Code: parameter and transfer rejection, speaker-link admission, SPKR_NONE override, fallback configuration, safety/energy initialization.

Concrete failure scenario: a card matched only by apple,macaudio has a DT Speaker backend. Its fallback configuration has enable_speakers=false, AMP_NONE, SPKR_NONE, and safe_vol=0. With the existing please_blow_up_my_speakers value at least 2 when probing:

  1. The enable_speakers refusal is skipped and the speaker backend is included.
  2. The SPKR_NONE fixup returns success instead of refusing the card.
  3. safe_vol=0 leaves has_safety=false; consequently has_energy=false and energy_enforced=false.
  4. macaudio_vlimit_update() exits without limiting anything; energy prepare exits before attaching a filter. Raw playback therefore has no finite energy ceiling, deadline, owner/grant requirement, or conservative volume cap imposed by this driver.

A sustained full-scale programme can then exceed the thermal allowance of a speaker whose unrestricted dissipation is unsafe, with no driver thermal-budget governor to stop it. This needs an explicit privileged unsafe configuration; it is not an ordinary-user bypass of the default TAS route. It is still an executable counterexample to the stated absolute invariant. The same parameter also suppresses speaker-setup errors and permits unqualified SSM3515 configurations. I traced the generic fallback because it makes the complete absence of protection explicit, rather than assuming that making transfer qualification fail somehow protects every fallback.

Requested resolution: remove/refuse the unsafe speaker-admission override for configurations without an independently enforced protection path. Keep unsupported speaker backends disabled regardless of this parameter. Add a no-hardware regression for generic compatibility plus Speaker DT plus parameter 2. If the intended invariant is narrower than the task's absolute rule, that exception needs an explicit operator decision; this review does not grant it.

2. P1 — A new PlaybackModel forgets already-delivered energy still inside its 1s/60s windows

Scope: speakerguardd runtime; affects a qualified/reference contract when optional power limits are enabled. Current packaged TAS profiles have no enabled power windows and the real TAS transfer remains NONE; J700's reference fixture supplies a useful reproducer, not a claim that the pinned real J700 has this gate.

Code: constructor history initialization, initial source-history envelope, grant-window calculation, takeover, legacy grant authority, unified adoption.

new() copies the current lifetime receipt to last and starts delivered empty. initial retains the old means, but initial_energy() is used only for source means. packet() subtracts only window(delivered), pending energy, background and the tail. Completed energy before the first receipt therefore occupies no delivered window. Subsequent integer deltas cannot recover it because the predecessor's completed total is already the baseline. Retaining temperatures, raw source means, or lifetime counters alone does not retain this window occupancy. The legacy scalar reduction is explicitly set to zero in playback mode; unified adoption similarly makes the finite grant authoritative.

Concrete failure scenario: a predecessor has just delivered approximately 1 J under a 1 W / 1 s limit. It completes all descriptors and makes a clean stop; a normal half-second drain still leaves that dose inside the next process's one-second window. Temperatures can be comfortably below both thermal ceilings. The successor restores the recent source history, sees the nonzero lifetime completion counters, then constructs a fresh PlaybackModel. Its delivered window is empty, so it grants another 0.873119047425 J in the synthetic J700-derived fixture. Both bursts can finish within the same one-second window, admitting about 1.873 J against 1 J. The same initialization defect applies independently to the 60 s window. This finding is a rolling energy-budget violation; it does not by itself demonstrate crossing a coil-temperature hard limit.

Independent reproduction: tests/authenticated-history.rs completes the predecessor's immutable payloads through the exact vendored C ledger/payload helper, changes owner, initializes the actual Rust model with retained source history and bounded temperatures, then asserts the old plus newly granted dose fits the window. Only a private test module is appended to a separate copy; production files and thresholds are untouched. A simpler constructor witness is in tests/adverse-model-tests.rs. Execution results are recorded below.

Requested resolution: seed a conservative delivered-history envelope on every takeover, including clean restore and delayed initial qualification. Use authenticated delivered history if available; otherwise use a justified conservative bound, such as retained raw history where its relation to delivered dose is proven, or block new credit until the uncertainty ages out. Include both 1 s and 60 s boundaries, nonzero completed counters, clean restarts and repeated takeovers in the regression. Do not fix this by resetting lifetime counters or dropping queued/residual debt.

3. P2 — The stated background condition spends the same safe-power allowance twice for unbilled fallback PCM

Scope: both repositories' certificate argument and its composition with the kernel/daemon. This is a conditional admission/proof defect, not an enabled physical certificate.

Code: kernel zero-cost fallback rule, daemon's sole safe-power allowance, baseline integration, and the duplicated condition in Linux certificate / daemon certificate.

The proposed certificate permits w + delta V <= P0 + F*|x|^p per unit time and requires only P0 <= Ps. But the ledger assigns zero cost to every word at or below the fallback amplitude, while the daemon's baseline is already Ps = F_driver*g_fallback^p. Thus Ps is simultaneously being used to cover the unbilled signal and an additional background up to Ps. The certificate's summation-by-parts proof is valid for its chosen supply; that supply has not been bounded by the amount actually billed plus the single reserved baseline.

Concrete mathematical counterexample: take transfer 1, F=F_driver=1 W, fallback amplitude g=0.1, Ps=P0=0.01 W, no state (V=B=0), and full-scale source reduced to the fallback amplitude. A stateless plant with w=P0+F*x^2=0.02 W satisfies the displayed storage inequality and explicit P0 condition exactly. The kernel bills zero for that input; the model reserves only 0.01 W indefinitely. For ambient 50 C, positive thermal resistances Rc=4000 K/W, Rm=2000 K/W, and time constants 1 s / 2 s, the reserved equilibrium is 110 C, below a 140 C working ceiling, whereas the permitted plant approaches 170 C and crosses a 150 C hard limit. There is no finite residual reserve that covers a persistent missing 0.01 W. These are newly authored mathematical constants, not measured speaker properties. Quantizing the fallback amplitude downward by a native-word step leaves a strict gap.

Independent reproduction: tests/background-counterexample.py checks the supply inequality and background condition with exact rationals and evaluates the independent closed-form thermal trajectory. An additional native-descriptor checker is prepared in tests/background-native.py, but was canceled while waiting for resource admission and is unexecuted. I do not claim a native-word execution or full production-daemon replay for this finding. The original checker explicitly uses P0=0, so passing it does not test this composition case.

Requested resolution: require a joint bound on the full supply in every unbilled mode, including digitally reduced words, safe-cached raw data under hardware caps and refunded tickets. For the simple stateless case this needs P0 + F_certificate*g_fallback^p <= Ps, not merely P0 <= Ps. Alternatively bill every signal contribution and reserve background separately, or reduce the exempt envelope to leave proven background headroom. The bound must hold at both models and through expiry/clock/route epochs. Keep real transfer NONE until that combined bound and the other physical obligations are satisfied.

Other required acceptance blockers

The pinned production helpers explicitly leave state.transfer=0 after zero-initializing their structures: TAS2764 at lines 591–622 and TAS2770 at 623–646. has_energy immediately implies energy_enforced; transfer NONE prevents the legacy magic ping from lifting those caps. This is appropriate fail-closed behavior and also means no louder real TAS/AOP path has been qualified by these PRs.

The two ordinary listening assertions remain required failures, not waivers: ordinary_quiet_programme_costs_at_most_one_db and j616_ordinary_quiet_programme_has_zero_extra_attenuation. Neither is ignored or expected-panic. The source retains the strict limits and accounts for native-word attenuation. No independent physical certificate or justified native reconstruction of the original 63 sense-only replays was available here. I did not replace those inputs, accept a convenient inverse, or treat synthetic coefficients as physical qualification. These known blockers remain separate from the three findings above.

Review coverage and bounded conclusions

Boundary Independently inspected result
DMA input / repeats ADMAC publishes the private copy after dma_wmb; each cyclic publication invokes the filter again. FE runtime source address, buffer and period sizes must match. Both playback FEs have the machine ops; backends are no_pcm. No writable-ring bypass found on an enforced, prepared route.
Completion / stop FIFO ticket order is checked; invalid/duplicate reports cannot retire an arbitrary ticket. Pending debt is retained until completion or conservatively retired after a proven stop. Failed stop quarantines private storage/channel and retains route exclusion. MMIO quiescence behavior was reviewed as code, not physically validated.
Grants / races Absolute ceilings, integer deltas, one ledger spinlock and epoch/sequence matching avoid credit top-ups from concurrent DMA. Invalid/stale writes revoke. An EAGAIN raw prefix remains under hardware caps while protected copies replace it.
Expiry / crash / stall Per-copy admission tests absolute boottime; pre-admitted copies keep full debt. The legacy ping is capped by the same deadline, idle does not pause the enforced deadline, suspend revokes, and owner close revokes in either control-release order. No additional default-route energy escape found here.
Gain / route / clock epochs Live userspace mux/pin changes require no open FE; readiness excludes raw headphone FEs from raised speaker caps. Fixed transform controls lose WRITE access. Rate/format changes reconfigure/revoke and cannot reinterpret live tickets. Residual/clock/transition obligations are still physical prerequisites, not proved by a new nonce.
Integer / format / rate Q20 sample costs round upward, grant conversions downward, quantization toward zero. S16/S24-container/S32 signs and full-scale negative endpoint are handled. Maximum sample/rate/queue products fit u64; lifetime source overflow fails closed. Actual five shared C/header files match the pinned Linux tree byte-for-byte. No overflow that mints credit found.
Ownership / second daemon ALSA serializes locks and writes with controls_rwsem; foreign control-file owners get EBUSY/EPERM. The grant requires the unlock/volume/amp-gain controls to share one file owner. The service adds no competing governor process and does not stop speakersafetyd to make room. The cloned internal sense monitor can tighten temperatures; it is not a second governing daemon. This is a code review of normal separately opened daemon instances, not a claim that trusted processes cannot intentionally share a file descriptor.
Thermal / residual proof Independently checked the positive two-node impulse envelope, both-node constraints, common-storage/paid-epoch requirement, and unimodal-kernel positive-variation argument. The background-to-ledger composition fails as in finding 3; missing delivered takeover history is not repaired by the residual proof.

A candidate initial-receipt timing witness is retained as a failed assertion in the private tests. It shows that the published state does not integrate an arbitrary initial safe-power interval. I do not count it as another demonstrated thermal escape: the grant constraint independently takes the maximum with the indefinite safe equilibrium, and ordinary startup writes minimum gain before takeover. This distinction avoids promoting a diagnostic underestimate into an unsupported over-temperature claim.

Independent execution and retained evidence

  • Exact published daemon: cargo test --offline --locked --release -j8 -- --nocapture --test-threads=4 exited 101: 321 passed, 2 failed, 1 ignored, 324 selected. The failures are exactly the two strict listening markers. The full log is evidence/logs/exact-suite.txt; command/exit receipts are in commands.json. This is a fresh independent run, not the author's retained result.
  • Exact public mathematical checker: python3 tools/check-transfer-contract.py exited 0. Its finite synthetic examples do not establish physical qualification or test nonzero background composition.
  • Independent constructor tests: two selected assertions failed, Cargo exit 101. The confirmed history witness reports prior=1.000000000000 J, additional=0.873119047425 J; the separate initial-clock diagnostic candidate is explicitly not promoted to a safety finding. Complete log: evidence/logs/adverse.txt.
  • Independent predecessor-ledger regression: one selected assertion failed, Cargo exit 101: previous_completed=0.999999999806 J, additional=0.873119047425 J, total=1.873119047230 J, limit=1 J. Complete log: evidence/logs/authenticated.txt.
  • Independent background witness: exact-rational premises and closed-form counterexample checks exited 0. It reports 110 C reserved equilibrium versus 170 C permitted-plant equilibrium; at 10 s the independent coils are 109.729574121441 C and 169.459148242883 C. Complete log: evidence/logs/background.txt.
  • Optional native-descriptor witness: canceled before obtaining a build slot; not executed, not a pass. Its prepared script is retained, together with evidence/native-job-disposition.json. The exact-rational background witness above did execute; the zero-cost C predicate was independently read in the pinned source.
  • I did not freshly run KUnit, a bootable-kernel/AOP build, the ignored extended 30,144-case campaign, the historical archive matrix, or the original 63-replay gate. I inspected their source/claims but do not adopt the author's pass counts as independent execution.

The exact daemon source is archived from its Git commit with no overlay. Independent regressions run in separate source and Cargo target directories. The host library uses the dual-licensed exact ledger and immutable payload helper; it does not exercise actual MMIO or qualify amplifiers. Builds/tests use normal buildslot admission, 8 CPUs, 8 GiB, nice 10, offline locked dependencies, no device mounts and no container network. No hardware requests were made.

Local evidence index: evidence/*-scope.json, *-pr-start.json, reviewed-source-sha256.json, kernel-vendor-comparison.json, test-input-manifest.json, review-command-notes.md, the complete exported execution logs, and tests/ with the independent fixtures/runners. The initial archive/diff setup failures are retained. No reviewed branch or author worktree was edited. No source fix is part of this review; consequently no implementation rollback is required, and all failing witnesses are preserved. The report and findings are review results only; follow-up proposals are drafts for the operator, with no automatic acceptance or deployment authorization.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent re-review of d3c3cdd1dc9d3444c63e74ec7d12c590336706c8, composed with speakerguardd #21 at f5c5f593ba8ab244a3ce800be9035496eabcdb4d.

The original three findings are corrected in the relevant code:

  • Unsupported speaker admission is independent of the unsafe parameter. Exact production predicates/configs admit J316/J413/J700/J616 at parameter 0 and refuse fallback/SSM/NONE/zero-safe-level cases. The remaining parameter use refuses transfer qualification; it does not disable enforced caps.
  • The daemon now retains pre-takeover completed-minus-refunded lifetime dose conservatively in both 1 s and 60 s windows, anchored to the first authenticated receipt. New completions, pending debt and residual reserve remain separate.
  • The certificate now requires P0 + F_certificate * g_fallback^p <= Ps. Free PCM shares the single baseline; paid PCM is charged in full. The original p=2 background counterexample is rejected by the corrected checker. Its tests cover both metrics and nonzero background/headroom; the executable checker code matches the daemon's.

Independent execution: exact daemon suite 324 passed, 2 failed, 1 ignored (exit 101), with only the two unchanged strict listening assertions failing. The unchanged original history reproducer now fails its assumption that a fresh grant exists; a separate no-grant-aware copy passes with 0.999999999806 J prior + 0 J new credit. Added authentic-ledger cases pass for both 1 s and 60 s, clean stop, delayed qualification, repeated owners, residual reserve and window boundaries. The original background witness still demonstrates the old premises; the corrected checker and an independent free/paid composition test reject it and pass. No thresholds were relaxed.

A separate P1 remains in standalone #510: its HPF deactivation only sets INACTIVE, leaving direct ALSA writes possible. This #495 head includes macaudio_energy_fixed_controls() to remove WRITE for its gate-capable speaker routes, including J616. That protection must also reach the standalone #510 fix; merely making deactivation unconditional is insufficient. A host-only witness from #510's exact ALSA functions changes the in-memory HPF from enum 6 (800 Hz) to 0 (Disabled) with access=0x103; removing WRITE produces EPERM.

This closes the reviewed admission/history/background defects in their relevant implementations, not broader acceptance: real TAS transfer helpers remain NONE, and physical qualification plus the strict listening/replay gates are still outstanding. No new credit bypass found in the correction diff. Comment-only review; no hardware, playback, source changes or pushes.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Closing as superseded (merge train MTR, 06/11). Speaker protection is moving to speakerguardd v2, the in-graph clean-room spp3/lsm2/atsp implementation. Its kernel side is #922 on sgv2-kernel-interface, cut over on every Mac at once (option A), with no kernel energy ledger and no per-board grant path. This prototype and its Neo port have no place in that design. The branch stays, so it can be reopened if any of it is needed.

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.

1 participant