it-pack / disenchant-it-command
command package for disenchant-it
Requires
- php: ^8.5
- it-pack/command-it: ^1.1
- it-pack/configure-it: ^1.1
- it-pack/disenchant-it: ^1.1
- justinrainbow/json-schema: ^6.16
- symfony/console: ^8.0
- symfony/finder: ^8.0
Requires (Dev)
- codeception/codeception: ^5.1
- codeception/module-asserts: ^3.0
- codeception/module-phpbrowser: ^3.0
- infection/codeception-adapter: ^0.4.7
- just-bases/php-obs-dev-base: ^0.1.0
- just-bases/php-qa-base: ^1.0
- just-bases/php-unit-test-base: ^1.0
- open-telemetry/api: ^1.0
- open-telemetry/exporter-otlp: ^1.0
- open-telemetry/sdk: ^1.0
- open-telemetry/sem-conv: ^1.0
- phparkitect/phparkitect: ^1.2
- rector/rector: ^2.1.3
Suggests
- it-pack/configure-it-runit: Optional RunIt integration for configuration resolution
- it-pack/run-it: Optional execution and observation integration
Provides
None
Conflicts
None
Replaces
None
README
This package contains the in-progress command and console for DisenchantIt. It is
not ready for production use. detect scans source read-only; check and fix
still dispatch placeholder handlers that return an error. config:validate
resolves configuration without scanning source, and config:explain reports
redacted effective values and their origins.
Configuration commands accept --config=FILE and --format=text|json, with
results on stdout and diagnostic codes on stderr. Without --config, only disenchant.json in the
invocation directory is considered; no parent-directory search is performed. Files
must be JSON, contain integer version: 1, and pass
schema/configuration.schema.json. The maximum
file size is 256 KiB. Unknown fields and unsupported versions are rejected; there is
no automatic migration. Duplicate JSON object keys use PHP's last-key-wins behavior.
PHP configuration, includes, and project bootstraps are not executed. On Linux,
configuration files are opened nonblocking to avoid waiting on a FIFO substituted
between validation and open; filesystem races are not otherwise eliminated.
Resolution precedence is defaults, selected file, allowlisted environment, then
explicitly supplied paths and exclusions passed to the resolver. Configuration
commands expose --config and --format, not path or exclusion options. detect
accepts positional paths, repeatable --exclude, --config and --format.
Supplied lists replace lower-priority
lists. File-relative source and registry paths are based on the file's directory;
CLI paths are based on the invocation directory. The default source path is src
under the invocation directory. DISENCHANT_MIN_OCCURRENCES accepts integers from
1 through 999999; DISENCHANT_VERIFY_SYNTAX accepts exactly true or false.
Explanation redacts paths and arbitrary strings. Configuration commands do not scan
source. The format defaults to text and can be selected by output.format in the
configuration file or overridden with --format; resolution errors default to JSON
unless a format was explicitly supplied.
Path and exclusion lists contain at most 1,000 entries. Paths must be valid UTF-8,
and the resolver limits both supplied and normalized paths to 4,096 bytes, even when
the JSON Schema validator counts Unicode characters. Parent traversal, control
characters, backslashes and colons are rejected. Empty lists replace lower-priority
lists; an omitted list leaves the lower-priority value intact. Schema acceptance of
promotion, verification or SemConv settings does not mean all operations support
those settings.
The invocation directory and generated default src path are subject to the same
path validation and byte limit even when an explicit path list replaces the default.
Discovery components provide sorted root-relative paths, Symfony Finder traversal,
and use the same lexical policy for discovery, reading, and report paths: valid UTF-8,
at most 4,096 bytes, without Unicode category C characters, backslashes, colons,
empty components, or . and .. components. The empty path denotes the discovery
root only; source and report paths cannot be empty. These lexical checks do not replace
the independent filesystem safety checks at discovery and read time.
Discovery also provides
case-sensitive *, ?, and ** exclusions, and bounded source reads. The discovery factory binds the
filesystem adapter and resolved-discovery component to one canonical root; all
selections, exclusions and registry destinations must lie within it. Source snapshots
support ordinary change detection but do not provide race-proof filesystem containment.
File-origin exclusions are based on the configuration directory, and supplied
exclusions on the invocation directory; bracket expressions are not supported.
On Linux, source files are opened nonblocking so that a FIFO substituted after the type
check can be rejected without waiting for a writer. Use an isolated, stable checkout;
other concurrent filesystem changes are not guaranteed to be detected safely.
Discovery does not exclude directories by name, including tests, fixtures, var,
or vendor. Detection uses an explicit SDK scope that does not silently exclude
these directories.
detect uses the invocation directory as its discovery root, reports root-relative
paths, line numbers and roles, and omits literal values and source snippets. Findings
are candidates, not guaranteed changes. Text and versioned JSON output use the same
result; findings alone exit 0. Diagnostics go to stderr. Detection honors
minOccurrences and promotion.fqcn; it rejects enabled output.includeSourceDetails,
verification.syntax and semconv.enabled rather than silently ignoring them. It
fails instead of truncating at 10,000 findings or a 10 MiB serialized report. Source
files are read but never executed or modified.
Detection uses the SDK's createWithScope() API, available from
it-pack/disenchant-it 1.2. The declared dependency requires ^1.2.
Discovery deduplicates overlapping selections and sorts the resulting relative paths.
An explicitly selected excluded path, a missing or unreadable path, or a selection
with no matching source files is an error. Explicit non-.php files fail; other
non-.php files encountered during traversal are skipped. The defaults allow up to 10,000 files,
1,000,000 bytes per source file, 100 MiB total input (including an existing registry),
and 100,000 visited entries. On each path resolution, the discovery adapter checks the
root's canonical path, device and inode to detect ordinary root or ancestor replacement,
including an ancestor replaced by a symlink. These checks do not make it a race-proof
sandbox.
The provisional programmatic contracts in src/Command/ register individual
handlers with CommandIt's registry and accept injected use cases without constructing
Symfony. The console projects registered definitions onto the same command bus.
Requests, results, diagnostic codes and limits are not yet stable public contracts.
The SDK factory accepts an optional execution recorder; without one the SDK supplies
its no-op recorder. Full optional RunIt integration is not yet implemented.
Install the package as a development dependency:
composer require --dev it-pack/disenchant-it-command
It is intended for trusted development checkouts and CI, not deployment to production; it is not a filesystem sandbox. Run untrusted contributions in an isolated environment with appropriately restricted credentials.
The package requires PHP 8.5 or later and Symfony Console. Local monorepo development
uses Composer path repositories; those are not a publication or release strategy.
In a standalone development checkout, the root manifest's three sibling path
repositories prevent Composer from resolving dependencies when those directories are
absent. As a temporary local-only workaround, remove the repositories array from the
checkout's composer.json before installing dev dependencies; do not commit that
checkout-specific edit. Composer can then resolve published sibling packages. The
architecture configuration falls back to tools/phparkitect.php when the monorepo QA
helpers are absent; keep that fallback in sync with the shared helpers. This workaround
is for developing this package as the Composer root, not for consumers, whose Composer
installation ignores dependency repository declarations.
The command package has not yet been published; the installation command applies once
it is available from a configured Composer repository.
After installing development dependencies, the executable can display help and version:
php bin/disenchant --help php bin/disenchant --version
The planned process status categories are 0 for success, 1 for proposed changes in
check or dry-run, 2 for invalid usage or configuration, 3 for processing or output
failure, and 130 for interruption. Actual capability and verification status are
tracked in DisenchantIt/docs/CLI_TODOS.md;
the broader design is in DisenchantIt/docs/CLI_PLAN.md.