Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ Migration:

Existing v0.3 collections are not offered migration.

## Runtime integration

Companion plugins can access the selected mdbase runtime host through:

```ts
app.plugins.getPlugin("mdbase-obsidian")?.api.runtime
```

The host remains default-deny. In v0.3 collections it validates and loads the
selected `runtime.policy` record and fails closed for missing, invalid,
disabled, or out-of-vault policies.

## Application interoperability

The plugin also hosts local application interoperability for companion plugins:
Expand All @@ -98,7 +86,9 @@ records the exact contract version and digest plus application and
implementation identity.

The bridge is cooperative, same-process transport for Obsidian plugins. It does
not claim durable delivery or cross-device execution.
not claim to be a durable runtime: workflows, scheduling, retries, recovery,
and runtime-policy admission belong to a Runtime 0.2 host such as Connect. It
does not claim durable delivery or cross-device execution.

## Development

Expand Down
246 changes: 123 additions & 123 deletions main.js

Large diffs are not rendered by default.

56 changes: 0 additions & 56 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ import {
WorkspaceLeaf,
normalizePath,
} from "obsidian";
import {
DEFAULT_DENY_RUNTIME_POLICY,
InMemoryRuntimeHost,
type MdbaseRuntimeHostApi,
type MdbaseRuntimePolicyInfo,
} from "@callumalpass/mdbase-runtime";
import {
ObsidianInteropBridge,
type MdbaseObsidianInteropApi,
Expand All @@ -42,10 +36,6 @@ import {
validateFile,
} from "./src/mdbaseCore";
import type { TypeEditorModel } from "./src/typeEditorTypes";
import {
loadSelectedRuntimePolicy,
type RuntimePolicyDiagnostic,
} from "./src/runtimePolicy";
import {
ConnectSyncController,
type MirrorProfile,
Expand Down Expand Up @@ -480,13 +470,7 @@ interface LoadedSchema {

export interface MdbaseObsidianApiV1 {
readonly apiVersion: 1;
readonly runtime: MdbaseRuntimeHostApi;
readonly interop: MdbaseObsidianInteropApi;
getRuntimeStatus(): {
policyId: string;
policyPath?: string;
diagnostics: RuntimePolicyDiagnostic[];
};
getInteropStatus(): {
enabled: boolean;
profileVersion: "0.1";
Expand All @@ -504,13 +488,6 @@ export default class MdbasePlugin extends Plugin {
private schemaLoadPromise: Promise<LoadedSchema | null> | null = null;
private pendingSaveValidations = new Map<string, number>();
private readonly saveValidationDebounceMs = 250;
private runtimePolicy: MdbaseRuntimePolicyInfo = {
...DEFAULT_DENY_RUNTIME_POLICY,
capabilities: { ...DEFAULT_DENY_RUNTIME_POLICY.capabilities },
};
private runtimePolicyPath: string | undefined;
private runtimePolicyDiagnostics: RuntimePolicyDiagnostic[] = [];
private runtimePolicyRefreshGeneration = 0;
private readonly interopBridge: ObsidianInteropBridge;

constructor(app: App, manifest: import("obsidian").PluginManifest) {
Expand All @@ -525,13 +502,7 @@ export default class MdbasePlugin extends Plugin {
this.interopBridge = new ObsidianInteropBridge(app, () => this.settings?.interopEnabled === true);
this.api = {
apiVersion: 1,
runtime: new InMemoryRuntimeHost({ policyResolver: () => this.runtimePolicy }),
interop: this.interopBridge,
getRuntimeStatus: () => ({
policyId: this.runtimePolicy.id,
policyPath: this.runtimePolicyPath,
diagnostics: this.runtimePolicyDiagnostics.map((diagnostic) => ({ ...diagnostic })),
}),
getInteropStatus: () => ({
enabled: this.settings?.interopEnabled === true,
profileVersion: "0.1",
Expand All @@ -542,7 +513,6 @@ export default class MdbasePlugin extends Plugin {
async onload(): Promise<void> {
await this.loadSettings();
await this.connectSync.initialize();
await this.refreshRuntimePolicy();
addIcon(MDBASE_ICON_ID, MDBASE_ICON_SVG);

this.statusBarEl = this.addStatusBarItem();
Expand Down Expand Up @@ -663,7 +633,6 @@ export default class MdbasePlugin extends Plugin {

async onunload(): Promise<void> {
await this.interopBridge.dispose();
await this.api.runtime.dispose();
this.app.workspace.getLeavesOfType(MDBASE_WORKSPACE_VIEW).forEach((leaf) => leaf.detach());
this.app.workspace.getLeavesOfType(MDBASE_ISSUES_VIEW).forEach((leaf) => leaf.detach());
this.clearAllPendingSaveValidations();
Expand Down Expand Up @@ -757,7 +726,6 @@ export default class MdbasePlugin extends Plugin {
);
}
this.invalidateSchemaCache();
await this.refreshRuntimePolicy();
new Notice(`Migrated to mdbase v0.3. Recovery manifest: ${result.manifestPath}`);
this.refreshWorkspaceViews(true);
}
Expand Down Expand Up @@ -1041,7 +1009,6 @@ export default class MdbasePlugin extends Plugin {
}

private onVaultModify(file: TFile): void {
if (this.isRuntimePolicyRelevantPath(file.path)) void this.refreshRuntimePolicy();
if (this.isSchemaRelevantPath(file.path)) {
this.invalidateSchemaCache();
this.refreshWorkspaceViews();
Expand All @@ -1053,9 +1020,6 @@ export default class MdbasePlugin extends Plugin {
}

private onVaultRename(file: TFile, oldPath: string): void {
if (this.isRuntimePolicyRelevantPath(oldPath) || this.isRuntimePolicyRelevantPath(file.path)) {
void this.refreshRuntimePolicy();
}
if (this.isSchemaRelevantPath(oldPath) || this.isSchemaRelevantPath(file.path)) {
this.invalidateSchemaCache();
this.refreshWorkspaceViews();
Expand All @@ -1072,7 +1036,6 @@ export default class MdbasePlugin extends Plugin {
}

private onVaultDelete(file: TFile): void {
if (this.isRuntimePolicyRelevantPath(file.path)) void this.refreshRuntimePolicy();
if (this.isSchemaRelevantPath(file.path)) {
this.invalidateSchemaCache();
this.refreshWorkspaceViews();
Expand All @@ -1084,31 +1047,12 @@ export default class MdbasePlugin extends Plugin {
}

private onVaultCreate(file: TFile): void {
if (this.isRuntimePolicyRelevantPath(file.path)) void this.refreshRuntimePolicy();
if (this.isSchemaRelevantPath(file.path)) {
this.invalidateSchemaCache();
this.refreshWorkspaceViews();
}
}

private isRuntimePolicyRelevantPath(path: string): boolean {
const normalized = normalizePath(path);
return normalized === "mdbase.yaml" || normalized === this.runtimePolicyPath;
}

private async refreshRuntimePolicy(): Promise<void> {
const generation = ++this.runtimePolicyRefreshGeneration;
const config = await loadMdbaseConfig(this.app.vault);
const selected = await loadSelectedRuntimePolicy(this.app.vault, config);
if (generation !== this.runtimePolicyRefreshGeneration) return;
this.runtimePolicy = selected.policy;
this.runtimePolicyPath = selected.path;
this.runtimePolicyDiagnostics = selected.diagnostics;
for (const diagnostic of selected.diagnostics) {
console.warn(`[mdbase/runtime] ${diagnostic.code}: ${diagnostic.message}`);
}
}

private async validateFileAndStore(file: TFile, reason: "save" | "open" | "manual"): Promise<MdbaseIssue[]> {
const loaded = await this.requireConfigAndTypes({ background: reason !== "manual" });
if (!loaded) {
Expand Down
13 changes: 0 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
},
"dependencies": {
"@callumalpass/mdbase-interop": "file:vendor/callumalpass-mdbase-interop-0.1.0-rc.2.tgz",
"@callumalpass/mdbase-runtime": "0.1.0-rc.1",
"@mdbase/connect-protocol": "file:vendor/mdbase-connect-protocol-0.1.0-beta.11.tgz",
"@mdbase/connect-sync": "file:vendor/mdbase-connect-sync-0.1.0-beta.11.tgz",
"ajv": "^8.20.0",
Expand Down
109 changes: 0 additions & 109 deletions src/runtimePolicy.ts

This file was deleted.

Loading
Loading