Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions IMPLEMENTATION_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ priorities.
shared leaf identity. It rejects hostile structural depth before descent
and leaves redirects, dynamic identities, unproved host command strings,
and undiscovered executable expressions incomplete.
- [x] Promote representative existing constructs into the executable corpus
with exact v0.3 syntax and command-occurrence expectations. Bash and
PowerShell cases pin simple commands, list/pipeline precedence, group
scope, static and dynamic wrappers, redirects, hidden substitutions,
roles, ancestry, completeness, nullable decoded spans, compatibility
operators, and exact shared `Clause` identity. The strict DTO rejects
unknown fields and always requires unparseable projections to be empty.
The PowerShell manifest now owns all 310 entries and round-trips exactly;
explicit false/null assertions remain opt-in and generator-preserved.
- [ ] Deliver paired Bash and PowerShell `$()` substitution slices for all
locked executable value positions, including ordering, ancestry,
shell-specific cwd propagation, literal/escaped boundaries, dynamic
Expand All @@ -272,9 +281,6 @@ priorities.

- Seed corpus entries from sanitized real-world dogfood logs (SPEC §14
workflow) — both shells.
- Synchronize PowerShell corpus manifest entries 282–309 before using the
generator as an all-corpus rewrite; until then, targeted manifest changes
must preserve the checked-in hand-authored tail.
- Expand verb / cmdlet / alias tables as the corpus surfaces real commands.
- Performance sanity check (~1 ms typical) with a tiny BenchmarkDotNet
harness — only if anything in the daemon hot path complains.
Expand Down
7 changes: 7 additions & 0 deletions SPEC.POWERSHELL.md
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,13 @@ The shared corpus DTO gains two optional fields:
`Invoke-Expression`, an over-cap input (§11), or a recursion-depth overflow
— because real `pwsh` parses the *outer* invocation without error.

The shared v0.3 `syntax` and `commands` expectations defined in `SPEC.md` §13
apply unchanged. Selected PowerShell entries SHALL pin current-scope groups,
pipeline/list precedence, exact direct spans, null decoded-wrapper spans,
command roles, ancestry, completeness, and exact compatibility-leaf identity.
The manifest marks these entries explicitly so regeneration preserves the
structural assertions; entries without the marker retain the legacy schema.

### Coverage targets for v0.2.0

| Category | Min |
Expand Down
20 changes: 20 additions & 0 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,26 @@ An entry may add an `elements` list to a clause to pin the complete
`resolved`). The field is opt-in so older corpus entries remain readable;
issue-specific provenance entries SHALL include it.

An entry may also add both of the following v0.3 structural expectations:

- `syntax` is the complete `ParsedCommand.Syntax` tree flattened in preorder.
Each item records `kind`, `parentIndex`, the incoming ancestry `region` and
`childIndex`, exact-or-null `sourceStart` / `sourceLength`, and the
kind-specific `clauseIndex`, `groupKind`, or `listOperator`. `clauseIndex`
identifies the exact compatibility `Clause` instance owned by a
`SimpleCommand` node; it is not a copied value comparison.
- `commands` is the complete `ParsedCommand.Commands` projection in authored
order. Each item records its `clauseIndex`, `immediateRole`, `isComplete`,
and outermost-to-innermost `ancestry` frames. Each frame records
`ancestorKind`, `region`, `childIndex`, and exact-or-null source range.

These fields are independently opt-in so legacy corpus entries retain their
v0.2 shape; structural acceptance cases normally provide both. When present,
the runner compares every node, relationship, range, occurrence, role,
completeness bit, ancestry frame, and `Clause` reference. Unknown JSON members
are rejected. An unparseable result always asserts empty `Clauses` and
`Commands`, even when those arrays are omitted from the JSON.

The corpus runner also lexes every direct, parseable input and verifies that
each authored verb, argument, opaque region, and redirect token is covered by
exactly-positioned clause-element provenance. This invariant applies even when
Expand Down
8 changes: 7 additions & 1 deletion TOOLING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ and parser slice exists. The PII audit scans both corpus trees.

The curated inputs live in `tools/PwshCorpusTool/CorpusManifest.cs`; the
`expected` AST is generated from `PwshParser`, and `PwshOracleTests`
independently validates every input against real `pwsh`.
independently validates every input against real `pwsh`. The manifest owns
every checked-in PowerShell entry. `IncludeStructure` opts selected entries
into exact `syntax` / `commands` expectations, while
`IncludeOptionalAssertions` preserves explicit false/null security assertions
for cases that require them. A safe generator change MUST regenerate to a
temporary directory and produce an exact directory diff before rewriting the
checked-in corpus.

## Source Control and CI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ of whether the command is top-level or nested.
- **THEN** the authored `echo` command appears once
- **THEN** its possible effective values are represented by analysis facts rather than three duplicated occurrences

#### Scenario: Executable corpus pins all public projections
- **WHEN** a selected Bash or PowerShell corpus entry is marked for structural verification
- **THEN** the corpus records the complete syntax tree and command-occurrence collection in authored order
- **THEN** every simple-command node and occurrence references the exact compatibility clause by index and object identity
- **THEN** roles, completeness, ancestry coordinates, and exact-or-null source ranges are compared without weakening legacy corpus entries that omit structural expectations

### Requirement: Occurrences identify structural execution roles
Each command occurrence SHALL identify its immediate structural execution role
and SHALL retain compositional ancestry for analysis, diagnostics, and UI
Expand Down
2 changes: 1 addition & 1 deletion openspec/changes/v0-3-structured-shell-analysis/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
- [x] 3.6 Adapt the existing Bash grammar to emit the structural model with no newly supported syntax.
- [x] 3.7 Adapt the existing PowerShell grammar to emit the structural model with no newly supported syntax.
- [x] 3.8 Add tests proving existing parser inputs retain their v0.2 leaf and compatibility results, except for explicitly promoted v0.3 fail-closed cases.
- [ ] 3.9 Add corpus expectations for syntax shape, occurrences, roles, and completeness for existing constructs.
- [x] 3.9 Add corpus expectations for syntax shape, occurrences, roles, and completeness for existing constructs.
- [ ] 3.10 Implement Bash `$()` discovery in supported argument words, redirect values, iterables, and expanding heredoc bodies; retain literal/escaped spellings and fail closed on command-name substitutions, legacy backticks, or incomplete interiors.
- [ ] 3.11 Implement PowerShell `$()` discovery in supported words, redirect values, foreach expressions, call-operator dynamic identities, standalone expression statements, double-quoted strings, and expandable here-strings; never invent invocation from standalone output, retain literal/escaped spellings, and fail closed on trailing command-style arguments, call-operator script blocks, or unsupported execution-bearing `@()` / `@{}` forms.
- [ ] 3.12 Pin substitution parentage, authored sibling indices, innermost-first ordering, Bash-isolated versus PowerShell-current-scope state, unknown-state propagation, nesting/depth limits, and incomplete dynamic identities in direct tests.
Expand Down
Loading