Skip to content

Stabilization pass: lint config, type safety, security docs, cache observability - #65

Merged
ApiliumDevTeam merged 7 commits into
devfrom
chore/stabilize-for-dev
Jul 13, 2026
Merged

ApiliumDevTeam merged 7 commits into
devfrom
chore/stabilize-for-dev

Conversation

@ApiliumDevTeam

Copy link
Copy Markdown
Collaborator

Summary

First pass of a stabilization effort focused on type safety, security documentation, and cache observability. No behavior changes to user-facing features.

  • Lint configuration: add .oxlintrc.json to formalize the type-aware rules (no-floating-promises, no-misused-promises, await-thenable, no-base-to-string, restrict-template-expressions) that were running on defaults. Keeps the green baseline while surfacing technical debt for incremental cleanup.
  • Type safety: replace every as any escape hatch in production code with proper types (structural types, type guards, inferred signatures). Removes the soft type-escape across five modules.
  • Security documentation: add a dependency supply-chain policy section (release-age floor, override rationale, patched-dependency version rule, lockfile discipline) and a trust-model section stating that OS-level isolation is the only load-bearing boundary, with in-process defenses classified as heuristics rather than containment.
  • CI: add a pull-request gate that fails when pnpm-lock.yaml changes without a deps:-scoped commit or a manifest change. Implements the documented lockfile discipline as an automated check; also runnable locally.
  • Cache observability: formalize the prompt-cache invariant in the contribution guide and add a system-prompt drift signal to the cache trace. When the system digest changes between consecutive turns of a session without a session restart, a cache:system-drift event is emitted so silent cache invalidations become diagnosable. Includes unit tests.
  • TUI roadmap: document the current terminal UI state and a prioritized P0/P1/P2 redesign plan covering rendering, input, vim mode, accessibility, and platform coverage.

Test plan

  • pnpm tsgo passes (0 errors)
  • pnpm lint passes (0 errors, 344 warnings — pre-existing technical debt surfaced by the new config)
  • pnpm exec vitest run src/agents/cache-trace.test.ts — 4/4 new tests pass
  • node scripts/check-lockfile-policy.mjs --base origin/dev — passes locally
  • All 13 changed files pass pnpm exec oxfmt --check

Formalize the lint configuration that was previously running on oxlint
defaults via the --type-aware flag. The config:
- Activates type-aware rules (no-floating-promises, no-misused-promises,
  await-thenable, no-base-to-string, restrict-template-expressions).
- Formalizes the repo no-explicit-any policy as a warning.
- Disables noisy rules in test files where type strictness is less
  valuable (unbound-method, no-floating-promises, any).
- Keeps correctness category as warnings, not errors, to preserve a
  green baseline while surfacing 364 items of technical debt for
  incremental cleanup.
Add a Dependency Supply Chain section to SECURITY.md covering the
controls the project already enforces via package.json:
- The 48-hour release age floor (minimumReleaseAge: 2880).
- The rationale requirement for every pnpm.overrides entry, tied to a
  CVE or regression.
- The hard rule that patchedDependencies must use exact versions.
- Lockfile discipline: frozen-lockfile in CI, deps: commits for
  dependency changes, reviewed transitive bumps.
- The onlyBuiltDependencies allowlist limiting native build scripts.

This formalizes existing practice as written policy so maintainers and
contributors have a single source of truth for dependency trust
decisions.
…undary

Introduce a Trust Model section that states the project's governing
security principle: operating-system level isolation is the only
load-bearing boundary, and every in-process defense (approval gate,
output redaction, scanners, rate limiters, the WASM sandbox) is a
heuristic that reduces attack surface but does not contain a
determined adversary with in-process code execution.

The section classifies real boundaries (separate users, containers,
VMs, namespaces, seccomp, Landlock) against in-process defenses, and
gives concrete implications for operators running untrusted skills and
plugins. This sharpens the existing Plugin Trust Boundary section,
which now reads as a specific case of the general model.
Add a CI step on pull requests that fails when pnpm-lock.yaml changes
without a deps-scoped commit or a corresponding manifest change
(package.json, pnpm-workspace.yaml). This implements the lockfile
discipline documented in SECURITY.md as an automated gate rather than
relying on review alone.

The check is implemented as scripts/check-lockfile-policy.mjs so it can
also run locally (node scripts/check-lockfile-policy.mjs --base <ref>)
before pushing. On CI it only runs on pull_request events, where the
base ref is well-defined.
Remove every `as any` escape hatch in production code (the 20
occurrences flagged by no-explicit-any once the rule was formalized).
Each replacement uses a concrete type:

- mattermost/channel.ts: params is already Record<string, unknown>, so
  the casts were unnecessary — access the fields directly with typeof
  narrowing.
- agent-mesh/index.ts: model the on-disk mayros.json and auth-profiles
  shapes with structural types instead of Record<string, any>; forward
  the heterogeneous Mamoru gateway handlers through a typed callable.
- feishu/bot.ts: narrow the Lark SDK response with a minimal
  FeishuUserResponse type; widen the logger signature to unknown[].
- feishu/docx.ts: introduce a FeishuBlock structural type for the
  document blocks used by sortBlocksByFirstLevel, with a type-guard
  filter.
- mcp-server/index.ts: type registerCli's program as Command and the
  dashboard respond callback with its structural signature.

Also extend the oxlint test override to *.test-helpers.ts so test
fixtures are not held to production type strictness.
Formalize the project's prompt-cache invariant and add a drift signal to
the cache trace so cache-breaking changes become visible.

AGENTS.md:
- Add a Prompt Cache Discipline section stating the governing principle:
  the system prompt must stay stable across runs that have no reason to
  change it, slash commands that mutate state invalidate only on the
  next turn, and hooks must be deterministic. This makes the contract
  explicit for contributors.

cache-trace.ts:
- Track the last system digest per session key in a module-level map.
- When wrapStreamFn sees a different system digest for the same session
  on a consecutive call, emit a new cache:system-drift event carrying
  both the current and previous digests. This turns silent cache
  invalidations (which multiply token cost) into a diagnosable signal.
- Propagate previousSystemDigest through the event pipeline.

cache-trace.test.ts:
- Unit tests covering first-call (no drift), drift on change, stability
  across repeated calls, and independent per-session tracking.
Add docs/platforms/tui-redesign.md capturing the current state of the
terminal UI, the gaps found during an internal audit, and a prioritized
P0/P1/P2 roadmap for the next redesign pass.

The audit covers rendering, input, slash commands, themes, vim mode,
accessibility, and platform coverage. It documents the architectural
constraints (shared terminal UI dependency as rendering floor, mandatory
gateway, mutable state, two parallel TUI implementations, two palette
systems) that bound the redesign, and calls out two P0 items that block
trustworthy feature work: verifying the vim bridge is actually wired,
and bringing the accessibility TUI to feature parity.
@ApiliumDevTeam
ApiliumDevTeam force-pushed the chore/stabilize-for-dev branch from dc06d48 to 499cd76 Compare July 13, 2026 16:40
@ApiliumDevTeam
ApiliumDevTeam merged commit debe72a into dev Jul 13, 2026
14 of 15 checks passed
@ApiliumDevTeam
ApiliumDevTeam deleted the chore/stabilize-for-dev branch July 13, 2026 16:43
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