id: doctor kind: intent statement: “THE doctor command SHALL classify the workspace mode and warn — never fail — when the binary’s embedded format knowledge lags the local corpus.”
doctor Specification
Purpose
Diagnose a workspace’s specodelic setup from inside the binary: classify the workspace as self-hosting or consumer, check the local corpus against the embedded format knowledge, and report findings over the standard envelope without failing on informational conditions.
Constraints
| id | kind | expr | traces_to |
|---|---|---|---|
| process_lifecycle | invariant | the capability advances through its declared lifecycle states under the repo's change process — each stage transition fires only when its stage gate holds | [[doctor]] |
| mode_detection | invariant | workspace classifies as self_hosting when openspec/specs/specodelic/spec.md exists and consumer otherwise, with the mode reported in envelope data | [[doctor]] |
| currency_warning | invariant | whenever a local corpus exists, the latest Revision N heading is compared numerically against FORMAT_REVISION; a lagging binary warns without failing; unreadable or revision-less corpora skip with an informational note | [[doctor]] |
Model
States
probedclassifiedcurrency_checked
Transitions
| id | from | to | guard |
|---|---|---|---|
| classify | probed | classified | [[doctor.mode_detection]] |
| currency | classified | currency_checked | [[doctor.currency_warning]] |
Properties
| id | kind | derives_from | generator | predicate |
|---|---|---|---|---|
| process_lifecycle_checked | unit | [[doctor.process_lifecycle]] | lifecycle_model_present() | check(file) == passed |
| p_mode | unit | [[doctor.mode_detection]] | arbitrary_workspace() | mode == expected(ws) ∧ mode ∈ envelope_data |
| p_currency | unit | [[doctor.currency_warning]] | arbitrary_corpus_state() | lag ⇒ warning ∧ ¬failure ∧ skip ⇒ note |
Requirements
Requirement: Workspace Mode Detection
spk doctor SHALL classify the workspace as self_hosting when
openspec/specs/specodelic/spec.md exists, and consumer otherwise, and SHALL
report the detected mode in its envelope data.
Scenario: Self-hosting corpus
- WHEN
spk doctorruns in a workspace containingopenspec/specs/specodelic/spec.md - THEN the envelope reports mode
self_hostingand keeps today’s checks (specs directory, core format spec, beads)
Scenario: Consumer workspace without the core spec
- WHEN
spk doctorruns in a workspace with aspecs/directory but noopenspec/specs/specodelic/spec.md - THEN the envelope reports mode
consumer, the check for the core spec does not fail the command, and the envelope reports the embedded guide’sformat_revisionas ok
Scenario: Empty workspace
- WHEN
spk doctorruns in a directory with nospecs/at all - THEN the envelope reports mode
consumerwith an informational note suggestingspk newto start a corpus, and exits 0
Requirement: Doctor Reports Knowledge Currency
spk doctor SHALL — in any mode, whenever a local corpus is present
(vendored consumer corpora included) — extract
the latest Revision N heading (numerically largest trailing integer)
from the local openspec/specs/specodelic/spec.md and SHALL emit a warning — not a
failure — when that revision is newer than the binary’s embedded
FORMAT_REVISION. A corpus with no Revision heading skips the
currency check with an informational note.
Scenario: Corpus file is unreadable
- WHEN the local
openspec/specs/specodelic/spec.mdexists but cannot be read (permissions, non-UTF-8 content) - THEN the currency check is skipped with an informational warning naming the read error, and the command neither fails nor claims the corpus is current
Scenario: Binary lags local corpus
- WHEN
spk doctorruns in a workspace whose vendoredopenspec/specs/specodelic/spec.mddeclaresRevision 8while the binary embedsRevision 7 - THEN the envelope contains a warning naming both revisions and exits 0
Scenario: Binary current
- WHEN
spk doctorruns in a workspace whose corpus revision equals the embeddedFORMAT_REVISION - THEN no knowledge-currency warning is emitted
Scenario: Corpus carries no revision headings
- WHEN
spk doctorruns in a workspace whoseopenspec/specs/specodelic/spec.mdcontains noRevision Nheading - THEN the currency check is skipped with an informational note and the command neither warns nor fails