Skip to content

Commit 8bd8265

Browse files
agorischekCopilot
andauthored
Absent isn't failed: typed outcomes, and rules against failures read as absence (#326)
* Absent isn't failed: typed outcomes, and rules against failures read as absence explore's authored definitions, VS Code's HEAD definitions, the Inspector's sweep poll and a downloaded CI artifact without its manifest each turned a failure into the value for "nothing there". Each now keeps the two apart and says why it failed; the sweep poll is a projections-machine machine. A check:silent-failures rule (with .silent-failures.yaml for genuine probes) and the CLI's clippy.toml (Result::unwrap_or_default) stop new ones. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> * Cite #326 in the changelog fragments Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> * Comparator tests: a repository without commits has no definitions yet Reading definitions needs HEAD, so a repository without commits failed the listing once that failure stopped reading as no definitions. Without commits there are none to read; any other failure still fails the listing. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> * Review: retry a failed CI download, read definitions strictly, abort a sweep start with the grid A failed download no longer leaves its commit marked attempted, so a later read fails the same way instead of extracting locally. Explore treats its definitions as absent only when the definition directories hold nothing, so definitions none of which can be read fail too. Starting a sweep aborts when the grid unmounts. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> * Retrigger CI Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> * Schemas for .silent-failures.yaml and the CLI's clippy.toml dollarlint requires every data file to have a schema. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --------- Co-authored-by: agorischek <6295280+agorischek@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 1ad58a9 commit 8bd8265

42 files changed

Lines changed: 868 additions & 92 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.dollarlint.toml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,14 @@ schema = "./packages/schemas/internal/portability.json"
215215
file = ".change-hues.yaml"
216216
schema = "./packages/schemas/internal/change-hues.json"
217217

218+
[[schemas.associations]]
219+
file = ".silent-failures.yaml"
220+
schema = "./packages/schemas/internal/silent-failures.json"
221+
222+
[[schemas.associations]]
223+
file = "packages/cli/clippy.toml"
224+
schema = "./packages/schemas/internal/clippy.json"
225+
218226
[[schemas.associations]]
219227
file = "packages/engine/verified/verus.toml"
220228
schema = "./packages/schemas/internal/verus.json"

‎.github/ci-rules.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"eslint.config.js",
4646
"eslint-suppressions.json",
4747
".portability.yaml",
48+
".silent-failures.yaml",
4849
"rustfmt.toml",
4950
".github/actionlint.yaml",
5051
".github/dependabot.yml",

