chore(lint): repo-wide green becomes the contract
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Close the lint arc #194-#197: deliberate-style rule disables with rationales (#194), filter-safe test renames + --test-case-name-format preserve (#195), every surviving warning fixed through the sanctioned lint-stable shapes (#196), and the docs now state the true contract (#197): bare swiftlint . reports zero violations and swiftformat . reformats nothing, while push gates stay scoped to the push's own files (settled #190 design) — the pre-push hook's stale 'pre-existing violations' rationale blocks refreshed, gate logic untouched. Also in the sweep: quiesce the FSEvent-burst watcher race in LibrarySearchTests (two rescans double-count one shared PostScanCache miss; benign revision over-bump), pin the learnings scan's symlink-skip contract (flip-verified — defended in depth by the lstat guard AND contentsOfDirectory's own symlink refusal), reorder that scan's guard so cheap rejections precede the directory listing, and park the roster chmod window with a ceiling comment. Finish-audit: 3 reviewers, 0 blocking; the one code finding was disproved by probe (&& out-binds ?? — the guard was correct). Suite 693/693 via scripts/full-test.sh; swiftlint 0 violations; swiftformat 0/141; hook rig 23/23. Closes #197
This commit is contained in:
1 parent
0ab00eb7b6
commit
d7fd11cf0d
29 files changed
+549
-269
No files matched your search
@@ -139,16 +139,16 @@ nonisolated enum ProfileProvisioner {
|
||||
return logFailure(.failed(profile: profile, phase: phase, excerpt: excerpt))
|
||||
}
|
||||
|
||||
let env = SurfaceEnv(
|
||||
hermesBinary: hermesBinary,
|
||||
profileRoot: profileRoot,
|
||||
masterRoot: masterRoot,
|
||||
manifest: manifest,
|
||||
serverBinaryPath: serverBinaryPath,
|
||||
timeout: timeout,
|
||||
)
|
||||
for surface in ProfileSurface.allCases {
|
||||
switch provisionSurface(
|
||||
surface,
|
||||
hermesBinary: hermesBinary,
|
||||
profileRoot: profileRoot,
|
||||
masterRoot: masterRoot,
|
||||
manifest: manifest,
|
||||
serverBinaryPath: serverBinaryPath,
|
||||
timeout: timeout,
|
||||
) {
|
||||
switch provisionSurface(surface, env: env) {
|
||||
case let .seeded(deltaCopied, deltaPresent):
|
||||
copied += deltaCopied
|
||||
present += deltaPresent
|
||||
@@ -165,20 +165,27 @@ nonisolated enum ProfileProvisioner {
|
||||
return .seeded(copied: copied, present: present)
|
||||
}
|
||||
|
||||
/// Per-`perform` context threaded into every surface pass — everything
|
||||
/// except the surface itself (the loop variable), so the per-surface
|
||||
/// seam stays under the parameter-count ceiling.
|
||||
private struct SurfaceEnv {
|
||||
let hermesBinary: String?
|
||||
let profileRoot: String
|
||||
let masterRoot: String
|
||||
let manifest: [String]
|
||||
let serverBinaryPath: String?
|
||||
let timeout: TimeInterval
|
||||
}
|
||||
|
||||
/// Phases 1–4 for ONE surface profile (#134): create (or adopt), write
|
||||
/// defaults on fresh profiles via the CLI rail, link skills per
|
||||
/// allocation, register museion-tools (#23).
|
||||
private static func provisionSurface(
|
||||
_ surface: ProfileSurface,
|
||||
hermesBinary: String?,
|
||||
profileRoot: String,
|
||||
masterRoot: String,
|
||||
manifest: [String],
|
||||
serverBinaryPath: String?,
|
||||
timeout: TimeInterval,
|
||||
env: SurfaceEnv,
|
||||
) -> Outcome {
|
||||
let fileManager = FileManager.default
|
||||
let profileDir = ProfileLayout.profileDir(surface.profileName, root: profileRoot)
|
||||
let profileDir = ProfileLayout.profileDir(surface.profileName, root: env.profileRoot)
|
||||
|
||||
// Phase 1 — profile create. Dir-check first; spawn only when
|
||||
// missing (#45). `museion` is adopted, never re-created (ADR-0014).
|
||||
@@ -186,12 +193,12 @@ nonisolated enum ProfileProvisioner {
|
||||
// carry only Museion's curated set — coding and writing never mix, G3).
|
||||
var createdFresh = false
|
||||
if !fileManager.fileExists(atPath: profileDir) {
|
||||
guard let binary = hermesBinary else {
|
||||
guard let binary = env.hermesBinary else {
|
||||
return .failed(profile: surface.profileName, phase: .create, excerpt: "hermes binary not found")
|
||||
}
|
||||
let run = EngineProbe.execute(
|
||||
[binary, "profile", "create", surface.profileName, "--no-alias", "--no-skills"],
|
||||
timeout: timeout,
|
||||
timeout: env.timeout,
|
||||
)
|
||||
// #43: exit 1 + "already exists" on stdout = success (a
|
||||
// concurrent create — not ours, so not fresh); all errors print on stdout.
|
||||
@@ -208,10 +215,10 @@ nonisolated enum ProfileProvisioner {
|
||||
// profile (interrupted before its marker landed) is healed, and
|
||||
// the adopted museion is never touched — its model is the user's.
|
||||
if createdFresh || (surface != .chat && !markerExists(at: profileDir)) {
|
||||
guard let binary = hermesBinary else {
|
||||
guard let binary = env.hermesBinary else {
|
||||
return .failed(profile: surface.profileName, phase: .configure, excerpt: "hermes binary not found")
|
||||
}
|
||||
if let failure = configureDefaults(profile: surface.profileName, hermesBinary: binary, timeout: timeout) {
|
||||
if let failure = configureDefaults(profile: surface.profileName, hermesBinary: binary, timeout: env.timeout) {
|
||||
return failure
|
||||
}
|
||||
// A marker we couldn't record = configure incomplete — surface it
|
||||
@@ -224,7 +231,7 @@ nonisolated enum ProfileProvisioner {
|
||||
|
||||
// Phase 3 — per-profile skills: symlinks per allocation + the
|
||||
// copy-era → symlink migration (#133).
|
||||
let linked = linkSkills(surface: surface, profileDir: profileDir, masterRoot: masterRoot, manifest: manifest)
|
||||
let linked = linkSkills(surface: surface, profileDir: profileDir, masterRoot: env.masterRoot, manifest: env.manifest)
|
||||
if case .failed = linked {
|
||||
return linked
|
||||
}
|
||||
@@ -232,7 +239,7 @@ nonisolated enum ProfileProvisioner {
|
||||
// Phase 4 — museion-tools registration per profile (ADR-0008
|
||||
// amendment). nil on either binary is the test-injection seam;
|
||||
// production always has both after a gate pass.
|
||||
guard let hermesBinary, let serverBinaryPath else {
|
||||
guard let hermesBinary = env.hermesBinary, let serverBinaryPath = env.serverBinaryPath else {
|
||||
Logger(subsystem: subsystem, category: "provisioning")
|
||||
.info("museion-tools registration skipped: engine or server binary missing")
|
||||
return linked
|
||||
@@ -241,7 +248,7 @@ nonisolated enum ProfileProvisioner {
|
||||
profile: surface.profileName,
|
||||
hermesBinary: hermesBinary,
|
||||
serverBinaryPath: serverBinaryPath,
|
||||
timeout: timeout,
|
||||
timeout: env.timeout,
|
||||
) {
|
||||
return failure
|
||||
}
|
||||
@@ -511,6 +518,12 @@ nonisolated extension ProfileProvisioner {
|
||||
!name.isEmpty && name.allSatisfy { ($0.isLowercase && $0.isLetter) || $0.isNumber || $0 == "-" }
|
||||
}
|
||||
|
||||
/// True when `path` is a symlink (lstat-true, before any open) — the
|
||||
/// payload never ships one, so a linked entry refuses the tree match.
|
||||
private static func isSymlinked(_ path: String) -> Bool {
|
||||
(try? FileManager.default.destinationOfSymbolicLink(atPath: path)) != nil
|
||||
}
|
||||
|
||||
/// Recursive byte-comparison of two dir trees — same entry names, every
|
||||
/// file byte-identical. `.DS_Store` is filtered from BOTH listings before
|
||||
/// the name-equality check (Finder noise, not a user edit — a
|
||||
@@ -532,9 +545,7 @@ nonisolated extension ProfileProvisioner {
|
||||
let rhsPath = (rhs as NSString).appendingPathComponent(name)
|
||||
// Neither side may carry a symlink at this entry (lstat-true,
|
||||
// before any open) — the payload never ships one.
|
||||
if (try? fileManager.destinationOfSymbolicLink(atPath: lhsPath)) != nil
|
||||
|| (try? fileManager.destinationOfSymbolicLink(atPath: rhsPath)) != nil
|
||||
{
|
||||
if isSymlinked(lhsPath) || isSymlinked(rhsPath) {
|
||||
return false
|
||||
}
|
||||
var lhsIsDirectory: ObjCBool = false, rhsIsDirectory: ObjCBool = false
|
||||
|
||||
Reference in new issue
Block a user