Documentation
¶
Overview ¶
Package unswell analyzes English prose offline with an extensible rule engine. It never discovers files, reads environment variables, prints, exits, or uses the network. Style findings are results; operational failures are Go errors.
Index ¶
Constants ¶
const SchemaVersion = "1.0.0-alpha.1"
SchemaVersion versions the saved result contract independently of CLI flags.
const Version = "0.1.0-alpha.1"
Version is the release identity used in canonical results.
Variables ¶
var BuildCommit = "development"
BuildCommit identifies release builds. Set it with -ldflags at build time. Applications should not change this value while engines are running.
Functions ¶
This section is empty.
Types ¶
type Assessment ¶
type Assessment struct {
Path string `json:"path"`
Scope string `json:"scope"`
UnitID int `json:"unit_id"`
Span document.Span `json:"span"`
Words int `json:"words"`
SlopScore float64 `json:"slop_score"`
EffectiveSlopScore float64 `json:"effective_slop_score"`
SlopProbability *float64 `json:"slop_probability"`
ProbabilityStatus string `json:"probability_status"`
Status string `json:"status"`
Contributions []Contribution `json:"contributions"`
}
Assessment is a local, nondilutable index. Probability is unavailable in alpha.
type Contribution ¶
type Contribution struct {
FindingID string `json:"finding_id"`
RuleID string `json:"rule_id"`
Group string `json:"group"`
Weight int `json:"weight"`
Activation int `json:"activation"`
Raw float64 `json:"raw"`
Effective float64 `json:"effective"`
RuleCap int `json:"rule_cap"`
GroupCap int `json:"group_cap"`
Reason string `json:"reason"`
}
Contribution explains fixed-point scoring and the effects of caps and deduplication.
type DocumentResult ¶
type DocumentResult struct {
Name string `json:"name"`
Format document.Format `json:"format"`
SourceHash string `json:"source_hash"`
Bytes int `json:"bytes"`
ProseWords int `json:"prose_words"`
Blocks int `json:"blocks"`
Sentences int `json:"sentences"`
Excluded []document.Exclusion `json:"excluded"`
Source string `json:"source,omitempty"`
Maximum float64 `json:"paragraph_maximum"`
Median float64 `json:"paragraph_median"`
P90 float64 `json:"paragraph_p90"`
FlaggedFraction float64 `json:"eligible_paragraph_flagged_fraction"`
}
DocumentResult summarizes one source without including its prose by default.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is immutable after construction and supports concurrent calls. Custom rule and NLP implementations must uphold their documented concurrency contract.
type Finding ¶
type Finding struct {
ID string `json:"id"`
RuleID string `json:"rule_id"`
RuleVersion string `json:"rule_version"`
Severity string `json:"severity"`
Gate string `json:"gate"`
Group string `json:"group"`
Scope string `json:"scope"`
Message string `json:"message"`
Primary Location `json:"primary"`
Related []Location `json:"related"`
Evidence rule.Evidence `json:"evidence"`
Fingerprint string `json:"fingerprint"`
Suppressed bool `json:"suppressed"`
BaselineState string `json:"baseline_state"`
Derived bool `json:"derived"`
}
Finding is a rule activation enriched with policy, identity, and source locations.
type GateDecision ¶
type GateDecision struct {
Passed bool `json:"passed"`
Reasons []GateReason `json:"reasons"`
}
GateDecision reports policy separately from operational completion.
type GateReason ¶
type GateReason struct {
Code string `json:"code"`
Path string `json:"path"`
FindingID string `json:"finding_id"`
Message string `json:"message"`
}
GateReason identifies the exact local condition behind a policy failure.
type Location ¶
type Location struct {
Path string `json:"path"`
Span document.Span `json:"span"`
Start document.Position `json:"start"`
End document.Position `json:"end"`
Segments []document.Span `json:"segments"`
Snippet string `json:"snippet,omitempty"`
}
Location contains original byte spans and Unicode code point positions.
type Manifest ¶
type Manifest struct {
ToolVersion string `json:"tool_version"`
ToolCommit string `json:"tool_commit"`
ConfigHash string `json:"config_hash"`
RulesetHash string `json:"ruleset_hash"`
ScoringProfile string `json:"scoring_profile"`
FeatureContract string `json:"feature_contract"`
NLP nlp.Identity `json:"nlp"`
Rules []rule.Descriptor `json:"rules"`
SelectionMode string `json:"selection_mode"`
Complete bool `json:"complete"`
NoGate bool `json:"no_gate"`
IncludeSource bool `json:"include_source"`
SkippedRules []string `json:"skipped_rules"`
}
Manifest records the exact execution policy and feature versions, without time.
type Options ¶
type Options struct {
Config []byte
Rules []rule.Rule
NLP nlp.Provider
Jobs int
IncludeSource bool
AllowEmpty bool
NoGate bool
}
Options injects all inputs. A nil Rules slice selects the builtin catalog; a nonnil slice is the complete registry. Config is YAML bytes, never a path.
type Result ¶
type Result = RunResult
Result is the same report contract restricted to one source by Analyze.
type RunResult ¶
type RunResult struct {
SchemaVersion string `json:"schema_version"`
Status string `json:"status"`
Manifest Manifest `json:"manifest"`
Documents []DocumentResult `json:"documents"`
Findings []Finding `json:"findings"`
Assessments []Assessment `json:"assessments"`
Gate GateDecision `json:"gate"`
Errors []RunError `json:"errors"`
}
RunResult is the immutable input shared by every reporter. Returned slices are owned by the caller and do not alias the engine.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package builtin constructs the versioned alpha rule catalog without init hooks.
|
Package builtin constructs the versioned alpha rule catalog without init hooks. |
|
cmd
|
|
|
genschema
command
Command genschema derives the saved-result JSON schema from the public types.
|
Command genschema derives the saved-result JSON schema from the public types. |
|
repocheck
command
Command repocheck validates the repository's source and CI contracts.
|
Command repocheck validates the repository's source and CI contracts. |
|
unswell
command
Command unswell checks English prose against a local editorial policy.
|
Command unswell checks English prose against a local editorial policy. |
|
Package config compiles strict, offline YAML policy against an explicit catalog.
|
Package config compiles strict, offline YAML policy against an explicit catalog. |
|
Package document defines source coordinates and the neutral prose model.
|
Package document defines source coordinates and the neutral prose model. |
|
Package extract provides source-preserving prose extraction from text and syntax trees.
|
Package extract provides source-preserving prose extraction from text and syntax trees. |
|
goanalysis
module
|
|
|
internal
|
|
|
cli
Package cli owns command parsing, filesystem discovery, streams, and exit codes.
|
Package cli owns command parsing, filesystem discovery, streams, and exit codes. |
|
mapping
Package mapping builds source-preserving normalized prose.
|
Package mapping builds source-preserving normalized prose. |
|
pathglob
Package pathglob compiles bounded project-relative path patterns.
|
Package pathglob compiles bounded project-relative path patterns. |
|
repopolicy
Package repopolicy checks repository contracts against the actual source tree.
|
Package repopolicy checks repository contracts against the actual source tree. |
|
Package nlp defines the backend contract without exposing vendor types.
|
Package nlp defines the backend contract without exposing vendor types. |
|
english
Package english adapts Prose's tokenizer, Punkt segmenter, and POS tagger.
|
Package english adapts Prose's tokenizer, Punkt segmenter, and POS tagger. |
|
Package report renders a completed result without analyzing or reading sources.
|
Package report renders a completed result without analyzing or reading sources. |
|
Package rule defines explicit rule registration, evidence, and configuration.
|
Package rule defines explicit rule registration, evidence, and configuration. |