Skip to content

feat(bootstrap): add audit installation#7

Merged
esifea merged 3 commits into
CryptoLabInc:mainfrom
esifea:feat/esifea/audit-install
Jun 1, 2026
Merged

feat(bootstrap): add audit installation#7
esifea merged 3 commits into
CryptoLabInc:mainfrom
esifea:feat/esifea/audit-install

Conversation

@esifea
Copy link
Copy Markdown
Contributor

@esifea esifea commented May 31, 2026

TSIA

@esifea esifea self-assigned this May 31, 2026
@esifea esifea force-pushed the feat/esifea/audit-install branch from 7a46c00 to 5075ede Compare May 31, 2026 07:44
@esifea esifea marked this pull request as ready for review May 31, 2026 07:49
Comment thread internal/bootstrap/audit.go Outdated
@jh-lee-cryptolab
Copy link
Copy Markdown
Contributor

Refactor suggestion: return the resolved spec from ensure* instead of re-resolving in the audit block

The audit block re-calls m.LlamaServerForCurrentPlatform() / m.ModelSpec(variant). This carries two issues with a single shared root cause:

1. Latent nil panic (correctness)install.go:98,135

llamaSpec, _ := m.LlamaServerForCurrentPlatform() // returns *LlamaServerSpec, nil on error
... llamaSpec.URL ...                              // panics if nil

Currently safe only because the audit block runs after ensureLlamaServer already succeeded on the same immutable manifest — an implicit ordering invariant that a future refactor can silently break. (ModelSpec is safe by contrast: it returns a value ArtifactSpec{}, so the two functions are asymmetric in risk.)

2. Redundant lookup — the spec resolved in the audit block is the exact value ensureLlamaServer/ensureModel already resolved moments earlier under the same lock.

Proposal

Have the internal helpers return the spec they already resolved, rather than looking it up a second time:

func ensureLlamaServer(...) (string, *LlamaServerSpec, error) { ... return target, spec, nil }
func ensureModel(...)       (string, ArtifactSpec, error)     { ... return target, spec, nil }
llamaBin, llamaSpec, err := ensureLlamaServer(...)
if err != nil { return ..., err }
modelPath, modelSpec, err := ensureModel(...)
if err != nil { return ..., err }

// audit block: the `llamaSpec, _ := ...` re-resolve line is gone entirely

Result

Scope: ensureLlamaServer/ensureModel are unexported; the only callers are EnsureAll/EnsureLlamaServer/EnsureModel. No public API change.

Copy link
Copy Markdown
Contributor

@couragehong couragehong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread internal/bootstrap/audit.go Outdated
}

type InstalledArtifact struct {
// Tarbar info
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: tarball?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Contributor

@jh-lee-cryptolab jh-lee-cryptolab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@esifea esifea merged commit ad361c6 into CryptoLabInc:main Jun 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants