[FEATURE] Audit and refactor authority, lifecycle and code quality across every repository #2

Open
opened 2026-09-12 07:56:22 +02:00 by erikinkinen · 0 comments
Owner

Problem and motivation

Compatibility and self-hosting expand the number of clients and lifecycle paths. Existing ambient, residual or oversized explicit authority, obsolete APIs and duplicated or oversized code must be removed continuously across the complete codebase.

Proposed behavior and scope

Maintain an evidence-backed finding register and a closure record for every repository. Audit capability origin, delegation, revocation, parsing, unsafe code, build scripts, production/test boundaries and measured costs; migrate callers while deleting superseded paths and refactor every authored code file below 1,000 physical lines.

This issue records planned work; its unchecked criteria are not implementation proof. The normative basis is Phase 6 and AC1–AC24.

Authority, security and reliability

Review success, partial failure, cancellation, timeout, crash and identifier reuse. Preserve exact live object identity, caller-specific error precedence and cleanup uncertainty handling. Shared libraries must remain authority-free; performance changes cannot cache authorization success or broaden grants.

Apply the priority order: security, reliability, then performance. Keep suspected vulnerabilities in the repository’s restricted SECURITY.md reporting channel.

Acceptance criteria

  • Create an audit register keyed by stable finding ID, repository, file/symbol,
    category, severity, exact revision, invariant, reproduction, remediation owner, regression
    test, status and closure evidence.
  • Inventory every startup/runtime capability: origin, receiving principal, object,
    operations, delegation ceiling, lifetime and all aliases. Include boot handoff, service
    registration, compatibility realms and tools.
  • Find ambient authority from global selectors, default service discovery,
    cwd/PATH/env, numeric slots/PIDs, implicit devices, inherited routes, host filesystem
    fallbacks and cache metadata; replace it with explicit grants.
  • Find residual authority after success, error, cancellation, interruption, timeout,
    restart, failed reply/transfer, fork, exec and teardown. Prove every alias is retired or its
    necessary retention is documented.
  • Find unwanted explicit authority: oversized startup inventories, broad
    provider/admin endpoints, duplicate aliases, unnecessary read/write/exec rights and debug
    routes. Attenuate/remove it even when technically explicit.
  • Audit generation reuse, replay, stale pending replies, confused deputy paths,
    endpoint impersonation and TOCTOU around path/object resolution. Test forged descriptive
    identity without the corresponding capability.
  • Audit cleanup failure behavior: attempt independent retirements, preserve existing
    caller-specific error precedence, including cleanup uncertainty overriding the triggering
    error, and quarantine/terminate when required; never continue serving with an unaccounted
    grant.
  • Audit unsafe code, FFI, wire parsing, range arithmetic, initialization, lifetimes,
    locks, interruption and publication order; give each unsafe block an exact safety argument and
    adversarial test where practical.
  • Inventory redundant implementations, dead/fallback code, duplicated validators,
    obsolete wrappers and deprecated public/wire APIs with all callers.
  • Migrate callers and remove deprecated APIs/compatibility shims in coordinated
    signed graphs; test rejection of retired versions without silent permissive fallback. Do not
    retain an obsolete API solely to avoid caller edits.
  • Classify every hard-coded size/count/depth/time restriction as ABI, hardware,
    explicit resource policy or accidental implementation limit. Replace accidental limits with
    checked caller-sized storage or authorized allocation.
  • Test above every removed old boundary and at exact allocation/ABI boundaries;
    preserve resource exhaustion errors, denial-of-service protection and mandatory bounded waits
    instead of interpreting “no arbitrary limits” as “unlimited resources”.
  • Inventory all authored code files at/over 1,000 physical lines, including tests,
    scripts and generated-source templates. Refactor them into cohesive modules below 1,000 lines,
    preserving meaningful APIs and tests.
  • Add a deterministic tracked-source size gate; exclude only genuine non-code
    data/external payload archives, not large authored tests or fixtures containing executable
    logic. Split generators and their generated code too.
  • Audit production versus integration/dev-only feature gating and linked symbols.
    Move/delete remaining test orchestration/diagnostics from production rootd; carry every
    retained move/delete classification to closure.
  • Re-measure rootd semantic surface using the maintained baseline tooling; compare
    same-toolchain code size, imports, unsafe blocks, accepted messages and authority inventory,
    not incomparable historical LoC estimates.
  • Audit bootstrap service ownership and release/development authority parity; prevent
    new compatibility work from adding policy or routine test orchestration back into rootd.
    initd/bootd-style work stays Phase 7.3.
  • Audit all performance findings through integration#3 evidence before changing algorithms;
    deduplicate measured hot paths without caching successful access checks, broadening grants or
    leaving invalidatable state unowned.
  • Audit build/CI scripts for secret exposure, mutable shared outputs, symlink
    escapes, unsafe deletion, unbounded subprocesses, silent warning suppression and accidental
    host dependencies.
  • Repeat the entire audit on final heads, independently review all security closures,
    and require zero unresolved in-scope authority, deprecated API, undocumented-code and
    over-1k-code findings before Phase 6 acceptance.
  • Inventory obsolete planning/migration documents, manifests, scripts, CI jobs,
    feature flags and migration-only tests, including dynlink migration checks and the superseded
    local planning archive. Preserve necessary evidence in historical artifacts/issues, then
    delete obsolete active files and references; retain current specifications and security
    assertions, not obsolete scaffolding.
  • Remove superseded static executable intake from every public launch, loader,
    policy, configuration and test path now replaced by dynlink intake. Map each former useful
    assertion to maintained coverage, reject retired input, and preserve genuinely required
    mount/bootstrap mechanisms with explicit scope. Inspect real consumers: a shared segment type
    used by dynamic materialization or the EFI loader's pre-runtime boot contract is not removed
    by name alone.
  • Audit symbols, filenames, flags, wire names and diagnostic tokens for
    milestone terminology; replace milestone-based naming with semantic responsibility
    names and update all consumers/tests atomically. Allow useful historical comments/docs and
    real algorithmic concepts, not executable planning APIs hidden behind an exception.
  • Review code navigation, naming, control flow, error paths, module cohesion and
    inline explanations with a contributor/auditor walkthrough; merge semantically similar files
    where useful while staying below 1,000 lines.
  • Identify repeated behavior across repositories suitable for an authority-free
    shared library; document genuine common semantics, variation, dependencies and boundaries
    before extracting it. Do not abstract merely similar syntax or combine unrelated trust
    domains.
  • For each justified extraction, create a new Forgejo repository from meta first,
    clone/branch it, implement documented/tested shared APIs, migrate callers, remove duplicates,
    and add catalog/CI/manual/man-page/audit/PR entries. Add explicit checklist rows for every
    resulting repository and use exact dependency commit pins without circular service/library
    dependencies.

Repository audits are linked below. Each audit includes authority and code quality, inline documentation, relevant tests and current-revision CI. Each audit requires its own acceptance evidence.

For each implementation slice, retain actual formatting, strict Clippy, unit/doctest and warning-denied build results for all altered Rust repositories and valid configurations. Add relevant runtime VM coverage, monitor older unit/VM regressions in exact-head CI, and update canonical component documents and affected technical-manual/API material. Every authored code file must remain below 1,000 physical lines, with meaningful inline documentation and missing_docs enforcement in Rust crates.

Alternatives and tradeoffs

Inventory alone does not close a finding, and broad exemptions for small libraries or tooling conceal real boundaries. Prefer cohesive thematic modules and genuine shared semantics over arbitrary fragmentation or generic abstraction.

Repository audit issues

Tracking and rollout

Dependencies: meta#2

Dependencies identify required contracts and closure gates; preparatory inventory/design can proceed in parallel under one owner per edited file. Link bounded implementation issues and their PRs here before claiming acceptance. Use feature/posix-compat, regular signed commits in the canonical contribution format, and WIP PRs linked to the exact coherent component graph. All cross-repository Cargo/catalog selections and CI helpers use full 40-character lowercase commit hashes, including transitive dependencies; do not substitute branch, tag or implicit HEAD selection.

Close criteria only with their own reviewed deliverables and validation evidence. Pending, skipped, cancelled, failed or predecessor-only results remain distinct. Keep main images unchanged until explicit promotion direction; technical completion does not authorize merges, release tags or publication.

## Problem and motivation Compatibility and self-hosting expand the number of clients and lifecycle paths. Existing ambient, residual or oversized explicit authority, obsolete APIs and duplicated or oversized code must be removed continuously across the complete codebase. ## Proposed behavior and scope Maintain an evidence-backed finding register and a closure record for every repository. Audit capability origin, delegation, revocation, parsing, unsafe code, build scripts, production/test boundaries and measured costs; migrate callers while deleting superseded paths and refactor every authored code file below 1,000 physical lines. This issue records planned work; its unchecked criteria are not implementation proof. The normative basis is [Phase 6 and AC1–AC24](https://git.erikinkinen.fi/erix/docs/src/branch/main/phases/6.md). ## Authority, security and reliability Review success, partial failure, cancellation, timeout, crash and identifier reuse. Preserve exact live object identity, caller-specific error precedence and cleanup uncertainty handling. Shared libraries must remain authority-free; performance changes cannot cache authorization success or broaden grants. Apply the priority order: security, reliability, then performance. Keep suspected vulnerabilities in the repository’s restricted SECURITY.md reporting channel. ## Acceptance criteria - [ ] Create an audit register keyed by stable finding ID, repository, file/symbol, category, severity, exact revision, invariant, reproduction, remediation owner, regression test, status and closure evidence. - [ ] Inventory every startup/runtime capability: origin, receiving principal, object, operations, delegation ceiling, lifetime and all aliases. Include boot handoff, service registration, compatibility realms and tools. - [ ] Find ambient authority from global selectors, default service discovery, cwd/PATH/env, numeric slots/PIDs, implicit devices, inherited routes, host filesystem fallbacks and cache metadata; replace it with explicit grants. - [ ] Find residual authority after success, error, cancellation, interruption, timeout, restart, failed reply/transfer, fork, exec and teardown. Prove every alias is retired or its necessary retention is documented. - [ ] Find unwanted explicit authority: oversized startup inventories, broad provider/admin endpoints, duplicate aliases, unnecessary read/write/exec rights and debug routes. Attenuate/remove it even when technically explicit. - [ ] Audit generation reuse, replay, stale pending replies, confused deputy paths, endpoint impersonation and TOCTOU around path/object resolution. Test forged descriptive identity without the corresponding capability. - [ ] Audit cleanup failure behavior: attempt independent retirements, preserve existing caller-specific error precedence, including cleanup uncertainty overriding the triggering error, and quarantine/terminate when required; never continue serving with an unaccounted grant. - [ ] Audit unsafe code, FFI, wire parsing, range arithmetic, initialization, lifetimes, locks, interruption and publication order; give each unsafe block an exact safety argument and adversarial test where practical. - [ ] Inventory redundant implementations, dead/fallback code, duplicated validators, obsolete wrappers and deprecated public/wire APIs with all callers. - [ ] Migrate callers and remove deprecated APIs/compatibility shims in coordinated signed graphs; test rejection of retired versions without silent permissive fallback. Do not retain an obsolete API solely to avoid caller edits. - [ ] Classify every hard-coded size/count/depth/time restriction as ABI, hardware, explicit resource policy or accidental implementation limit. Replace accidental limits with checked caller-sized storage or authorized allocation. - [ ] Test above every removed old boundary and at exact allocation/ABI boundaries; preserve resource exhaustion errors, denial-of-service protection and mandatory bounded waits instead of interpreting “no arbitrary limits” as “unlimited resources”. - [ ] Inventory all authored code files at/over 1,000 physical lines, including tests, scripts and generated-source templates. Refactor them into cohesive modules below 1,000 lines, preserving meaningful APIs and tests. - [ ] Add a deterministic tracked-source size gate; exclude only genuine non-code data/external payload archives, not large authored tests or fixtures containing executable logic. Split generators and their generated code too. - [ ] Audit production versus integration/dev-only feature gating and linked symbols. Move/delete remaining test orchestration/diagnostics from production rootd; carry every retained move/delete classification to closure. - [ ] Re-measure rootd semantic surface using the maintained baseline tooling; compare same-toolchain code size, imports, unsafe blocks, accepted messages and authority inventory, not incomparable historical LoC estimates. - [ ] Audit bootstrap service ownership and release/development authority parity; prevent new compatibility work from adding policy or routine test orchestration back into rootd. `initd`/bootd-style work stays Phase 7.3. - [ ] Audit all performance findings through [integration#3](https://git.erikinkinen.fi/erix/integration/issues/3) evidence before changing algorithms; deduplicate measured hot paths without caching successful access checks, broadening grants or leaving invalidatable state unowned. - [ ] Audit build/CI scripts for secret exposure, mutable shared outputs, symlink escapes, unsafe deletion, unbounded subprocesses, silent warning suppression and accidental host dependencies. - [ ] Repeat the entire audit on final heads, independently review all security closures, and require zero unresolved in-scope authority, deprecated API, undocumented-code and over-1k-code findings before Phase 6 acceptance. - [ ] Inventory obsolete planning/migration documents, manifests, scripts, CI jobs, feature flags and migration-only tests, including dynlink migration checks and the superseded local planning archive. Preserve necessary evidence in historical artifacts/issues, then delete obsolete active files and references; retain current specifications and security assertions, not obsolete scaffolding. - [ ] Remove superseded static executable intake from every public launch, loader, policy, configuration and test path now replaced by dynlink intake. Map each former useful assertion to maintained coverage, reject retired input, and preserve genuinely required mount/bootstrap mechanisms with explicit scope. Inspect real consumers: a shared segment type used by dynamic materialization or the EFI loader's pre-runtime boot contract is not removed by name alone. - [ ] Audit symbols, filenames, flags, wire names and diagnostic tokens for milestone terminology; replace milestone-based naming with semantic responsibility names and update all consumers/tests atomically. Allow useful historical comments/docs and real algorithmic concepts, not executable planning APIs hidden behind an exception. - [ ] Review code navigation, naming, control flow, error paths, module cohesion and inline explanations with a contributor/auditor walkthrough; merge semantically similar files where useful while staying below 1,000 lines. - [ ] Identify repeated behavior across repositories suitable for an authority-free shared library; document genuine common semantics, variation, dependencies and boundaries before extracting it. Do not abstract merely similar syntax or combine unrelated trust domains. - [ ] For each justified extraction, create a new Forgejo repository from `meta` first, clone/branch it, implement documented/tested shared APIs, migrate callers, remove duplicates, and add catalog/CI/manual/man-page/audit/PR entries. Add explicit checklist rows for every resulting repository and use exact dependency commit pins without circular service/library dependencies. Repository audits are linked below. Each audit includes authority and code quality, inline documentation, relevant tests and current-revision CI. Each audit requires its own acceptance evidence. For each implementation slice, retain actual formatting, strict Clippy, unit/doctest and warning-denied build results for all altered Rust repositories and valid configurations. Add relevant runtime VM coverage, monitor older unit/VM regressions in exact-head CI, and update canonical component documents and affected technical-manual/API material. Every authored code file must remain below 1,000 physical lines, with meaningful inline documentation and missing_docs enforcement in Rust crates. ## Alternatives and tradeoffs Inventory alone does not close a finding, and broad exemptions for small libraries or tooling conceal real boundaries. Prefer cohesive thematic modules and genuine shared semantics over arbitrary fragmentation or generic abstraction. ### Repository audit issues - [blockd#1](https://git.erikinkinen.fi/erix/blockd/issues/1): `blockd` - [boot-tool#1](https://git.erikinkinen.fi/erix/boot-tool/issues/1): `boot-tool` - [bootloader#2](https://git.erikinkinen.fi/erix/bootloader/issues/2): `bootloader` - [coreutils#1](https://git.erikinkinen.fi/erix/coreutils/issues/1): `coreutils` - [crashd#1](https://git.erikinkinen.fi/erix/crashd/issues/1): `crashd` - [deviced#1](https://git.erikinkinen.fi/erix/deviced/issues/1): `deviced` - [docs#2](https://git.erikinkinen.fi/erix/docs/issues/2): `docs` - [drv-acpi#1](https://git.erikinkinen.fi/erix/drv-acpi/issues/1): `drv-acpi` - [drv-i8042#1](https://git.erikinkinen.fi/erix/drv-i8042/issues/1): `drv-i8042` - [drv-ps2-keyboard#1](https://git.erikinkinen.fi/erix/drv-ps2-keyboard/issues/1): `drv-ps2-keyboard` - [drv-ps2-mouse#1](https://git.erikinkinen.fi/erix/drv-ps2-mouse/issues/1): `drv-ps2-mouse` - [drv-rtc-cmos#1](https://git.erikinkinen.fi/erix/drv-rtc-cmos/issues/1): `drv-rtc-cmos` - [drv-serial#1](https://git.erikinkinen.fi/erix/drv-serial/issues/1): `drv-serial` - [drv-virtio-block#1](https://git.erikinkinen.fi/erix/drv-virtio-block/issues/1): `drv-virtio-block` - [dynlinkd#2](https://git.erikinkinen.fi/erix/dynlinkd/issues/2): `dynlinkd` - [e2fsd#1](https://git.erikinkinen.fi/erix/e2fsd/issues/1): `e2fsd` - [exsh#2](https://git.erikinkinen.fi/erix/exsh/issues/2): `exsh` - [extop#1](https://git.erikinkinen.fi/erix/extop/issues/1): `extop` - [fatd#1](https://git.erikinkinen.fi/erix/fatd/issues/1): `fatd` - [fbcond#1](https://git.erikinkinen.fi/erix/fbcond/issues/1): `fbcond` - [hotplugd#1](https://git.erikinkinen.fi/erix/hotplugd/issues/1): `hotplugd` - [inputd#1](https://git.erikinkinen.fi/erix/inputd/issues/1): `inputd` - [integration#11](https://git.erikinkinen.fi/erix/integration/issues/11): `integration` - [irqd#1](https://git.erikinkinen.fi/erix/irqd/issues/1): `irqd` - [kernel#2](https://git.erikinkinen.fi/erix/kernel/issues/2): `kernel` - [keyd#1](https://git.erikinkinen.fi/erix/keyd/issues/1): `keyd` - [launchd#1](https://git.erikinkinen.fi/erix/launchd/issues/1): `launchd` - [lib-aes#1](https://git.erikinkinen.fi/erix/lib-aes/issues/1): `lib-aes` - [lib-block#1](https://git.erikinkinen.fi/erix/lib-block/issues/1): `lib-block` - [lib-bootimg#1](https://git.erikinkinen.fi/erix/lib-bootimg/issues/1): `lib-bootimg` - [lib-bootstrap#1](https://git.erikinkinen.fi/erix/lib-bootstrap/issues/1): `lib-bootstrap` - [lib-capabi#1](https://git.erikinkinen.fi/erix/lib-capabi/issues/1): `lib-capabi` - [lib-cli#1](https://git.erikinkinen.fi/erix/lib-cli/issues/1): `lib-cli` - [lib-console#1](https://git.erikinkinen.fi/erix/lib-console/issues/1): `lib-console` - [lib-constant-time#1](https://git.erikinkinen.fi/erix/lib-constant-time/issues/1): `lib-constant-time` - [lib-crc#1](https://git.erikinkinen.fi/erix/lib-crc/issues/1): `lib-crc` - [lib-deflate#1](https://git.erikinkinen.fi/erix/lib-deflate/issues/1): `lib-deflate` - [lib-device#1](https://git.erikinkinen.fi/erix/lib-device/issues/1): `lib-device` - [lib-driver#1](https://git.erikinkinen.fi/erix/lib-driver/issues/1): `lib-driver` - [lib-dynlink#1](https://git.erikinkinen.fi/erix/lib-dynlink/issues/1): `lib-dynlink` - [lib-ed25519#1](https://git.erikinkinen.fi/erix/lib-ed25519/issues/1): `lib-ed25519` - [lib-elf#1](https://git.erikinkinen.fi/erix/lib-elf/issues/1): `lib-elf` - [lib-fs-crypto#1](https://git.erikinkinen.fi/erix/lib-fs-crypto/issues/1): `lib-fs-crypto` - [lib-fs-name#1](https://git.erikinkinen.fi/erix/lib-fs-name/issues/1): `lib-fs-name` - [lib-handoff#1](https://git.erikinkinen.fi/erix/lib-handoff/issues/1): `lib-handoff` - [lib-input#1](https://git.erikinkinen.fi/erix/lib-input/issues/1): `lib-input` - [lib-interrupt#1](https://git.erikinkinen.fi/erix/lib-interrupt/issues/1): `lib-interrupt` - [lib-ipc#1](https://git.erikinkinen.fi/erix/lib-ipc/issues/1): `lib-ipc` - [lib-log#1](https://git.erikinkinen.fi/erix/lib-log/issues/1): `lib-log` - [lib-partition#1](https://git.erikinkinen.fi/erix/lib-partition/issues/1): `lib-partition` - [lib-service#1](https://git.erikinkinen.fi/erix/lib-service/issues/1): `lib-service` - [lib-sha2#1](https://git.erikinkinen.fi/erix/lib-sha2/issues/1): `lib-sha2` - [lib-stdio#1](https://git.erikinkinen.fi/erix/lib-stdio/issues/1): `lib-stdio` - [lib-time#1](https://git.erikinkinen.fi/erix/lib-time/issues/1): `lib-time` - [lib-tty#1](https://git.erikinkinen.fi/erix/lib-tty/issues/1): `lib-tty` - [lib-vfs#1](https://git.erikinkinen.fi/erix/lib-vfs/issues/1): `lib-vfs` - [loaderd#1](https://git.erikinkinen.fi/erix/loaderd/issues/1): `loaderd` - [logd#1](https://git.erikinkinen.fi/erix/logd/issues/1): `logd` - [memd#1](https://git.erikinkinen.fi/erix/memd/issues/1): `memd` - [meta#3](https://git.erikinkinen.fi/erix/meta/issues/3): `meta` - [named#1](https://git.erikinkinen.fi/erix/named/issues/1): `named` - [pagerd#1](https://git.erikinkinen.fi/erix/pagerd/issues/1): `pagerd` - [powerboxd#1](https://git.erikinkinen.fi/erix/powerboxd/issues/1): `powerboxd` - [probed#1](https://git.erikinkinen.fi/erix/probed/issues/1): `probed` - [procd#1](https://git.erikinkinen.fi/erix/procd/issues/1): `procd` - [ramfsd#1](https://git.erikinkinen.fi/erix/ramfsd/issues/1): `ramfsd` - [rootd#1](https://git.erikinkinen.fi/erix/rootd/issues/1): `rootd` - [seriald#1](https://git.erikinkinen.fi/erix/seriald/issues/1): `seriald` - [sha2-tool#1](https://git.erikinkinen.fi/erix/sha2-tool/issues/1): `sha2-tool` - [timed#1](https://git.erikinkinen.fi/erix/timed/issues/1): `timed` - [ttyd#2](https://git.erikinkinen.fi/erix/ttyd/issues/2): `ttyd` - [vfsd#1](https://git.erikinkinen.fi/erix/vfsd/issues/1): `vfsd` - [vspaced#1](https://git.erikinkinen.fi/erix/vspaced/issues/1): `vspaced` - [lib-posixabi#2](https://git.erikinkinen.fi/erix/lib-posixabi/issues/2): `lib-posixabi` - [lib-cstd#2](https://git.erikinkinen.fi/erix/lib-cstd/issues/2): `lib-cstd` - [posixd#4](https://git.erikinkinen.fi/erix/posixd/issues/4): `posixd` ## Tracking and rollout Dependencies: [meta#2](https://git.erikinkinen.fi/erix/meta/issues/2) Dependencies identify required contracts and closure gates; preparatory inventory/design can proceed in parallel under one owner per edited file. Link bounded implementation issues and their PRs here before claiming acceptance. Use `feature/posix-compat`, regular signed commits in the canonical contribution format, and WIP PRs linked to the exact coherent component graph. All cross-repository Cargo/catalog selections and CI helpers use full 40-character lowercase commit hashes, including transitive dependencies; do not substitute branch, tag or implicit HEAD selection. Close criteria only with their own reviewed deliverables and validation evidence. Pending, skipped, cancelled, failed or predecessor-only results remain distinct. Keep main images unchanged until explicit promotion direction; technical completion does not authorize merges, release tags or publication.
erikinkinen changed title from [FEATURE] [P02] Audit and refactor authority, lifecycle and code quality across every repository to [FEATURE] Audit and refactor authority, lifecycle and code quality across every repository 2026-09-12 08:01:58 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
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
erix/integration#2
No description provided.