feat(publish): releases in git (public tier, stage 2)

A person with an identity and a public profile publishes a studyset with
everything inside it as its next release (ADR 0005, rule 3): the server
reads their synced rows and writes them through the git command as a
commit on main and the annotated tag vN, in a bare repository of the
studyset's own, named by a random public id made at the first publish.

A release is a directory per studyset with a file per card, note, path,
step and PDF (its id, position, tag names and payload as synced, keys
sorted and indented) and the files the content names, without what is
only the author's (a card's report, a PDF's deadline). Publishing is
refused without a licence allowing passing it on in every studyset ("no
derivatives" allowed), with revisions to settle, with files not uploaded
yet, when nothing changed, or for a name that won't do; the name is
fixed from the first release, as is the person's handle.

In the app, Share in a studyset's action row opens the Publish sheet;
publishing syncs first, and settles by itself the revisions that merge
cleanly, listing only real conflicts. The server's image gets git, the
repositories a volume of their own, and the hourly backup a git bundle of
each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMm7usAo6q9ZZRoPkWjoxi
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-09 22:01:00 +02:00
commit f635b0816a
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -0,0 +1,62 @@
import 'package:halkyon_learn_flutter/src/feature/publish/data/publish_gateway.dart';
import 'package:halkyon_learn_flutter/src/feature/publish/model/publication.dart';
/// A [PublishGateway] in memory, on an instance whose account domain is
/// `halkyon.eu`, for the person `raisondetredev`: each publish a release
/// (unless [refusals] has one waiting), the name fixed from the first.
class FakePublishGateway({
/// The studysets published, by id.
final Map<String, Publication> publications = const {},
}) implements PublishGateway {
late final _publications = {...publications};
/// Refusals to answer the next publishes with, the first first.
final refusals = <PublishRefused>[];
/// What each publish was asked: the studyset, name and notes.
final published = <({String studysetId, String slug, String notes})>[];
/// When set, every request fails with it.
Exception? fail;
@override
Future<Publication?> publication(String studysetId) async {
if (fail case final error?) {
throw error;
}
return _publications[studysetId];
}
@override
Future<Publication> publish(
String studysetId, {
required String slug,
required String notes,
}) async {
if (fail case final error?) {
throw error;
}
published.add((studysetId: studysetId, slug: slug, notes: notes));
if (refusals.isNotEmpty) {
throw refusals.removeAt(0);
}
final before = _publications[studysetId];
if (before != null && before.slug != slug) {
throw PublishRefused(PublishProblem.slugFixed);
}
return _publications[studysetId] = Publication(
publicId: before?.publicId ?? 'public-$studysetId',
slug: slug,
location: 'halkyon.eu/@raisondetredev/$slug',
releases: [
Release(
version: (before?.latest?.version ?? 0) + 1,
releasedAt: DateTime.utc(2026, 10, 9),
license: 'CC-BY-SA-4.0',
notes: notes,
),
...?before?.releases,
],
);
}
}