Files
Codewhale/scripts/test_check_command_config_proof.py
6c2b1d83be refactor(commands): adopt portable core navigation Shapes (FEAT-031) (#7009)
* test(commands): reconcile baseline capability and config proof guards

Match /init's existing WORKSPACE|PRESENTATION authority after 8867749f5. Approve only the already-declared pure sanitizer in the config normal graph; preserve all existing service rejection controls.

FEAT-031 P0 baseline: 19066 nextest passed, 34 skipped; 3 doctests passed, 8 ignored; config proof 35 passed and 7 controls. Full Clippy, debug/release builds and format passed. No navigation implementation or product behavior change. Refs #5316.

* refactor(commands): adopt pure core navigation outcomes and registration

FEAT-031 P2 replaces hotbar/transcript/turn FunctionCommand App wrappers with shared pure handlers, real navigation inventory and exhaustive host action conversion. Preserve the original metadata, grammar, output and nine leaf assertions; core remains pending.

Verified: 79 contract and 482 scoped native tests pass; 1125 actual observations across 15 locales plus all 40 metadata entries replay byte-identically. Full Clippy, rustfmt, 30 boundary and 63 migration controls pass. Complete 13-command portability proof remains P4; no physical move. Refs #5316.

* refactor(commands): adopt stateful core navigation Shapes

FEAT-031 P3 replaces the App-bound help/home/overview/links/anchor/workspace/translate wrappers and nine core.rs helpers with command-owned parsing/rendering, NAVIGATION bit30, narrow workspace/config operations and explicit host adapters. Retain all34 relocated host tests, old capability identities and confinement controls. No physical move or complete-core claim.

Verified:79 contract and1289 commands/help/voice tests pass;1125 native observations across15 locales plus40 metadata entries remain byte-identical. Full Clippy, formatting,30 boundary/63 migration controls and locale guards pass; all failures/retries retained. Refs #5316.

* refactor(commands): complete portable core navigation voice boundary

FEAT-031 P4 replaces the remaining voice App handlers with VOICE_INPUT bit31 Shapes, preserving u32 identities and exact authority. Relocate the unchanged capture runtime outside the movable group and retain builtin shortcut semantics. The real complete13-entry root compiles independently as an unpublished normal library; core remains pending for other slices.

Verified:79 contract and1289 native command/help/voice tests;1125 observations/15 locales and40 metadata entries byte-identical;9 actual-source portable tests and7 rejection controls. Normal graph/build, full Clippy/fmt,30 boundary/63 migration controls, locales, developer routing and publication-order validation pass. No physical move or release. Refs #5316.

* test(commands): strengthen navigation preservation assertions

FEAT-031 P5 extends existing host tests for user help precedence/alias shadowing, one-dismissal help behavior, home-directory routes and exact anchor read/open/partial-write/replacement failures. Production code and all original test identities remain unchanged.

Verified:1289 commands/help/voice tests pass after correcting the fixture's comma-separated alias syntax;58 native/PTY acceptance tests pass against rebuilt current CLI. Contract79, navigation9+7 controls, config35+7, session65+5, boundary30/migration63 and locale/format checks pass. Numeric final coverage remains pending. Refs #5316.

* docs(web): refresh generated agent docs from current main

* fix(commands): address core navigation extraction review

Relocate the existing canonicalization budget without increasing total authority or blocking-call allowance. Correct both localization guides, restore native command tests for command source paths, and make the complete navigation proof tolerate unrelated registry insertions while rejecting omitted/duplicate/reordered entries. Enforce source and normal graph checks on heavy main and PR lint jobs; retain explicit dependency review.

Verified: 1215 native command tests (including all 34 relocated host tests), 9 portable tests, 7 proof controls, 34 blocking-budget controls, workflow regression, docs/facts and formatting pass. Preserved maintainer merge fc5ac7d904. Workspace operation-level authority remains an explicitly documented follow-up; no capability renumbering or widening. Refs #5316.
Signed-off-by: Paulo Aboim Pinto <[email protected]>

* fix(commands): resolve builtin voice shortcut by canonical name

Address the non-blocking PR #7009 review nits: replace dispatch::<10> with builtin-registry lookup using VOICE_INFO.name, preserve capability-scoped dispatch and user-command shadowing isolation, and fix all 13 proof-message spacing.

Verified 1215 native command tests, including existing shadowed-voice and pure action assertions plus safe missing-name rejection; 9 portable tests and 7 proof controls pass. Scoped TUI Clippy and formatting pass. No workspace authority redesign; maintainers own that follow-up and the post-v0.10.2 merge timing. Refs #5316.

Signed-off-by: Paulo Aboim Pinto <[email protected]>

* fix(security): patch follow-redirects in Feishu and WeCom bridges

Resolve the two red npm-audit checks on PR #7009 (GHSA-q3jh-wrc6-jgq8 and GHSA-8r9p-f939-6h3c). Update only the follow-redirects lock entries from 1.16.0 to 1.16.1; keep SDK versions, manifests and all other packages unchanged. No audit exclusions or threshold changes.

Verified on Node 22.22.1: clean locked installs, syntax checks, Feishu 19/19 tests and WeCom 17/17 tests, zero vulnerabilities in both npm audit JSON reports, and installed dependency trees at 1.16.1. Original failing reports retained. Refs #5316.

Signed-off-by: Paulo Aboim Pinto <[email protected]>

---------

Signed-off-by: Paulo Aboim Pinto <[email protected]>
Co-authored-by: Paulo Aboim Pinto <[email protected]>
Co-authored-by: CodeWhale Bot <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Hunter Bown <[email protected]>
2026-10-22 21:20:49 +00:00

115 lines
5.3 KiB
Python

"""Executable negative controls for the complete config-group extraction proof.
FEAT-028 proves the WHOLE config group, so the controls must reject a
selected-leaf proof, a cfg(test)-only mount, a missing root or helper, a host
import anywhere in the mounted closure (including `config.rs`), a dev-dependency
swap, and forbidden normal graph edges.
"""
import importlib.util
from pathlib import Path
import re
import tempfile
import unittest
path = Path(__file__).with_name("check-command-config-proof.py")
spec = importlib.util.spec_from_file_location("config_proof", path)
proof = importlib.util.module_from_spec(spec)
spec.loader.exec_module(proof)
class ConfigProofTests(unittest.TestCase):
def fixture(self, root):
for relative in proof.REQUIRED | {proof.PROOF, proof.MANIFEST}:
target = root / relative
target.parent.mkdir(parents=True, exist_ok=True)
target.write_text((proof.ROOT / relative).read_text())
def test_actual_complete_group_is_included(self):
self.assertEqual(proof.violations(proof.ROOT), [])
def test_selected_leaf_stub_and_test_only_root_are_rejected(self):
for source in [
'pub mod config_group {}',
'#[path = "config.rs"] pub mod config_group;',
'#[cfg(test)]\n' + (proof.ROOT / proof.PROOF).read_text(),
]:
with self.subTest(source=source), tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
self.fixture(root)
(root / proof.PROOF).write_text(source)
self.assertTrue(proof.violations(root))
def test_omitted_root_or_helper_is_rejected(self):
group_dir = "crates/tui/src/commands/groups/config"
for name in ["config", "status", "policy_messages", "money", "tests"]:
with self.subTest(name=name), tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
self.fixture(root)
if name == "config":
# The group root must include its children.
group_root = root / proof.ROOTS[0]
group_root.write_text(
group_root.read_text().replace("pub mod config;\n", ""))
elif name == "money":
policy = root / group_dir / "policy.rs"
policy.write_text(policy.read_text().replace(
"use codewhale_command_contract::money;", ""))
else:
policy = root / group_dir / "policy.rs"
policy.write_text(re.sub(
r'#\[path = "[^"]+"\]\s*(?:pub(?:\([^)]*\))?\s+)?mod ' + name + r';',
'', policy.read_text()))
self.assertTrue(proof.violations(root))
def test_host_import_in_any_mounted_file_is_rejected(self):
for source in [
'use crate::tui::app::App;',
'use codewhale_config::Config;',
'use crate::commands::CommandResult;',
'use std::fs;',
'use codewhale_secrets::Store;',
]:
with self.subTest(source=source), tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
self.fixture(root)
group_root = root / proof.ROOTS[0]
group_root.write_text(group_root.read_text() + "\n" + source + "\n")
self.assertTrue(proof.violations(root))
def test_host_import_in_unmounted_group_file_is_rejected(self):
# A new file in the group directory that is not reachable from the
# mounted root must still be rejected by the whole-directory scan, which
# is the selected-source gap FEAT-026 corrected.
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
self.fixture(root)
stray = root / "crates/tui/src/commands/groups/config/stray_helper.rs"
stray.write_text("use crate::tui::app::App;\n")
self.assertTrue(proof.violations(root))
def test_shapes_cannot_move_to_dev_dependencies(self):
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
self.fixture(root)
manifest = root / proof.MANIFEST
manifest.write_text(
manifest.read_text().replace("[dev-dependencies]", "[build-dependencies]")
.replace("[dependencies]", "[dev-dependencies]"))
self.assertTrue(proof.violations(root))
def test_direct_and_transitive_runtime_or_storage_edges_are_rejected(self):
allowed = ("codewhale-portable-config v0.10.2\ncodewhale-command-contract v0.10.2\n"
"codewhale-protocol v0.10.2\ncodewhale-sanitize v0.10.2\nserde v1.0.0\n")
self.assertEqual(proof.graph_violations(allowed), [])
for package in ["codewhale-tui", "codewhale-config", "codewhale-core", "codewhale-runtime",
"codewhale-execpolicy", "codewhale-secrets", "codewhale-state",
"codewhale-localization", "tokio", "reqwest", "rusqlite", "keyring",
"ratatui", "crossterm"]:
with self.subTest(package=package):
self.assertEqual(
len(proof.graph_violations(allowed + f"{package} v1.0.0\n")), 1)
if __name__ == '__main__':
unittest.main(verbosity=2)