From 7f051b7d812807bcaed6ad03159f60cdc6234035 Mon Sep 17 00:00:00 2001 From: Tydalia Date: Wed, 7 Oct 2026 22:05:55 +0200 Subject: [PATCH 1/3] fullframe can ask aity suggestions --- CHANGELOG.md | 13 ++ .../API/VaultNamespaceController.php | 51 ++++++- backend/app/Services/GalleryVaultWriter.php | 33 ++++- backend/app/Services/VaultIngest.php | 73 ++++++++++ backend/routes/web.php | 12 ++ backend/tests/Feature/VaultIngestOpsTest.php | 126 ++++++++++++++++-- client/CHANGELOG.md | 7 + client/README.md | 8 ++ client/src/__tests__/vault.test.ts | 18 +++ client/src/index.ts | 2 + client/src/vault.ts | 29 ++++ docs/architecture/VAULT_WRITE_METHODS.md | 27 +++- 12 files changed, 381 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c960ca..5da8778 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,19 @@ All notable changes to TYDAL are documented here. The format follows ## [Unreleased] +### Added + +- **AITY suggestions at the vault write boundary.** A gallery `ingest` with + `suggest: true` runs AITY on the stored photograph — opt-in per photograph, + because the consumer may hold the photographer's consent for some and not + others. AITY only proposes; what the consumer sent is never changed, and + AITY failing never fails the ingest. `GET …/w/suggestions?resources=…` + returns the proposed title and description per ingested resource (`off`, + `pending`, `done`, `failed`) to a key that may `update`; reading never + starts AITY. + `@tydal/client` gets `suggestions(resources)`. See + `docs/architecture/VAULT_WRITE_METHODS.md` §3. + ## [1.4.1] — 2026-10-06 ### Added diff --git a/backend/app/Http/Controllers/API/VaultNamespaceController.php b/backend/app/Http/Controllers/API/VaultNamespaceController.php index cb5848c..a2bacca 100644 --- a/backend/app/Http/Controllers/API/VaultNamespaceController.php +++ b/backend/app/Http/Controllers/API/VaultNamespaceController.php @@ -420,6 +420,53 @@ private function writeInfo(?Vault $vault, Request $request, VaultIngest $ingest) return $this->vaultJson($body); } + /** + * AITY's proposals for resources this vault ingested (VAULT_WRITE_METHODS.md + * §5) — a read beside the write probe, for a key that may `update`: whoever + * can apply a suggestion may see it. Not a write, so it isn't audited and a + * consumer can poll it while the pipeline runs. `resources` is a + * comma-separated list of the hashes `ingest` returned. Reading never + * starts AITY: only an `ingest` with `suggest` does. + */ + public function hashVaultSuggestions(string $vaultHash, Request $request, VaultIngest $ingest): JsonResponse + { + return $this->suggestions(Vault::findByHashCached($vaultHash), $request, $ingest); + } + + /** Human-form suggestions read — same gate as the hash form. */ + public function vaultSuggestions(string $orgSlug, string $vaultSlug, Request $request, VaultIngest $ingest): JsonResponse + { + return $this->suggestions(Vault::findBySlugsCached($orgSlug, $vaultSlug), $request, $ingest); + } + + private function suggestions(?Vault $vault, Request $request, VaultIngest $ingest): JsonResponse + { + $probe = $this->links->writeCapabilities($vault, $request->ip(), $this->vaultKey($request)); + + if ($probe['status'] !== 200 || ! $vault) { + return $this->vaultJson( + ['ok' => false, 'error' => $probe['error'] ?? 'Not found or expired'], + $probe['status'] === 200 ? 404 : $probe['status'], + ); + } + if (! in_array('update', $probe['methods'], true)) { + return $this->vaultJson(['ok' => false, 'error' => 'This key may not update resources here.'], 403); + } + + $hashes = array_values(array_filter(array_map( + 'trim', + explode(',', (string) $request->query('resources', '')), + ))); + if ($hashes === [] || count($hashes) > VaultIngest::MAX_SUGGESTION_RESOURCES) { + return $this->vaultJson([ + 'ok' => false, + 'error' => 'Give 1 to '.VaultIngest::MAX_SUGGESTION_RESOURCES.' resource hashes in `resources`.', + ], 400); + } + + return $this->vaultJson(['ok' => true, 'suggestions' => (object) $ingest->suggestions($vault, $hashes)]); + } + private function dispatchWrite(?Vault $vault, string $method, Request $request, GalleryVaultWriter $writer, AiVaultWriter $aiWriter, VaultIngest $ingest): JsonResponse { $auth = $this->links->authorizeWrite($vault, $method, $request->ip(), $this->vaultKey($request)); @@ -526,7 +573,9 @@ private function dispatchIngest(Vault $vault, Request $request, GalleryVaultWrit return $aiWriter->ingest($vault, $document, $descriptor, $image); } - return $writer->ingest($vault, $document, $image); + // AITY runs only when the consumer asks: it may hold the photographer's + // consent for some photographs and not for others. + return $writer->ingest($vault, $document, $image, $request->boolean('suggest')); } public function hashEntry(string $vaultHash, string $linkHash, Request $request): StreamedResponse|JsonResponse diff --git a/backend/app/Services/GalleryVaultWriter.php b/backend/app/Services/GalleryVaultWriter.php index 23bae9f..01032b2 100644 --- a/backend/app/Services/GalleryVaultWriter.php +++ b/backend/app/Services/GalleryVaultWriter.php @@ -13,6 +13,7 @@ use App\Services\Interfaces\ResourceServiceInterface; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; use Illuminate\Validation\ValidationException; @@ -33,6 +34,7 @@ public function __construct( private ResourceServiceInterface $resources, private VaultLinkService $links, private VaultIngest $ingest, + private AityEnrichmentService $aity, ) {} /** @@ -41,8 +43,12 @@ public function __construct( * preview. The metadata document is already split by VaultIngest; the * gallery requires `name` (the author owns the title). The stored filename * is derived from it, so the uploader's filename (often a person's name) - * never reaches TYDAL. Nothing here rewrites what the consumer sent — no AI - * enrichment runs on it. + * never reaches TYDAL. Nothing here rewrites what the consumer sent. With + * `$suggest` (the consumer holds the photographer's consent to it), AITY + * runs on the stored photograph, but only *proposes* a title and a + * description, which the consumer reads back through `suggestions` + * (VaultIngest::suggestions) and applies, or not, with `update`. Without + * it, the photograph never reaches an AI service. * * Refused when the target workspace isn't projected by this vault — the * photo would be written but never shown (e.g. after an `activate`, whose @@ -51,7 +57,7 @@ public function __construct( * @param array{columns: array, metadata: array} $document * @return array{hash: string, name: string} */ - public function ingest(Vault $vault, array $document, UploadedFile $image): array + public function ingest(Vault $vault, array $document, UploadedFile $image, bool $suggest = false): array { $name = $document['columns']['name'] ?? null; if ($name === null) { @@ -76,7 +82,7 @@ public function ingest(Vault $vault, array $document, UploadedFile $image): arra ]); } - return DB::transaction(function () use ($vault, $document, $name, $image, $workspace, $collection): array { + [$summary, $file] = DB::transaction(function () use ($vault, $document, $name, $image, $workspace, $collection): array { $metadata = array_filter($document['metadata'], fn ($v) => $v !== null); $resource = $this->resources->createResource([ @@ -94,7 +100,7 @@ public function ingest(Vault $vault, array $document, UploadedFile $image): arra $stem = Str::slug($name) ?: 'photograph'; // Images are their own snapshot (the preview every card shows). - $this->ingest->attachFile( + $file = $this->ingest->attachFile( $resource, (string) $image->getRealPath(), "{$stem}.{$extension}", @@ -111,8 +117,23 @@ public function ingest(Vault $vault, array $document, UploadedFile $image): arra $link = $this->links->getOrCreateLink($vault, null, $resource->id, null); - return ['hash' => $link->hash, 'name' => $name]; + return [['hash' => $link->hash, 'name' => $name], $file]; }); + + if (! $suggest) { + return $summary; + } + + // After the commit, so the queued jobs find the rows. The photograph is + // stored either way: AITY failing (e.g. on a sync queue) must not turn + // a done ingest into an error the consumer would retry into a duplicate. + try { + $this->aity->enrich($file); + } catch (\Throwable $e) { + Log::warning('Vault ingest: AITY could not start', ['file_id' => $file->id, 'error' => $e->getMessage()]); + } + + return $summary; } /** diff --git a/backend/app/Services/VaultIngest.php b/backend/app/Services/VaultIngest.php index 1e5428b..16b5fab 100644 --- a/backend/app/Services/VaultIngest.php +++ b/backend/app/Services/VaultIngest.php @@ -8,6 +8,7 @@ use App\Models\Collection; use App\Models\File; use App\Models\Resource; +use App\Models\SystemFile; use App\Models\Vault; use App\Models\VaultLink; use App\Models\VaultWrite; @@ -29,6 +30,8 @@ * keys naming a resource column (`name`, `description`) are lifted into it, * the rest are stored in `resources.metadata` as given. No AI and no scheme * check touch it — the scheme only decides which keys get indexed/faceted. + * AITY may *propose* values when the consumer asks (`ingest` with `suggest`, + * read back with `suggestions`); only the consumer applies them. * - **Provenance.** `update`/`withdraw` act only on resources this vault's * `ingest` created; the `vault_writes` audit is the record. */ @@ -41,6 +44,9 @@ class VaultIngest private const MAX_VALUE_LENGTH = 5000; + /** Most resources one `suggestions` read reports on. */ + public const MAX_SUGGESTION_RESOURCES = 100; + public function __construct( private ResourceServiceInterface $resources, ) {} @@ -287,6 +293,73 @@ public function withdraw(Vault $vault, string $hash): array return ['withdrawn' => $hash]; } + /** + * What AITY proposes for resources this vault ingested — the read beside + * the write probe (VAULT_WRITE_METHODS.md §5), for a consumer that may + * `update` them. Per hash: `status` (`off` when AITY was never asked to + * run on it, `pending` while the pipeline runs, `done` once it has + * finished — with or without a proposal — or `failed`) and the latest + * proposed `name` / `description` (null when none). Reading never starts + * AITY: whether a photograph may reach an AI service is the consumer's + * call, made at `ingest`. Hashes this vault did not ingest are left out, + * like everywhere else on the boundary. + * + * @param list $hashes + * @return array + */ + public function suggestions(Vault $vault, array $hashes): array + { + $ingested = array_values(array_intersect(array_unique($hashes), $this->ingested($vault))); + if ($ingested === []) { + return []; + } + + $links = VaultLink::where('vault_id', $vault->id) + ->whereNull('file_id') + ->whereIn('hash', $ingested) + ->pluck('resource_id', 'hash'); + + $files = File::whereIn('resource_id', $links->values()) + ->committed() + ->where('role', FileRole::CANONICAL) + ->with([ + 'latestAiSuggestedNameSystemFileForDisplay', + 'latestAiSuggestedDescriptionSystemFileForDisplay', + ]) + ->get() + ->keyBy('resource_id'); + + $report = []; + foreach ($links as $hash => $resourceId) { + $file = $files->get($resourceId); + if (! $file) { + continue; + } + + $stage = $file->processing_status['stage'] ?? null; + + $report[$hash] = [ + 'status' => match ($stage) { + null => 'off', + 'done', 'not_applicable' => 'done', + 'failed' => 'failed', + default => 'pending', + }, + 'name' => $this->suggested($file->latestAiSuggestedNameSystemFileForDisplay), + 'description' => $this->suggested($file->latestAiSuggestedDescriptionSystemFileForDisplay), + ]; + } + + return $report; + } + + private function suggested(?SystemFile $suggestion): ?string + { + $value = $suggestion?->metadata['value'] ?? null; + + return is_string($value) && trim($value) !== '' ? trim($value) : null; + } + private function ingestedResource(Vault $vault, string $hash): Resource { $ingested = VaultWrite::where('vault_id', $vault->id) diff --git a/backend/routes/web.php b/backend/routes/web.php index 9615ecd..4a209cf 100644 --- a/backend/routes/web.php +++ b/backend/routes/web.php @@ -58,6 +58,13 @@ ->middleware('throttle:30,1') ->name('h.vault.write.info'); +// AITY's proposals for ingested resources — a read beside the write probe, +// gated by a key that may `update`. Polled while the pipeline runs, hence the +// looser throttle. +Route::get('/h/{vaultHash}/w/suggestions', [VaultNamespaceController::class, 'hashVaultSuggestions']) + ->middleware('throttle:60,1') + ->name('h.vault.write.suggestions'); + Route::get('/h/{vaultHash}/{linkHash}', [VaultNamespaceController::class, 'hashEntry']) ->name('h.serve'); @@ -94,6 +101,11 @@ ->middleware('throttle:30,1') ->name('v.write.info'); + // Before {resourceSlug}/{fileSlug}, which would read it as a file. + Route::get('/w/suggestions', 'vaultSuggestions') + ->middleware('throttle:60,1') + ->name('v.write.suggestions'); + Route::get('/{resourceSlug}', 'resourceEntry')->name('v.resource'); Route::get('/{resourceSlug}/{op}', 'resourceOperation') diff --git a/backend/tests/Feature/VaultIngestOpsTest.php b/backend/tests/Feature/VaultIngestOpsTest.php index bc6b973..a5fdcd5 100644 --- a/backend/tests/Feature/VaultIngestOpsTest.php +++ b/backend/tests/Feature/VaultIngestOpsTest.php @@ -3,12 +3,16 @@ namespace Tests\Feature; use App\Enums\ResourceState; +use App\Enums\SystemFilePurpose; use App\Enums\VaultPurpose; use App\Enums\VaultState; +use App\Jobs\ExtractFileText; use App\Models\Collection; use App\Models\CollectionScheme; +use App\Models\File; use App\Models\Organization; use App\Models\Resource; +use App\Models\SystemFile; use App\Models\User; use App\Models\Vault; use App\Models\VaultKey; @@ -18,6 +22,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Queue; use Illuminate\Support\Facades\Storage; use Illuminate\Testing\TestResponse; use Tests\TestCase; @@ -45,6 +50,8 @@ protected function setUp(): void parent::setUp(); Storage::fake('public'); // the media-library disk + // Ingest starts AITY; its pipeline (Tika, vision) is not under test here. + Queue::fake([ExtractFileText::class]); $this->org = Organization::factory()->create(); $user = User::factory()->create(); @@ -85,11 +92,12 @@ private function writeKey(array $abilities = ['w:ingest', 'w:update', 'w:withdra } /** @param array|null $metadata */ - private function ingest(?string $key, ?array $metadata = null, ?UploadedFile $image = null): TestResponse + private function ingest(?string $key, ?array $metadata = null, ?UploadedFile $image = null, bool $suggest = false): TestResponse { $headers = $key !== null ? ['X-Vault-Key' => $key] : []; return $this->post("/h/{$this->vault->hash}/w/ingest", [ + ...($suggest ? ['suggest' => 'true'] : []), 'image' => $image ?? UploadedFile::fake()->image('199008_Jane_Doe_K23.jpg', 60, 40), 'metadata' => json_encode($metadata ?? [ 'name' => 'Morning at the Pier', @@ -154,14 +162,6 @@ public function test_stored_filename_comes_from_the_title_not_the_upload(): void $this->assertDatabaseMissing('files', ['filename' => '199008_Jane_Doe_K23.jpg']); } - public function test_ingest_does_not_start_ai_enrichment(): void - { - $resource = $this->resourceFor($this->ingest($this->writeKey())->json('result.hash')); - - // enrich() stamps a processing stage on the file; nothing touched it. - $this->assertNull($resource->files()->firstOrFail()->processing_status); - } - public function test_gallery_ingest_requires_a_title(): void { $this->ingest($this->writeKey(), ['description' => 'No title'])->assertStatus(400); @@ -337,4 +337,112 @@ public function test_probe_reports_the_upload_limit_to_keys_that_can_ingest(): v $this->getJson("/h/{$this->vault->hash}/w", ['X-Vault-Key' => $this->writeKey(['w:activate'])]) ->assertJsonMissingPath('max_upload_bytes'); } + + // ========================================================================= + // AITY suggestions + // ========================================================================= + + private function suggestions(string $key, string $resources): TestResponse + { + return $this->getJson( + "/h/{$this->vault->hash}/w/suggestions?resources={$resources}", + ['X-Vault-Key' => $key], + ); + } + + private function canonicalFile(string $hash): File + { + return File::where('resource_id', $this->resourceFor($hash)->id)->firstOrFail(); + } + + private function suggest(File $file, SystemFilePurpose $purpose, string $value): void + { + SystemFile::create([ + 'resource_id' => $file->resource_id, + 'source_file_id' => $file->id, + 'purpose' => $purpose->value, + 'filename' => 'suggestion.json', + 'mime_type' => 'application/json', + 'size' => 1, + 'path' => 'suggestion.json', + 'disk' => 'public', + 'metadata' => ['value' => $value], + 'is_active' => true, + ]); + } + + public function test_ingest_starts_aity_only_when_asked(): void + { + $key = $this->writeKey(); + $plain = $this->ingest($key)->json('result.hash'); + + // Without `suggest` the photograph never reaches an AI service. + Queue::assertNothingPushed(); + $this->assertNull($this->canonicalFile($plain)->processing_status); + + $asked = $this->ingest($key, null, null, true)->json('result.hash'); + + Queue::assertPushed(ExtractFileText::class, 1); + $this->assertSame('queued', $this->canonicalFile($asked)->processing_status['stage']); + // AITY only proposes: what the consumer sent stays. + $this->assertSame('Morning at the Pier', $this->resourceFor($asked)->name); + } + + public function test_suggestions_report_pending_then_the_proposals(): void + { + $key = $this->writeKey(); + $hash = $this->ingest($key, null, null, true)->json('result.hash'); + + $this->suggestions($key, $hash) + ->assertStatus(200) + ->assertJsonPath("suggestions.{$hash}", ['status' => 'pending', 'name' => null, 'description' => null]); + + $file = $this->canonicalFile($hash); + $this->suggest($file, SystemFilePurpose::AI_SUGGESTED_NAME, 'Pier at dawn'); + $this->suggest($file, SystemFilePurpose::AI_SUGGESTED_DESCRIPTION, 'A wooden pier stretches into calm water.'); + $file->updateProcessingStage('done'); + + $this->suggestions($key, $hash) + ->assertStatus(200) + ->assertJsonPath("suggestions.{$hash}", [ + 'status' => 'done', + 'name' => 'Pier at dawn', + 'description' => 'A wooden pier stretches into calm water.', + ]); + } + + public function test_reading_suggestions_never_starts_aity(): void + { + $key = $this->writeKey(); + $hash = $this->ingest($key)->json('result.hash'); + + $this->suggestions($key, $hash) + ->assertStatus(200) + ->assertJsonPath("suggestions.{$hash}", ['status' => 'off', 'name' => null, 'description' => null]); + + Queue::assertNothingPushed(); + $this->assertNull($this->canonicalFile($hash)->processing_status); + } + + public function test_suggestions_only_cover_what_this_vault_ingested_for_a_key_that_may_update(): void + { + $key = $this->writeKey(); + $hash = $this->ingest($key)->json('result.hash'); + + // Unknown hashes are left out, not refused. + $this->suggestions($key, "{$hash},nope") + ->assertStatus(200) + ->assertJsonCount(1, 'suggestions') + ->assertJsonMissingPath('suggestions.nope'); + + $this->suggestions($this->writeKey(['w:ingest']), $hash)->assertStatus(403); + $this->getJson("/h/{$this->vault->hash}/w/suggestions?resources={$hash}")->assertStatus(403); + $this->suggestions($key, '')->assertStatus(400); + + // The human form reaches the same read. + $this->getJson( + "/v/{$this->org->slug}/show/w/suggestions?resources={$hash}", + ['X-Vault-Key' => $key], + )->assertStatus(200)->assertJsonPath("suggestions.{$hash}.status", 'off'); + } } diff --git a/client/CHANGELOG.md b/client/CHANGELOG.md index d8a33cc..1ccd8a2 100644 --- a/client/CHANGELOG.md +++ b/client/CHANGELOG.md @@ -17,6 +17,13 @@ The SDK versions independently of the TYDAL product release documented in ## [Unreleased] +### Added +- `suggestions(resources)` — `GET …/w/suggestions`: AITY's proposed title and + description for resources the vault ingested (`VaultSuggestions`), for a key + that may `update` them. `off` unless the ingest sent `suggest: true`; + `pending` while the pipeline runs; nothing is applied until the consumer + sends `update`. + ## [1.6.0] — 2026-10-02 ### Added diff --git a/client/README.md b/client/README.md index a9c9b3b..d0edb73 100644 --- a/client/README.md +++ b/client/README.md @@ -122,11 +122,19 @@ const { result } = await writer.write('ingest', { image, metadata: { name: 'Morning at the Pier', author: 'Ana Ruiz', technique: 'Silver gelatin print' }, }) // ai vaults also send `descriptor` +// `suggest: true` on a gallery ingest also runs AITY on the photograph (only +// with the photographer's consent): it proposes a title and a description. await writer.write('update', { resource: hash, metadata: { dimensions: '50 × 70 cm' } }) // null removes a key await writer.write('withdraw', { resource: hash }) // to TYDAL's trash // Which ops may this key invoke, and (with w:update/w:withdraw) on what? const { methods, ingested } = await writer.writeCapabilities() + +// What AITY proposes for ingested photographs (a key that may update them). +// `off` without `suggest`; `pending` while it runs — poll; apply a proposal +// yourself with `update`. +const { suggestions } = await writer.suggestions([hash]) +// → { [hash]: { status: 'off' | 'pending' | 'done' | 'failed', name, description } } ``` > `writer.gallery.activate/open/close` still work as thin shims but are diff --git a/client/src/__tests__/vault.test.ts b/client/src/__tests__/vault.test.ts index e58b7f7..0458cc8 100644 --- a/client/src/__tests__/vault.test.ts +++ b/client/src/__tests__/vault.test.ts @@ -250,6 +250,24 @@ describe('createVaultConsumer', () => { expect(caps).toEqual({ ok: true, methods: ['activate', 'open', 'close'] }) }) + it('reads AITY suggestions for ingested resources over GET /w/suggestions', async () => { + const body = { + ok: true, + suggestions: { h1: { status: 'done', name: 'Pier at dawn', description: 'A pier.' } }, + } + const { fn, calls } = fakeFetch(() => json(body)) + const vault = createVaultConsumer({ baseUrl: root, vault: { hash: 'AbC123' }, key: 'tvk_write', fetch: fn }) + + const result = await vault.suggestions(['h1', 'h2']) + + const url = new URL(calls[0].url) + expect(url.pathname).toBe('/h/AbC123/w/suggestions') + expect(url.searchParams.get('resources')).toBe('h1,h2') + expect(calls[0].init.method ?? 'GET').toBe('GET') + expect((calls[0].init.headers as Record)['X-Vault-Key']).toBe('tvk_write') + expect(result).toEqual(body) + }) + it('throws when the probed key cannot write (403)', async () => { const { fn } = fakeFetch(() => json({ ok: false, error: 'Key not authorized to write on this vault' }, 403)) const vault = createVaultConsumer({ baseUrl: root, vault: { hash: 'AbC123' }, key: 'tvk_read', fetch: fn }) diff --git a/client/src/index.ts b/client/src/index.ts index a4b09b9..7c750e5 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -46,6 +46,8 @@ export type { VaultPagination, VaultWriteResult, VaultWriteCapabilities, + VaultSuggestion, + VaultSuggestions, } from './vault.js' export type { AuthNamespace } from './auth-endpoints.js' diff --git a/client/src/vault.ts b/client/src/vault.ts index 76420c7..2af3d6d 100644 --- a/client/src/vault.ts +++ b/client/src/vault.ts @@ -268,6 +268,25 @@ export interface VaultWriteCapabilities { organization?: { id: string; slug: string; name: string } } +/** + * What AITY proposes for one ingested resource (`GET …/w/suggestions`): + * `off` when it was ingested without `suggest: true` (AITY never ran), + * `pending` while its pipeline runs, `done` once finished (with or without a + * proposal), `failed` if it broke. A proposal is never applied by TYDAL — the + * consumer applies it, or not, with `write('update', …)`. + */ +export interface VaultSuggestion { + status: 'off' | 'pending' | 'done' | 'failed' + name: string | null + description: string | null +} + +/** The suggestions read: one entry per requested hash this vault ingested. */ +export interface VaultSuggestions { + ok: boolean + suggestions: Record +} + export interface VaultWriteResult { ok: boolean result?: unknown @@ -359,6 +378,13 @@ export interface VaultConsumer { * vault 404s — the same opacity a real write has. */ writeCapabilities(): Promise + /** + * AITY's proposed title and description for resources this vault ingested + * (`GET /w/suggestions`, at most 100 hashes). Needs a key that may `update` + * them; hashes the vault didn't ingest are left out. AITY runs only on what + * was ingested with `suggest: true`; poll a `pending` one until `done`. + */ + suggestions(resources: string[]): Promise /** * @deprecated Per-purpose sugar is retired in favor of the generic * `write(op, payload)` — `write('activate', { resources })` / `write('open')` / @@ -539,6 +565,9 @@ export function createVaultConsumer(config: VaultConsumerConfig): VaultConsumer writeCapabilities: () => get('/w'), + suggestions: (resources) => + get('/w/suggestions', { resources: resources.join(',') }), + gallery: { activate: (linkHashes) => write('activate', { resources: linkHashes }), open: () => write('open'), diff --git a/docs/architecture/VAULT_WRITE_METHODS.md b/docs/architecture/VAULT_WRITE_METHODS.md index 923b039..ea26fa7 100644 --- a/docs/architecture/VAULT_WRITE_METHODS.md +++ b/docs/architecture/VAULT_WRITE_METHODS.md @@ -117,7 +117,8 @@ writer decides only **which files an `ingest` carries and how they're stored**. resource column (`name`, `description`) are **lifted** onto the resource; every other key is stored in `resources.metadata` **as given**. Values are text, numbers or booleans (≤ 50 keys, ≤ 5000 chars; `name` ≤ 255); keys are - `lower_snake_case`. No AI and no scheme check rewrites it — the collection's + `lower_snake_case`. No AI and no scheme check rewrites it (AITY only + *proposes* values — see **Suggestions** below) — the collection's scheme only decides which keys are indexed, faceted and shown on vault cards (undeclared keys are still returned by `…/meta`). Each fact lives once: the title is the resource's `name`, never also a metadata copy. @@ -134,7 +135,13 @@ writer decides only **which files an `ingest` carries and how they're stored**. formulae, stored as the canonical `descriptor.json`). `name` is optional; provenance such as `source_hash` is just metadata. A companion `delivery` vault over the target workspace then exports the JSON to a renderer. - - No AI enrichment runs on ingested content. + - `gallery` runs AITY on the stored photograph when the ingest carries + `suggest: true` (2026-10-07) — opt-in per photograph, because the consumer + may hold the photographer's consent to AI processing for some photographs + and not others; without it the photograph never reaches an AI service. + `ai` never does — its content already comes from an external AI. AITY + never changes what the consumer sent: it only proposes, and a failure to + start it never fails the `ingest`. - **Size limit.** An `ingest` file larger than `MAX_MEDIA_FILE_SIZE` (bounded by PHP's `upload_max_filesize`/`post_max_size`) is refused with a 400 naming both sizes; the probe reports the limit as `max_upload_bytes` to keys holding @@ -153,6 +160,18 @@ writer decides only **which files an `ingest` carries and how they're stored**. `w:withdraw`, so a consumer offers those actions on the right items with no bookkeeping of its own. +- **Suggestions** (2026-10-07) — `GET …/w/suggestions?resources=h1,h2` (≤ 100 + hashes), for a key that may `update`: whoever can apply a proposal may see + it. A read beside the probe, not a write — not audited, throttled 60/min, so + a consumer polls it while AITY runs. Per ingested hash: + `{ status: off | pending | done | failed, name, description }` — the latest + AITY title/description proposals (null when none); `off` when it was + ingested without `suggest`. Reading never starts AITY. Hashes the vault + didn't ingest are left out. Proposals live where every AITY suggestion lives (`system_files`); the + consumer applies one by sending it in an `update`, and nothing on TYDAL's + side records that choice (the suggestion store stays deferred). FullFrame + offers them beside the title and description in its curator's edit form. + A new purpose that takes content only defines its file composition; the target, the metadata document, `update`, `withdraw` and provenance come with it. @@ -201,6 +220,10 @@ POST /h/{vaultHash}/w/{method} 400 { "ok": false, "error": "…" } malformed body / unknown ref 403 { "ok": false, "error": "…" } key lacks ability, or method not in purpose 404 vault not found / disabled (indistinguishable) + +GET /h/{vaultHash}/w write probe — methods, ingested, limits +GET /h/{vaultHash}/w/suggestions AITY proposals for ingested resources (§3) + (and /v/{org}/{vault}/w, /v/{org}/{vault}/w/suggestions — same gate) ``` Lives beside the existing machine surface in `VaultNamespaceController` From f78ac803c19e547e4e5fbc1a4d5d822e378d4b91 Mon Sep 17 00:00:00 2001 From: Tydalia Date: Thu, 8 Oct 2026 12:06:13 +0200 Subject: [PATCH 2/3] Release 1.5.0 --- CHANGELOG.md | 12 +++++++++-- client/CHANGELOG.md | 2 +- client/package.json | 2 +- package-lock.json | 50 +++------------------------------------------ package.json | 2 +- 5 files changed, 16 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5da8778..39a44ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to TYDAL are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/); this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [1.5.0] — 2026-10-08 ### Added @@ -19,6 +19,13 @@ All notable changes to TYDAL are documented here. The format follows `@tydal/client` gets `suggestions(resources)`. See `docs/architecture/VAULT_WRITE_METHODS.md` §3. +### Upgrading + +No migrations and no new configuration. Suggestions run on the existing AITY +pipeline, so they need what AITY already needs: a configured LLM driver and a +queue worker. `@tydal/client` goes to `1.7.0` (`suggestions`); +`@tydal/org-mcp` and `@tydal/vault-mcp` keep their versions. + ## [1.4.1] — 2026-10-06 ### Added @@ -655,7 +662,8 @@ layer); as a shipped product it is version 1.0.0. [`MIGRATION_V1_V2.md`](docs/planning/MIGRATION_V1_V2.md), CLI guide, and OpenAPI 3.0 spec. -[Unreleased]: https://github.com/eonity-org/tydal/compare/v1.4.1...HEAD +[Unreleased]: https://github.com/eonity-org/tydal/compare/v1.5.0...HEAD +[1.5.0]: https://github.com/eonity-org/tydal/compare/v1.4.1...v1.5.0 [1.4.1]: https://github.com/eonity-org/tydal/compare/v1.4.0...v1.4.1 [1.4.0]: https://github.com/eonity-org/tydal/compare/v1.3.0...v1.4.0 [1.3.0]: https://github.com/eonity-org/tydal/compare/v1.2.0...v1.3.0 diff --git a/client/CHANGELOG.md b/client/CHANGELOG.md index 1ccd8a2..ab08085 100644 --- a/client/CHANGELOG.md +++ b/client/CHANGELOG.md @@ -15,7 +15,7 @@ The SDK versions independently of the TYDAL product release documented in > `1.1.0` tarball) but never released. `1.3.0` is the first release to carry > them, so upgrading from `1.0.1` picks up the whole vault write surface. -## [Unreleased] +## [1.7.0] — 2026-10-08 ### Added - `suggestions(resources)` — `GET …/w/suggestions`: AITY's proposed title and diff --git a/client/package.json b/client/package.json index 8682fab..4f98e9d 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "@tydal/client", - "version": "1.6.0", + "version": "1.7.0", "description": "Shared TypeScript client for the TYDAL REST API — the single transport layer for every TYDAL surface (management SPA, MCP server, vault renderer apps).", "license": "Apache-2.0", "repository": { diff --git a/package-lock.json b/package-lock.json index dd5ed3b..11f3851 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tydal-monorepo", - "version": "1.1.0", + "version": "1.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tydal-monorepo", - "version": "1.4.1", + "version": "1.5.0", "workspaces": [ "client", "frontend", @@ -17,7 +17,7 @@ }, "client": { "name": "@tydal/client", - "version": "1.6.0", + "version": "1.7.0", "license": "Apache-2.0", "devDependencies": { "typescript": "^5.6.0", @@ -933,7 +933,6 @@ "os": [ "aix" ], - "peer": true, "engines": { "node": ">=18" } @@ -951,7 +950,6 @@ "os": [ "android" ], - "peer": true, "engines": { "node": ">=18" } @@ -969,7 +967,6 @@ "os": [ "android" ], - "peer": true, "engines": { "node": ">=18" } @@ -987,7 +984,6 @@ "os": [ "android" ], - "peer": true, "engines": { "node": ">=18" } @@ -1005,7 +1001,6 @@ "os": [ "darwin" ], - "peer": true, "engines": { "node": ">=18" } @@ -1023,7 +1018,6 @@ "os": [ "darwin" ], - "peer": true, "engines": { "node": ">=18" } @@ -1041,7 +1035,6 @@ "os": [ "freebsd" ], - "peer": true, "engines": { "node": ">=18" } @@ -1059,7 +1052,6 @@ "os": [ "freebsd" ], - "peer": true, "engines": { "node": ">=18" } @@ -1077,7 +1069,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -1095,7 +1086,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -1113,7 +1103,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -1131,7 +1120,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -1149,7 +1137,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -1167,7 +1154,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -1185,7 +1171,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -1203,7 +1188,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -1221,7 +1205,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -1239,7 +1222,6 @@ "os": [ "netbsd" ], - "peer": true, "engines": { "node": ">=18" } @@ -1257,7 +1239,6 @@ "os": [ "netbsd" ], - "peer": true, "engines": { "node": ">=18" } @@ -1275,7 +1256,6 @@ "os": [ "openbsd" ], - "peer": true, "engines": { "node": ">=18" } @@ -1293,7 +1273,6 @@ "os": [ "openbsd" ], - "peer": true, "engines": { "node": ">=18" } @@ -1311,7 +1290,6 @@ "os": [ "openharmony" ], - "peer": true, "engines": { "node": ">=18" } @@ -1329,7 +1307,6 @@ "os": [ "sunos" ], - "peer": true, "engines": { "node": ">=18" } @@ -1347,7 +1324,6 @@ "os": [ "win32" ], - "peer": true, "engines": { "node": ">=18" } @@ -1365,7 +1341,6 @@ "os": [ "win32" ], - "peer": true, "engines": { "node": ">=18" } @@ -1383,7 +1358,6 @@ "os": [ "win32" ], - "peer": true, "engines": { "node": ">=18" } @@ -9256,24 +9230,6 @@ "dev": true, "license": "ISC" }, - "node_modules/yaml": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz", - "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", - "dev": true, - "license": "ISC", - "optional": true, - "peer": true, - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14.6" - }, - "funding": { - "url": "https://github.com/sponsors/eemeli" - } - }, "node_modules/yargs": { "version": "17.7.3", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.3.tgz", diff --git a/package.json b/package.json index 1134b16..69e6ed1 100644 --- a/package.json +++ b/package.json @@ -9,5 +9,5 @@ "vault-mcp", "vaults/*" ], - "version": "1.4.1" + "version": "1.5.0" } From 50c349dab183e2250f579ae94696a54a1d3cc99b Mon Sep 17 00:00:00 2001 From: Tydalia Date: Thu, 8 Oct 2026 12:12:04 +0200 Subject: [PATCH 3/3] CI enabled --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39a44ce..4e5f086 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to TYDAL are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/); this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [1.5.0] — 2026-10-08 +## [1.5.0] — 2026-10-08 ### Added