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
2 changes: 1 addition & 1 deletion docs/adrs/0001-one-route-per-fact.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 0001: One Route Per Fact
# 1: One Route Per Fact

Status: accepted

Expand Down
6 changes: 3 additions & 3 deletions docs/adrs/0002-services-interfaces.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 0002: Services Defined by Interfaces and Provided via DI
# 2: Services Defined by Interfaces and Provided via DI

Status: accepted, supplemented by 0003.
Status: accepted

## Decision

A service must be backed by an interface, and reached only through that interface via dependency injection.
Service construction (outside of tests) is to be done only in the project's DI container.
The DI container is the only place that does interface-to-implementation mapping (semi-exception: composites may name concrete classes; see ADR 0003).
The DI container is the only place that does interface-to-implementation mapping (semi-exception: composites may name concrete classes; see ADR 3).

## Context

Expand Down
11 changes: 4 additions & 7 deletions docs/adrs/0003-composite-services.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# 0003: Composite Services
# 3: Composite Services

Status: accepted

## Decision

If there is more than one implementation of a service, logic for which one to use and/or how to combine their results is to be done in a Composite service.

There are **never** to be exactly two implementations of an interface (exception: decorators).
Either there is a single implementation (wired directly in the container), or there are multiple implementations and a composite to dispatch the logic.
A composite is not added proactively when there is a single implementation.

A composite is the **only** place outside of implementations that holds switching or combining logic.
It is the only place outside of the DI container that directly names concrete implementations, and **must** do so in its constructor.
A composite is the **only** place outside of implementations that holds switching or combining logic of which implemention to apply.
It is the **only** place outside of the DI container that directly names concrete implementations, **must** do so in its constructor, and **must** name all of the concrete implementations directly.
There MUST be more than one concrete implementation named by the composite, therefore a composite **must not** be created until multiple implementations exist.

It is permissible to apply the decorator pattern to any implementation inclduing a composite; this should also be done in the container.

Expand Down
4 changes: 2 additions & 2 deletions docs/adrs/0004-php-parser-document-ast.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 0004: Use php-parser for Document Structure
# 4: Use php-parser for Document Structure

Status: accepted

Expand All @@ -7,7 +7,7 @@ Status: accepted
Parsed file structure is to use `nikic/php-parser`'s Abstract Syntax Tree (AST) and data types, regardless of the parsing mechanism.
Parsers, including syntax-invalid file recovery, are to convert into it if necessary.

Walking the AST (recovered or otherwise) to extract other facts is still to be centralized per ADR 0001.
Walking the AST (recovered or otherwise) to extract other facts is still to be centralized per ADR 1.

## Context

Expand Down
6 changes: 3 additions & 3 deletions docs/adrs/0005-document-recovery.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# 0005: Syntax-invalid Document Recovery
# 5: Syntax-invalid Document Recovery

Status: accepted

## Decision

Initial recovery of syntax-invalid documents (common-case: mid-edit editor buffers) is done by best-effort file/AST modification.
Fallback logic stays self-contained so that downstream consumers need no awareness of how recovery occurred and can confidently build on a well-formed AST (ADR 0004).
Fallback logic stays self-contained so that downstream consumers need no awareness of how recovery occurred and can confidently build on a well-formed AST (ADR 4).
Other recovery approaches are allowed but out of scope for now; if implemented, they must still fit within these guidelines.

It is permissible for downstream consumers to be able to determine _if_ (but not how) a node came from recovery.
Expand All @@ -15,7 +15,7 @@ Consumers are only to use this to filter out synthesized code.

Documents in various mid-edit state should produce ASTs as close to valid as possible so symbols can be extracted and downstream tools can continue to rely on those symbols.
Various downstream consumers and handlers must not need to build their own fallback or recovery, as this leads to logic drift.
To be clear: this is largely restating ADR 0001; mid-edit file recovery is central to any LSP server and has historically been a cause of drift within this project.
To be clear: this is largely restating ADR 1; mid-edit file recovery is central to any LSP server and has historically been a cause of drift within this project.

