0.0.2-alpha.2.fix.1

This commit is contained in:
2026-09-28 16:25:25 +02:00
parent bdbd6a51a4
commit ffb47214af
10 changed files with 528 additions and 81 deletions

View File

@@ -0,0 +1,280 @@
<!-- file: deltas/0.0.2/alpha.2.fix.1.md -->
<!-- version: 1 -->
# Delta 0.0.2-alpha.2.fix.1 — correction de gate, formatage et construction interne
## Base requise
Partir de `0.0.2-alpha.2` après application et commit du history réel :
```text
deltas/0.0.2/alpha.2.md présent et historique
history/0.0.2/alpha.2.md FAIL
```
Le delta `alpha.2` historique ne doit pas être réécrit.
La version devient :
```text
0.0.2-alpha.2.fix.1
```
## Objet
Corriger uniquement les défauts révélés par la gate opérateur d'`alpha.2` :
- supprimer la ligne vide terminale détectée par `git diff --check` dans la matrice de validation ;
- empêcher l'audit Markdown embarqué de traiter `node_modules` ou d'autres arbres générés comme contenu gouverné ;
- appliquer le formatage attendu par `cargo fmt` aux quatre fichiers Rust signalés ;
- construire `GitSourceKey` depuis son module propriétaire au lieu de tenter d'utiliser son constructeur tuple privé via le réexport `crate::GitSourceKey` ;
- conserver le champ tuple privé et ne pas élargir l'API publique ;
- documenter le `FAIL` d'`alpha.2` et la portée strictement corrective de ce fix.
Le fix n'ajoute aucune capacité Git. `refresh`, résolution vers commit et snapshot/worktree restent réservés à `alpha.3`.
## Scope
REPLACE :
```text
VERSION
Cargo.toml
crates/knowledge-git-lib/src/backend.rs
crates/knowledge-git-lib/src/error.rs
crates/knowledge-git-lib/src/lib.rs
crates/knowledge-git-lib/unit_tests/backend.rs
docs/plans/002-V0_0_2_GIT_SYNC_PLAN.md
docs/validation/001-VALIDATION_MATRIX.md
```
ADD :
```text
deltas/0.0.2/alpha.2.fix.1.md
```
DELETE : aucun.
Le history `history/0.0.2/alpha.2.md` appartient à la base requise mais n'est pas inclus dans ce delta.
Aucun fichier sous `Web/`, `crates/knowledge-git-api/` ou `crates/knowledge-sync-api/` n'est modifié.
## Corrections attendues
### Hygiène documentaire
`docs/validation/001-VALIDATION_MATRIX.md` doit terminer par une seule fin de ligne, sans ligne vide additionnelle produisant un warning `git diff --check`.
La gate du fix contrôle les Markdown du workspace mais ignore explicitement les arbres générés/non gouvernés :
```text
.git
node_modules
target
builds
```
La présence d'un README provenant d'une dépendance npm ne doit donc plus faire échouer la gouvernance documentaire du projet.
### Rustfmt
Les fichiers signalés par la gate initiale sont remis dans la forme attendue par `rustfmt.toml` :
```text
crates/knowledge-git-lib/src/backend.rs
crates/knowledge-git-lib/src/error.rs
crates/knowledge-git-lib/src/lib.rs
crates/knowledge-git-lib/unit_tests/backend.rs
```
Aucun changement fonctionnel autre que la correction de visibilité ci-dessous n'est introduit.
### Construction de `GitSourceKey`
`GitSourceKey` conserve son champ tuple privé :
```text
pub struct GitSourceKey(String);
```
Sa méthode `from_source_id`, définie dans le module `backend`, construit le type avec `Self(value)` depuis son propre `impl`. Le réexport public reste destiné à nommer le type, pas à contourner la visibilité de son champ interne.
## Gate opérateur
Après application du history `alpha.2`, commit/push de cet état, puis application du présent delta :
```bash
test "$(cat VERSION)" = '0.0.2-alpha.2.fix.1'
grep -F 'version = "0.0.2-alpha.2.fix.1"' Cargo.toml
grep -A2 '^## Statut$' history/0.0.2/alpha.2.md | grep -Fx 'FAIL'
git diff --check
python3 - <<'PY'
from pathlib import Path
import re
import tomllib
required = (
"crates/knowledge-git-lib/Cargo.toml",
"crates/knowledge-git-lib/src/backend.rs",
"crates/knowledge-git-lib/src/error.rs",
"crates/knowledge-git-lib/src/lib.rs",
"crates/knowledge-git-lib/unit_tests/backend.rs",
"deltas/0.0.2/alpha.2.md",
"deltas/0.0.2/alpha.2.fix.1.md",
"history/0.0.2/alpha.2.md",
)
for value in required:
assert Path(value).is_file(), value
root = tomllib.loads(Path("Cargo.toml").read_text(encoding="utf-8"))
manifest = tomllib.loads(Path("crates/knowledge-git-lib/Cargo.toml").read_text(encoding="utf-8"))
assert "crates/knowledge-git-lib" in root["workspace"]["members"]
assert set(manifest["dependencies"]) == {"knowledge-domain-lib"}, manifest["dependencies"]
backend = Path("crates/knowledge-git-lib/src/backend.rs").read_text(encoding="utf-8")
error = Path("crates/knowledge-git-lib/src/error.rs").read_text(encoding="utf-8")
assert "return Self(value);" in backend
assert "return crate::GitSourceKey(value);" not in backend
assert "return crate::backend::GitSourceKey(value);" not in backend
assert "pub struct GitSourceKey(String);" in backend
for phrase in (
"std::process::Command::new",
'command.env("GIT_TERMINAL_PROMPT", "0")',
'command.env_remove("GIT_DIR")',
'command.env_remove("GIT_WORK_TREE")',
'command.env_remove("GIT_INDEX_FILE")',
'command.env_remove("GIT_OBJECT_DIRECTORY")',
'command.env_remove("GIT_ALTERNATE_OBJECT_DIRECTORIES")',
'command.env("GIT_CONFIG_KEY_0", "core.hooksPath")',
'std::ffi::OsString::from("--mirror")',
'std::ffi::OsString::from("--no-local")',
'std::ffi::OsString::from("--")',
'std::ffi::OsString::from("--is-bare-repository")',
):
assert phrase in backend, phrase
for forbidden in (
'Command::new("sh")',
'Command::new("bash")',
'Command::new("cmd")',
'Command::new("powershell")',
"stderr: String",
"arguments: Vec<String>",
"refresh(",
"resolve_revision(",
"worktree add",
"knowledge-app-lib",
):
assert forbidden not in backend + error, forbidden
for path in Path("crates/knowledge-git-lib").rglob("*.rs"):
text = path.read_text(encoding="utf-8")
for forbidden in ("unwrap()", "expect(", "panic!("):
assert forbidden not in text, (path, forbidden)
ignored_parts = {".git", "node_modules", "target", "builds"}
checked_markdown = 0
for path in Path(".").rglob("*.md"):
if any(part in ignored_parts for part in path.parts):
continue
lines = path.read_text(encoding="utf-8").splitlines()
assert lines[0] == f"<!-- file: {path.as_posix()} -->", path
assert re.fullmatch(r"<!-- version: [1-9][0-9]* -->", lines[1]), path
checked_markdown += 1
assert checked_markdown > 0
print(f"Knowledge 0.0.2-alpha.2.fix.1 structural audit: clean ({checked_markdown} Markdown file(s))")
PY
python3 -B scripts/audit_rust_test_layout.py crates
python3 -B scripts/audit_rust_blank_lines.py crates
python3 -B scripts/audit_rust_item_spacing.py crates
python3 -B scripts/audit_rust_module_order.py crates
python3 -B scripts/audit_rust_trait_import_blocks.py crates
python3 -B scripts/audit_rust_reexport_blocks.py crates
python3 -B scripts/audit_rust_export_completeness.py --root . --summary-only
cargo fmt --all -- --check
cargo metadata --format-version 1 --no-deps > /tmp/sasedev-knowledge-0.0.2-alpha.2.fix.1-metadata.json
cargo check --workspace
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo test -p knowledge-git-lib --all-targets --all-features
cargo test --workspace --all-targets --all-features
python3 - <<'PY'
import json
from pathlib import Path
metadata = json.loads(Path("/tmp/sasedev-knowledge-0.0.2-alpha.2.fix.1-metadata.json").read_text(encoding="utf-8"))
packages = {package["name"] for package in metadata["packages"]}
expected = {
"knowledge-domain-lib",
"knowledge-git-api",
"knowledge-git-lib",
"knowledge-sync-api",
"knowledge-web-lib",
"knowledge-pgr-server",
"knowledge-howtos-server",
"knowledge-snippets-server",
}
assert packages == expected, packages
assert len(metadata["workspace_members"]) == 8, metadata["workspace_members"]
print("Knowledge 0.0.2-alpha.2.fix.1 Cargo metadata audit: clean")
PY
test -f Cargo.lock
git check-ignore -q Cargo.lock
if git ls-files --error-unmatch Cargo.lock >/dev/null 2>&1; then
echo 'Cargo.lock must remain untracked for Knowledge' >&2
exit 1
fi
test -z "$(git diff --name-only -- Web)"
test -z "$(git diff --name-only -- crates/knowledge-git-api crates/knowledge-sync-api)"
test ! -e crates/knowledge-app-lib
test ! -e crates/knowledge-forge-gitea-lib
test ! -e crates/knowledge-store-postgres-lib
git add -A
git diff --cached --check
git status --short
```
## Résultats attendus
La gate doit notamment produire :
```text
Knowledge 0.0.2-alpha.2.fix.1 structural audit: clean (... Markdown file(s))
Rust test-layout audit: clean (8 crate(s))
Rust export completeness audit: 0 candidate(s) across 8 package(s)
Knowledge 0.0.2-alpha.2.fix.1 Cargo metadata audit: clean
```
`cargo fmt --all -- --check` doit être silencieux et `cargo check`, Clippy et les deux suites de tests doivent tous terminer avec succès.
La suite ciblée `knowledge-git-lib` doit exécuter `7` tests unitaires `PASS`, sauf modification explicitement justifiée du nombre de tests dans un fix ultérieur.
## Revue opérateur complémentaire
Vérifier que :
- la correction de visibilité n'a pas rendu public l'état interne de `GitSourceKey` ;
- l'audit Markdown ne dépend plus de l'absence physique de `node_modules` ;
- aucun comportement de `refresh`, résolution ou snapshot n'est apparu dans le fix ;
- aucune nouvelle dépendance Cargo n'a été introduite ;
- le fix ne change pas l'architecture validée d'`alpha.2`.
## Transition
### PASS
Produire `history/0.0.2/alpha.2.fix.1.md`, appliquer ce history, committer/pousser le fix, puis seulement préparer `0.0.2-alpha.3`.
### FAIL / PARTIAL / BLOCKED
Conserver le résultat réel dans `history/0.0.2/alpha.2.fix.1.md` et rester dans le scope `alpha.2` avec `alpha.2.fix.2` si nécessaire, sauf déclencheur de REPLAN explicitement satisfait.