‎.silent-failures.yaml‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Intentional `undefined` fallbacks (checked by tools/scripts/check-silent-failures.mjs via npm run check:silent-failures).
2+
# Each entry lists a file, its exact count, and why an error means absence or drops only an optional detail.
3+
# Higher counts fail (new sites need a reason), and lower counts fail too so stale entries get pruned.
4+
allow:
5+
- path: packages/extractors/typescript-support/src/worker.ts
6+
count: 1
7+
reason: Probes paths listed by git; a path that fails lstat was removed and cannot be read.
8+
- path: packages/host/core/src/targets/encoding.ts
9+
count: 1
10+
reason: Decodes a target from a URL fragment; invalid input is not a target.
11+
- path: packages/host/inspector/src/app/extraction-coordinator.ts
12+
count: 1
13+
reason: Cancels an unwanted job; if cancellation fails, the finished result is simply ignored.
14+
- path: packages/host/inspector/src/app/persistence.ts
15+
count: 1
16+
reason: Reads a saved preference from localStorage; unavailable storage or corrupt JSON is treated as unset.
17+
- path: packages/host/inspector/src/app/use-live-changes.ts
18+
count: 1
19+
reason: Refreshes the revision list after a working-tree change; on failure, the current refs stay visible.
20+
- path: packages/host/inspector/src/host.tsx
21+
count: 1
22+
reason: Parses a host-supplied link; invalid URL text is ignored.
23+
- path: packages/host/inspector/src/mount.tsx
24+
count: 1
25+
reason: Checks for an active explore session to pick the initial view; defaults to the Inspector on error.
26+
- path: packages/host/inspector/src/sweep/thumbnails.tsx
27+
count: 1
28+
reason: Serializes thumbnail fetches; each cell's promise still rejects, while the queue ignores failures.
29+
- path: packages/integrations/copilot-canvas/extension.mjs
30+
count: 1
31+
reason: Reads the last viewer from the canvas record; corrupt data is treated as none.
32+
- path: packages/integrations/vscode/src/develop-model.ts
33+
count: 1
34+
reason: parseScenarios checks whether text is a scenarios document; non-JSON text is not one.
35+
- path: packages/integrations/vscode/src/folder-model/requests.ts
36+
count: 1
37+
reason: Fetches the current change generation; if it fails, the first changes-stream notification sets it.
38+
- path: packages/integrations/vscode/src/language-model-tools/open-projection.ts
39+
count: 2
40+
reason: Polls a tab page until its modes are available, retrying failed responses until the deadline.
41+
- path: packages/integrations/vscode/src/language-model-tools/view-tools.ts
42+
count: 1
43+
reason: Polls a tab page until extraction finishes, retrying failed responses until the deadline.
44+
- path: packages/integrations/vscode/src/panels/projection-tab/facts.ts
45+
count: 3
46+
reason: Optional tab facts (page view, side descriptions, definition file); a hidden tab or a ref git can't describe omits them and keeps the last reported values.
47+
- path: packages/integrations/vscode/src/pulls.ts
48+
count: 1
49+
reason: Queries gh for the branch's pull request; missing gh, auth, or PR means nothing to link.
50+
- path: packages/integrations/vscode/src/refs.ts
51+
count: 5
52+
reason: Optional git facts (working tree, changed files and counts, checkout location, edit hashes); outside a repo or without git, views omit them and fall back to non-repo behavior.
53+
- path: packages/integrations/vscode/src/scope.ts
54+
count: 1
55+
reason: Hashes scope files for staleness; an unreadable file produces no digest, so the tab cannot mark its result current.
56+
- path: packages/integrations/vscode/src/viewing/recent-commits.ts
57+
count: 1
58+
reason: Fetches a sweep thumbnail; on failure, the cell renders without an image.
59+
- path: tools/cli/src/commands/link.ts
60+
count: 1
61+
reason: Checks whether the link path exists before writing it.
62+
- path: tools/cli/src/lib/ci-change.ts
63+
count: 1
64+
reason: Reads current file contents; files deleted by the change do not exist.
65+
- path: tools/cli/src/lib/link.ts
66+
count: 1
67+
reason: Reads .node-version, which a checkout may not have.
68+
- path: tools/cli/src/lib/links.ts
69+
count: 1
70+
reason: Checks a link target's type; a missing target is neither a file nor a directory.
71+
- path: tools/cli/src/lib/repo.ts
72+
count: 1
73+
reason: readText reads an optional file; callers treat a missing file as absent.
74+
- path: tools/scripts/product-icons.mjs
75+
count: 1
76+
reason: Compares a generated file against disk; a missing file counts as different.
77+
- path: tools/scripts/reference-docs.mjs
78+
count: 1
79+
reason: Compares a generated page against disk; a missing file counts as different.
80+
- path: tools/scripts/reference-docs/shared.mjs
81+
count: 1
82+
reason: Checks whether a path exists.
83+
- path: tools/storybook/harness/host/params.ts
84+
count: 2
85+
reason: Parses user-supplied Storybook URL parameters; invalid JSON is ignored.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
section: behaviour-changes
3+
---
4+
5+
- **`explore` and `adopt` now fail when repository definitions can't be read** (#326). Previously, unreadable definitions (a symlinked definitions directory, an unreadable file, or a repository with no commits) were treated as empty, proposing every candidate as new, including adopted ones. Both commands now fail with the error. Fix the definitions or commit once in a new repository, then rerun.
6+
- **Downloaded CI artifacts missing their manifest now fail** (#326). With CI artifact downloads enabled, a `projections` artifact without `projections.artifact.json` was treated as missing and silently extracted locally. It now fails and names the run, unless an imported artifact already supplies the commit, in which case a note reports the failed download.

‎changelog.d/absent-vs-failed.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
section: fixes
3+
---
4+
5+
- **Stop treating failures as missing data** (#326). `projections doctor` warns when kept workspaces can't be listed instead of reporting none. Listing or running Inspector comparator tests (`/api/comparator-tests`) returns an error when definitions or comparator files can't be listed instead of finding no tests. In VS Code, a failed `HEAD` definitions read logs the error to the Projections output instead of treating the repository as having no commits. The Inspector's history sweep shows polling errors, retries one request at a time, and stops when the view closes.

‎docs/maintainers/linting.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ Left out:
161161
in a regular expression literal is written `\x60`. Considered's scc provider
162162
reads a bare one as the start of a template string and stops counting the
163163
file, so its size and complexity limits would quietly not apply.
164+
- `npm run check:silent-failures` (`tools/scripts/check-silent-failures.mjs`, a
165+
`tools check --fast` gate): `.catch(() => undefined)` and
166+
`catch { return undefined }` hide errors as missing data. Return a typed
167+
outcome instead (absent vs. failed with a reason) and report the error.
168+
Intentional probes, where a failure means absence, are allowlisted in
169+
`.silent-failures.yaml` with per-file counts and reasons.
170+
- `clippy.toml` in `packages/cli` disallows `Result::unwrap_or_default` for the
171+
same reason. Call sites where an error genuinely means the default must use
172+
`#[expect(clippy::disallowed_methods, reason = "…")]`.
164173

165174
## eslint-plugin-unicorn
166175

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"check:boundaries": "node --test tools/scripts/engine-contracts.test.mjs && node tools/scripts/check-boundaries.mjs",
5050
"check:casing": "node tools/scripts/check-casing.mjs",
5151
"check:portability": "node --test tools/scripts/check-portability.test.mjs && node tools/scripts/check-portability.mjs",
52+
"check:silent-failures": "node --test tools/scripts/check-silent-failures.test.mjs && node tools/scripts/check-silent-failures.mjs",
5253
"check:styles": "node --test tools/scripts/check-styles.test.mjs && node tools/scripts/check-styles.mjs",
5354
"check:change-hues": "node --test tools/scripts/check-change-hues.test.mjs && node tools/scripts/check-change-hues.mjs",
5455
"check:lockfile": "node tools/scripts/lockfile-registry.mjs",
@@ -64,7 +65,7 @@
6465
"check:changelog": "node tools/cli/src/bin.ts check --only changelog",
6566
"considered": "node tools/scripts/considered.mjs",
6667
"check": "npm run check:no-test && npm test",
67-
"check:no-test": "npm run check:boundaries && npm run check:casing && npm run check:portability && npm run check:styles && npm run check:change-hues && npm run check:readmes && npm run check:links && npm run check:icons && npm run check:considered && npm run check:machines && npm run check:tsdoc && npm run check:versions && npm run check:changelog && npm run check:lockfile && npm run format:check && npm run build && npm run check:notices && npm run check:comparators && npm run typecheck && npm run lint",
68+
"check:no-test": "npm run check:boundaries && npm run check:casing && npm run check:portability && npm run check:silent-failures && npm run check:styles && npm run check:change-hues && npm run check:readmes && npm run check:links && npm run check:icons && npm run check:considered && npm run check:machines && npm run check:tsdoc && npm run check:versions && npm run check:changelog && npm run check:lockfile && npm run format:check && npm run build && npm run check:notices && npm run check:comparators && npm run typecheck && npm run lint",
6869
"storybook": "npm run storybook --workspace @githubnext/projections-storybook",
6970
"docs:generate": "node tools/scripts/reference-docs.mjs",
7071
"docs:check": "node --test tools/scripts/reference-docs/agents.test.mjs && node tools/scripts/reference-docs.mjs --check",

‎packages/cli/clippy.toml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Turning a failed Result into its default (empty list, `false`, `0`) hides errors as missing data. Match or propagate
2+
# the error, or return a typed outcome; use `#[expect(clippy::disallowed_methods, reason = "…")]` only when an error
3+
# genuinely means the default.
4+
disallowed-methods = [
5+
{ path = "core::result::Result::unwrap_or_default", reason = "hides errors as default values; handle or propagate the error" },
6+
]

‎packages/cli/src/ci_artifacts/github.rs‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
artifact,
1515
runtime::{ProcessFailure, Runner},
1616
};
17-
use anyhow::{Context, Result};
17+
use anyhow::{Context, Result, ensure};
1818
use serde_json::{Value, json};
1919
use std::{
2020
cell::RefCell,
@@ -135,7 +135,8 @@ impl<'a> GitHub<'a> {
135135

136136
/// Downloads into `base/<run>` the `name` artifact of the newest
137137
/// successful run for `commit` whose artifact is this repository's own CI
138-
/// output, recording the run beside it (`base/<run>.json`).
138+
/// output, recording the run beside it (`base/<run>.json`). `None` when no
139+
/// such run has the artifact; an artifact without its manifest fails.
139140
pub fn download(&self, commit: &str, base: &Path) -> Result<Option<PathBuf>> {
140141
let runs = self.api(&format!(
141142
"repos/{}/actions/runs?head_sha={commit}&status=success&per_page=20",
@@ -180,9 +181,12 @@ impl<'a> GitHub<'a> {
180181
let _ = fs::remove_dir_all(&staged);
181182
}
182183
}
183-
if !target.join(super::MANIFEST).is_file() {
184-
return Ok(None);
185-
}
184+
// A run with no artifact is `None`; an artifact without its manifest is broken, not absent.
185+
ensure!(
186+
target.join(super::MANIFEST).is_file(),
187+
"Run {id}'s projections artifact has no {}: it isn't a Projections CI artifact, or it didn't download whole",
188+
super::MANIFEST
189+
);
186190
// The record, not the artifact's own manifest, says whose run it is,
187191
// and on what basis its workflow was accepted.
188192
let record = json!({"host": self.host, "repository": self.repository, "run": id,

‎packages/cli/src/ci_artifacts/mod.rs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ impl Artifacts {
117117
"projections: note: CI's artifact for {commit} couldn't be downloaded, so the imported one is used ({error:#})"
118118
);
119119
}
120-
Err(error) => return Err(error),
120+
Err(error) => {
121+
// Not attempted after all: a later read of the commit fails the same way, never extracting locally
122+
// as if CI had published nothing.
123+
self.attempted.lock().expect("attempts").remove(commit);
124+
return Err(error);
125+
}
121126
}
122127
found = matching(index.as_ref().expect("index"));
123128
}

0 commit comments

Comments
 (0)