Ideally, the design would not allow downstream consumers to know whether a node came from the recovery system at all.
Unfortunately, that is unavoidable: the recovery can synthesize code that doesn't exist, and some operations must filter this out.
Expand Down
4 changes: 2 additions & 2 deletions docs/adrs/0006-domain-holds-facts.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 0006: The Domain Holds Facts
# 6: The Domain Holds Facts

Status: accepted

Expand All @@ -13,6 +13,6 @@ A local workaround is not a fix, and neither is a comment deferring one.

## Context

ADR 0001 forbids a second route to a fact, but a gap in the domain leaves no first route to compare against.
ADR 1 forbids a second route to a fact, but a gap in the domain leaves no first route to compare against.
The gap shows up as missing structure rather than as a duplicate route, so it is easy to work around without noticing.
One structure per declaration, regardless of origin, is what lets every feature see the same facts.
6 changes: 3 additions & 3 deletions docs/adrs/0007-syntax-produces-facts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 0007: Syntax Produces Facts
# 7: Syntax Produces Facts

Status: accepted, supplements 0004.
Status: accepted, supplements 4.

## Decision

Expand All @@ -15,4 +15,4 @@ Code that needed a closure's parameter types read them from the syntax tree beca
Recovered trees can make this worse: each walker tolerates broken code differently, so a feature can work on half-typed code while another does not.
Note: walkers must not attempt to work around broken code themselves; that's an issue with the recovery tool.

ADR 0004 requires walking the tree to be centralized; this decision is how.
ADR 4 requires walking the tree to be centralized; this decision is how.
36 changes: 36 additions & 0 deletions docs/adrs/0008-known-defects-are-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 8: Known Defects are Added as Tests

Status: accepted.

## Decision

When a reproducible defect is discovered and a fix is out-of-scope for the work being performed, the reproduction script is tracked as a known-defect case.
This addition MAY be included in the original change where it was discovered, or can be given its own PR.

Known-defect cases are end-to-end tests that live in `tests/EndToEnd/defects/`, written with the intended behavior of the program.
When the defect is resolved, the script moves to the standard home for end-to-end tests: `tests/EndToEnd/scripts`.

Known-defect cases have a runner that inverts the pass/fail logic: while it lives in `defects` it _must_ fail; a defect case that's passing will cause the suite to fail.

A defect script is named for its issue when one exists.
The author may use their own discretion as to whether it should be renamed or keep the issue number upon being fixed and moving into the standard suite.

## Context

It's common to discover bugs unrelated to the task at hand.
Trying to fix them mid-change often leads to scope creep.

Capturing them solely as an issue can cause details to get lost.
Further, if a change inadvertently fixes a known issue, the issue remains open until someone discovers it was fixed.
With the inverted pass/fail logic on the defect suite, an unintended fix is actively highlighted when running the test suite and in CI.

Functionally, this serves as something akin to PHPStan's baseline, but for end-to-end tests.
It also serves as a sort of inverted-TDD: a fix for a known defect will turn that suite red, and moving it into the normal suite brings it green again.

### Alternatives considered

- Creating tests and marking as skipped proactively.
This does not have a way to proactively check if any skipped tests are now passing.
- Issues only.
Tried countless times; details get lost and issues go stale.

23 changes: 23 additions & 0 deletions docs/adrs/0009-temporary-known-defects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 9: Temporary Known Defects

Status: accepted

## Decision

It is acceptable to move a passing end-to-end test temporarily into the known-defects suite (ADR 8) if it simplifies the process of executing a multi-stage refactor or other large project.

Authors must justify the temporary regression in the pull request making the change, and explain why it should be temporary.
Reviewers must exercise their judgment as to whether this is an acceptable change.

These temporary regressions should not be added into a tagged release.
The release manager should include a check for this as part of the release process.

## Context

The project has kept to very high test coverage standards.
However, trying to meet the letter of the standards sometimes gets in the way of making bigger changes.
Sometimes it's _way_ easier, simpler, or smaller to take a small break during a refactor and fast-follow fix it.

By moving the test into a known-failing location, no information is lost.
The test remains intact, and retains all the benefits of ADR 8's rationale.
Disabled tests get forgotten, and deleted tests will likely never return.
25 changes: 0 additions & 25 deletions docs/adrs/000x-known-defects-are-tests.md

This file was deleted.

Loading