mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-29 11:52:50 +01:00
feat(flavor): read komorebi for Mac and for Windows
Which komorebi produced a session is a separate axis from the host the recorder ran on. `Flavor` names the two and `Rules` holds what each knows: what its events look like on the wire, which of them move a window, and which are komorebi making things up. komorebi for Mac and komorebi for Windows each implement it, and a missing method is a compile error. The Windows rules were written from komorebi's source and say so until a recording confirms them. Events are classified through the rules, and the names of things in a session (`event:12`, `log:7`) are parsed here too, with the envelope and exit codes every command will answer in.
This commit is contained in:
1 parent
d5eacecef8
commit
0de0f82840
11 files changed
+2488
-5
No files matched your search
@@ -10,6 +10,11 @@ Two things about it vary independently, and everything below is arranged so that
|
||||
| axis | what varies | where the variation lives | what a session records |
|
||||
|---|---|---|---|
|
||||
| host | the OS the recorder runs on: macOS or Windows (a third `unsupported` host builds anywhere) | [`platform`](../komorebi-recorder/src/platform/mod.rs), selected by `cfg` | `host` in the manifest |
|
||||
| flavor | the komorebi being recorded: komorebi for Mac or komorebi for Windows | `Rules` in [`analysis::flavor`](../komorebi-recorder/src/analysis/flavor/mod.rs), selected by data | `komorebi.flavor` in the manifest |
|
||||
|
||||
They are independent because a session recorded on one host is investigated on whichever machine the investigator has.
|
||||
A session recorded on Windows is read on a Mac, and the other way round, so reading never asks which host it is
|
||||
running on: it asks the session.
|
||||
|
||||
## The master clock
|
||||
|
||||
@@ -43,9 +48,27 @@ only on a third OS.
|
||||
Where one host has no analogue of something, the facade function exists on both and one answers "nothing": `trace::start`
|
||||
on the `unsupported` host returns no taps and a line saying so, and `power::start` returns no watcher.
|
||||
|
||||
## Flavors and rules
|
||||
|
||||
Which komorebi produced a session decides what its events mean (a process id and an accessibility notification on a Mac,
|
||||
a window handle and a WinEvent on Windows), how it hides a window (by moving it to a corner on a Mac, by cloaking it in
|
||||
place on Windows) and how its log marks where a handler starts and ends. `Flavor` names the two and is recorded in the
|
||||
manifest. `Rules` is the trait that holds what each knows, and `Flavor::rules` is where a name becomes rules. Code that
|
||||
reads komorebi's output asks `Rules` and does not match on `Flavor`; only convention holds that, and it has exceptions:
|
||||
the index of komorebi's source that log lines are mapped to, and the places the log and a checkout of the source are
|
||||
looked for on disk, are keyed by `Flavor` directly.
|
||||
|
||||
The contract is a counting rule: a flavor implements every method of `Rules` that has no default, and the compiler
|
||||
refuses an implementor that misses one. A method with a default is a question most flavors answer the same way, and the
|
||||
doc of each says what the default is. `Rules::verified` is how a flavor says that its rules were written from komorebi's
|
||||
source and have not been checked against a recording of it: an analysis that reads such a session says so.
|
||||
|
||||
## Rules and the layer that enforces them
|
||||
|
||||
| Rule | Enforced by |
|
||||
|---|---|
|
||||
| Every host provides the same functions with the same signatures | the compiler, for the host being built; `just check-windows` and CI build the Windows host from a Mac; nothing builds `unsupported` |
|
||||
| A timestamp in a session is on the master clock | convention, and the tests that place records at known times: the type is a plain `u64` |
|
||||
| An implementor of `Rules` answers every question that has no default | the type system: a missing method is E0046, proved by a `compile_fail` example on `Rules` |
|
||||
| Code that reads komorebi's output asks `Rules` and does not match on `Flavor` | convention only |
|
||||
| Rules that were not checked against a recording of komorebi say so | the framework path: an analysis that reads such a session adds a warning |
|
||||
Reference in new issue
Block a user