navid/veins / 50bb6b26be9807dfca8531abacf329caea89234930485880d87ca908f0002597 / docs/SPECIFICATION_V1.html
SPECIFICATION_V1.html
← docs · 193497 bytes · raw · download
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.20">
<title>veins: Version Control System Specification</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<style>
/*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
/* Uncomment the following line when using as a custom stylesheet */
/* @import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"; */
html{font-family:sans-serif;-webkit-text-size-adjust:100%}
a{background:none}
a:focus{outline:thin dotted}
a:active,a:hover{outline:0}
h1{font-size:2em;margin:.67em 0}
b,strong{font-weight:bold}
abbr{font-size:.9em}
abbr[title]{cursor:help;border-bottom:1px dotted #dddddf;text-decoration:none}
dfn{font-style:italic}
hr{height:0}
mark{background:#ff0;color:#000}
code,kbd,pre,samp{font-family:monospace;font-size:1em}
pre{white-space:pre-wrap}
q{quotes:"\201C" "\201D" "\2018" "\2019"}
small{font-size:80%}
sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
sup{top:-.5em}
sub{bottom:-.25em}
img{border:0}
svg:not(:root){overflow:hidden}
figure{margin:0}
audio,video{display:inline-block}
audio:not([controls]){display:none;height:0}
fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
legend{border:0;padding:0}
button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
button,input{line-height:normal}
button,select{text-transform:none}
button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}
button[disabled],html input[disabled]{cursor:default}
input[type=checkbox],input[type=radio]{padding:0}
button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
textarea{overflow:auto;vertical-align:top}
table{border-collapse:collapse;border-spacing:0}
*,::before,::after{box-sizing:border-box}
html,body{font-size:100%}
body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;line-height:1;position:relative;cursor:auto;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-wrap:anywhere;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
a:hover{cursor:pointer}
img,object,embed{max-width:100%;height:auto}
object,embed{height:100%}
img{-ms-interpolation-mode:bicubic}
.left{float:left!important}
.right{float:right!important}
.text-left{text-align:left!important}
.text-right{text-align:right!important}
.text-center{text-align:center!important}
.text-justify{text-align:justify!important}
.hide{display:none}
img,object,svg{display:inline-block;vertical-align:middle}
textarea{height:auto;min-height:50px}
select{width:100%}
.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0}
a{color:#2156a5;text-decoration:underline;line-height:inherit}
a:hover,a:focus{color:#1d4b8f}
a img{border:0}
p{line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
p aside{font-size:.875em;line-height:1.35;font-style:italic}
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
h1{font-size:2.125em}
h2{font-size:1.6875em}
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
h4,h5{font-size:1.125em}
h6{font-size:1em}
hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em}
em,i{font-style:italic;line-height:inherit}
strong,b{font-weight:bold;line-height:inherit}
small{font-size:60%;line-height:inherit}
code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
ul,ol,dl{line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
ul,ol{margin-left:1.5em}
ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0}
ul.circle{list-style-type:circle}
ul.disc{list-style-type:disc}
ul.square{list-style-type:square}
ul.circle ul:not([class]),ul.disc ul:not([class]),ul.square ul:not([class]){list-style:inherit}
ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
dl dt{margin-bottom:.3125em;font-weight:bold}
dl dd{margin-bottom:1.25em}
blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
@media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
h1{font-size:2.75em}
h2{font-size:2.3125em}
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
h4{font-size:1.4375em}}
table{background:#fff;margin-bottom:1.25em;border:1px solid #dedede;word-wrap:normal}
table thead,table tfoot{background:#f7f8f7}
table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
table tr.even,table tr.alt{background:#f8f8f7}
table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{line-height:1.6}
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
.center{margin-left:auto;margin-right:auto}
.stretch{width:100%}
.clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
.clearfix::after,.float-group::after{clear:both}
:not(pre).nobreak{word-wrap:normal}
:not(pre).nowrap{white-space:nowrap}
:not(pre).pre-wrap{white-space:pre-wrap}
:not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
pre{color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;line-height:1.45;text-rendering:optimizeSpeed}
pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
pre>code{display:block}
pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
em em{font-style:normal}
strong strong{font-weight:400}
.keyseq{color:rgba(51,51,51,.8)}
kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background:#f7f7f7;border:1px solid #ccc;border-radius:3px;box-shadow:0 1px 0 rgba(0,0,0,.2),inset 0 0 0 .1em #fff;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
.keyseq kbd:first-child{margin-left:0}
.keyseq kbd:last-child{margin-right:0}
.menuseq,.menuref{color:#000}
.menuseq b:not(.caret),.menuref{font-weight:inherit}
.menuseq{word-spacing:-.02em}
.menuseq b.caret{font-size:1.25em;line-height:.8}
.menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
b.button::before{content:"[";padding:0 3px 0 2px}
b.button::after{content:"]";padding:0 2px 0 3px}
p a>code:hover{color:rgba(0,0,0,.9)}
#header,#content,#footnotes,#footer{width:100%;margin:0 auto;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
#header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
#header::after,#content::after,#footnotes::after,#footer::after{clear:both}
#content{margin-top:1.25em}
#content::before{content:none}
#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
#header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:flex;flex-flow:row wrap}
#header .details span:first-child{margin-left:-.125em}
#header .details span.email a{color:rgba(0,0,0,.85)}
#header .details br{display:none}
#header .details br+span::before{content:"\00a0\2013\00a0"}
#header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
#header .details br+span#revremark::before{content:"\00a0|\00a0"}
#header #revnumber{text-transform:capitalize}
#header #revnumber::after{content:"\00a0"}
#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
#toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
#toc>ul{margin-left:.125em}
#toc ul.sectlevel0>li>a{font-style:italic}
#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
#toc li{line-height:1.3334;margin-top:.3334em}
#toc a{text-decoration:none}
#toc a:active{text-decoration:underline}
#toctitle{color:#7a2518;font-size:1.2em}
@media screen and (min-width:768px){#toctitle{font-size:1.375em}
body.toc2{padding-left:15em;padding-right:0}
#toc.toc2{margin-top:0!important;background:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
#toc.toc2>ul{font-size:.9em;margin-bottom:0}
#toc.toc2 ul ul{margin-left:0;padding-left:1em}
#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
body.toc2.toc-right{padding-left:0;padding-right:15em}
body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
@media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
#toc.toc2{width:20em}
#toc.toc2 #toctitle{font-size:1.375em}
#toc.toc2>ul{font-size:.95em}
#toc.toc2 ul ul{padding-left:1.25em}
body.toc2.toc-right{padding-left:0;padding-right:20em}}
#content #toc{border:1px solid #e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;border-radius:4px}
#content #toc>:first-child{margin-top:0}
#content #toc>:last-child{margin-bottom:0}
#footer{max-width:none;background:rgba(0,0,0,.8);padding:1.25em}
#footer-text{color:hsla(0,0%,100%,.8);line-height:1.44}
#content{margin-bottom:.625em}
.sect1{padding-bottom:.625em}
@media screen and (min-width:768px){#content{margin-bottom:1.25em}
.sect1{padding-bottom:1.25em}}
.sect1:last-child{padding-bottom:0}
.sect1+.sect1{border-top:1px solid #e7e7e9}
#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
#content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
details{margin-left:1.25rem}
details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;outline:none;-webkit-tap-highlight-color:transparent}
details>summary::-webkit-details-marker{display:none}
details>summary::before{content:"";border:solid transparent;border-left:solid;border-width:.3em 0 .3em .5em;position:absolute;top:.5em;left:-1.25rem;transform:translateX(15%)}
details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)}
details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem}
.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
.paragraph.lead>p,#preamble>.sectionbody>[class=paragraph]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
.admonitionblock>table td.icon{text-align:center;width:80px}
.admonitionblock>table td.icon img{max-width:none}
.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6);word-wrap:anywhere}
.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
.exampleblock>.content{border:1px solid #e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;border-radius:4px}
.sidebarblock{border:1px solid #dbdbd6;margin-bottom:1.25em;padding:1.25em;background:#f3f3f2;border-radius:4px}
.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
.exampleblock>.content>:first-child,.sidebarblock>.content>:first-child{margin-top:0}
.exampleblock>.content>:last-child,.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
.literalblock pre,.listingblock>.content>pre{border-radius:4px;overflow-x:auto;padding:1em;font-size:.8125em}
@media screen and (min-width:768px){.literalblock pre,.listingblock>.content>pre{font-size:.90625em}}
@media screen and (min-width:1280px){.literalblock pre,.listingblock>.content>pre{font-size:1em}}
.literalblock pre,.listingblock>.content>pre:not(.highlight),.listingblock>.content>pre[class=highlight],.listingblock>.content>pre[class^="highlight "]{background:#f7f7f8}
.literalblock.output pre{color:#f7f7f8;background:rgba(0,0,0,.9)}
.listingblock>.content{position:relative}
.listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:inherit;opacity:.5}
.listingblock:hover code[data-lang]::before{display:block}
.listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:inherit;opacity:.5}
.listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
.listingblock pre.highlightjs{padding:0}
.listingblock pre.highlightjs>code{padding:1em;border-radius:4px}
.listingblock pre.prettyprint{border-width:0}
.prettyprint{background:#f7f7f8}
pre.prettyprint .linenums{line-height:1.45;margin-left:2em}
pre.prettyprint li{background:none;list-style-type:inherit;padding-left:0}
pre.prettyprint li code[data-lang]::before{opacity:1}
pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
table.linenotable td.code{padding-left:.75em}
table.linenotable td.linenos,pre.pygments .linenos{border-right:1px solid;opacity:.35;padding-right:.5em;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
pre.pygments span.linenos{display:inline-block;margin-right:.75em}
.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
.quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em}
.quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
.quoteblock blockquote{margin:0;padding:0;border:0}
.quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
.quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
.verseblock{margin:0 1em 1.25em}
.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans-serif;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
.verseblock pre strong{font-weight:400}
.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
.quoteblock .attribution br,.verseblock .attribution br{display:none}
.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
.quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
.quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
.quoteblock.abstract{margin:0 1em 1.25em;display:block}
.quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
.quoteblock.excerpt>blockquote,.quoteblock .quoteblock{padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
.quoteblock.excerpt,.quoteblock .quoteblock{margin-left:0}
.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
.quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;font-size:.85rem;text-align:left;margin-right:0}
p.tableblock:last-child{margin-bottom:0}
td.tableblock>.content{margin-bottom:1.25em;word-wrap:anywhere}
td.tableblock>.content>:last-child{margin-bottom:-1.25em}
table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
table.grid-all>*>tr>*{border-width:1px}
table.grid-cols>*>tr>*{border-width:0 1px}
table.grid-rows>*>tr>*{border-width:1px 0}
table.frame-all{border-width:1px}
table.frame-ends{border-width:1px 0}
table.frame-sides{border-width:0 1px}
table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-child>*{border-top-width:0}
table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
table.stripes-all>*>tr,table.stripes-odd>*>tr:nth-of-type(odd),table.stripes-even>*>tr:nth-of-type(even),table.stripes-hover>*>tr:hover{background:#f8f8f7}
th.halign-left,td.halign-left{text-align:left}
th.halign-right,td.halign-right{text-align:right}
th.halign-center,td.halign-center{text-align:center}
th.valign-top,td.valign-top{vertical-align:top}
th.valign-bottom,td.valign-bottom{vertical-align:bottom}
th.valign-middle,td.valign-middle{vertical-align:middle}
table thead th,table tfoot th{font-weight:bold}
tbody tr th{background:#f7f8f7}
tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
p.tableblock>code:only-child{background:none;padding:0}
p.tableblock{font-size:1em}
ol{margin-left:1.75em}
ul li ol{margin-left:1.5em}
dl dd{margin-left:1.125em}
dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
ul.unstyled,ol.unstyled{margin-left:0}
li>p:empty:only-child::before{content:"";display:inline-block}
ul.checklist>li>p:first-child{margin-left:-1em}
ul.checklist>li>p:first-child>.fa-square-o:first-child,ul.checklist>li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em}
ul.inline{display:flex;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
ul.inline>li{margin-left:1.25em}
.unstyled dl dt{font-weight:400;font-style:normal}
ol.arabic{list-style-type:decimal}
ol.decimal{list-style-type:decimal-leading-zero}
ol.loweralpha{list-style-type:lower-alpha}
ol.upperalpha{list-style-type:upper-alpha}
ol.lowerroman{list-style-type:lower-roman}
ol.upperroman{list-style-type:upper-roman}
ol.lowergreek{list-style-type:lower-greek}
.hdlist>table,.colist>table{border:0;background:none}
.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
td.hdlist1{font-weight:bold;padding-bottom:1.25em}
td.hdlist2{word-wrap:anywhere}
.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
.colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
.colist td:not([class]):first-child img{max-width:none}
.colist td:not([class]):last-child{padding:.25em 0}
.thumb,.th{line-height:0;display:inline-block;border:4px solid #fff;box-shadow:0 0 0 1px #ddd}
.imageblock.left{margin:.25em .625em 1.25em 0}
.imageblock.right{margin:.25em 0 1.25em .625em}
.imageblock>.title{margin-bottom:0}
.imageblock.thumb,.imageblock.th{border-width:6px}
.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
.image.left{margin-right:.625em}
.image.right{margin-left:.625em}
a.image{text-decoration:none;display:inline-block}
a.image object{pointer-events:none}
sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
sup.footnote a,sup.footnoteref a{text-decoration:none}
sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
#footnotes .footnote:last-of-type{margin-bottom:0}
#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
div.unbreakable{page-break-inside:avoid}
.big{font-size:larger}
.small{font-size:smaller}
.underline{text-decoration:underline}
.overline{text-decoration:overline}
.line-through{text-decoration:line-through}
.aqua{color:#00bfbf}
.aqua-background{background:#00fafa}
.black{color:#000}
.black-background{background:#000}
.blue{color:#0000bf}
.blue-background{background:#0000fa}
.fuchsia{color:#bf00bf}
.fuchsia-background{background:#fa00fa}
.gray{color:#606060}
.gray-background{background:#7d7d7d}
.green{color:#006000}
.green-background{background:#007d00}
.lime{color:#00bf00}
.lime-background{background:#00fa00}
.maroon{color:#600000}
.maroon-background{background:#7d0000}
.navy{color:#000060}
.navy-background{background:#00007d}
.olive{color:#606000}
.olive-background{background:#7d7d00}
.purple{color:#600060}
.purple-background{background:#7d007d}
.red{color:#bf0000}
.red-background{background:#fa0000}
.silver{color:#909090}
.silver-background{background:#bcbcbc}
.teal{color:#006060}
.teal-background{background:#007d7d}
.white{color:#bfbfbf}
.white-background{background:#fafafa}
.yellow{color:#bfbf00}
.yellow-background{background:#fafa00}
span.icon>.fa{cursor:default}
a span.icon>.fa{cursor:inherit}
.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
.admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
.admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
.admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
.admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
.admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
.conum[data-value]{display:inline-block;color:#fff!important;background:rgba(0,0,0,.8);border-radius:50%;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
.conum[data-value] *{color:#fff!important}
.conum[data-value]+b{display:none}
.conum[data-value]::after{content:attr(data-value)}
pre .conum[data-value]{position:relative;top:-.125em}
b.conum *{color:inherit!important}
.conum:not([data-value]):empty{display:none}
dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
h1,h2,p,td.content,span.alt,summary{letter-spacing:-.01em}
p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
p,blockquote,dt,td.content,td.hdlist1,span.alt,summary{font-size:1.0625rem}
p{margin-bottom:1.25rem}
.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
.exampleblock>.content{background:#fffef7;border-color:#e0e0dc;box-shadow:0 1px 4px #e0e0dc}
.print-only{display:none!important}
@page{margin:1.25cm .75cm}
@media print{*{box-shadow:none!important;text-shadow:none!important}
html{font-size:80%}
a{color:inherit!important;text-decoration:underline!important}
a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
abbr[title]{border-bottom:1px dotted}
abbr[title]::after{content:" (" attr(title) ")"}
pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
thead{display:table-header-group}
svg{max-width:100%}
p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
#header,#content,#footnotes,#footer{max-width:none}
#toc,.sidebarblock,.exampleblock>.content{background:none!important}
#toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
body.book #header{text-align:center}
body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
body.book #header .details{border:0!important;display:block;padding:0!important}
body.book #header .details span:first-child{margin-left:0!important}
body.book #header .details br{display:block}
body.book #header .details br+span::before{content:none!important}
body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
.listingblock code[data-lang]::before{display:block}
#footer{padding:0 .9375em}
.hide-on-print{display:none!important}
.print-only{display:block!important}
.hide-for-print{display:none!important}
.show-for-print{display:inherit!important}}
@media amzn-kf8,print{#header>h1:first-child{margin-top:1.25rem}
.sect1{padding:0!important}
.sect1+.sect1{border:0}
#footer{background:none}
#footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
@media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body class="book toc2 toc-left">
<div id="header">
<h1>veins: Version Control System Specification</h1>
<div class="details">
<span id="revnumber">version 0.1-draft,</span>
<span id="revdate">2026-11-24</span>
</div>
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
<ul class="sectlevel1">
<li><a href="#sec-intro">1. Introduction</a>
<ul class="sectlevel2">
<li><a href="#_purpose">1.1. Purpose</a></li>
<li><a href="#_goals">1.2. Goals</a></li>
<li><a href="#_non_goals">1.3. Non-goals</a></li>
<li><a href="#_naming">1.4. Naming</a></li>
<li><a href="#_conventions">1.5. Conventions</a></li>
<li><a href="#_terminology">1.6. Terminology</a></li>
<li><a href="#_design_decisions">1.7. Design decisions</a></li>
</ul>
</li>
<li><a href="#sec-arch">2. Architecture overview</a></li>
<li><a href="#sec-data">3. Data model</a>
<ul class="sectlevel2">
<li><a href="#sec-prims">3.1. Primitive encodings</a></li>
<li><a href="#sec-ids">3.2. Object IDs</a></li>
<li><a href="#_chunking">3.3. Chunking</a></li>
<li><a href="#sec-blobs">3.4. Blob objects and manifests</a></li>
<li><a href="#_tree_objects">3.5. Tree objects</a></li>
<li><a href="#sec-conflict-obj">3.6. Conflict objects</a></li>
<li><a href="#sec-commit-obj">3.7. Commit objects</a></li>
<li><a href="#_operation_and_view_objects">3.8. Operation and view objects</a></li>
<li><a href="#sec-canon">3.9. Canonical form and limits</a></li>
</ul>
</li>
<li><a href="#sec-storage">4. Storage</a>
<ul class="sectlevel2">
<li><a href="#_repository_layout">4.1. Repository layout</a></li>
<li><a href="#_pack_files">4.2. Pack files</a>
<ul class="sectlevel3">
<li><a href="#sec-pack-deltas">4.2.1. Delta records</a></li>
</ul>
</li>
<li><a href="#_index_files">4.3. Index files</a></li>
<li><a href="#_writing_and_durability">4.4. Writing and durability</a></li>
<li><a href="#_reading_and_verification">4.5. Reading and verification</a></li>
<li><a href="#_compaction_and_garbage_collection">4.6. Compaction and garbage collection</a></li>
<li><a href="#_promised_objects">4.7. Promised objects</a></li>
</ul>
</li>
<li><a href="#sec-oplog">5. Operation log and change IDs</a>
<ul class="sectlevel2">
<li><a href="#_operations">5.1. Operations</a></li>
<li><a href="#_concurrency">5.2. Concurrency</a></li>
<li><a href="#_undo_and_restore">5.3. Undo and restore</a></li>
<li><a href="#_change_ids">5.4. Change IDs</a></li>
<li><a href="#sec-tags">5.5. Tags</a></li>
</ul>
</li>
<li><a href="#sec-wc">6. Working copy</a>
<ul class="sectlevel2">
<li><a href="#_model_review">6.1. Model <strong>(review)</strong></a></li>
<li><a href="#_empty_changes">6.2. Empty changes</a></li>
<li><a href="#_snapshotting">6.3. Snapshotting</a></li>
<li><a href="#_untracking_paths">6.4. Untracking paths</a></li>
<li><a href="#_checkout_safety">6.5. Checkout safety</a></li>
</ul>
</li>
<li><a href="#sec-merge">7. Merging and conflicts</a>
<ul class="sectlevel2">
<li><a href="#_principles">7.1. Principles</a></li>
<li><a href="#sec-algebra">7.2. Conflict algebra</a></li>
<li><a href="#_merge_base_selection">7.3. Merge base selection</a></li>
<li><a href="#_tree_merge">7.4. Tree merge</a></li>
<li><a href="#_renames">7.5. Renames</a></li>
<li><a href="#_file_merge">7.6. File merge</a></li>
<li><a href="#_materializing_conflicts_in_the_working_copy">7.7. Materializing conflicts in the working copy</a></li>
<li><a href="#_resolving">7.8. Resolving</a></li>
<li><a href="#_rebase_and_rewrite">7.9. Rebase and rewrite</a></li>
<li><a href="#_resolution_memory">7.10. Resolution memory</a></li>
<li><a href="#_path_policies">7.11. Path policies</a></li>
</ul>
</li>
<li><a href="#sec-git">8. Git interoperability</a>
<ul class="sectlevel2">
<li><a href="#_the_mirror_repository">8.1. The mirror repository</a></li>
<li><a href="#_id_mapping">8.2. ID mapping</a></li>
<li><a href="#_import_git_to_veins">8.3. Import (git to veins)</a></li>
<li><a href="#_lazy_git_backed_import_m1">8.4. Lazy git-backed import (M1)</a></li>
<li><a href="#_export_veins_to_git">8.5. Export (veins to git)</a></li>
<li><a href="#_refs">8.6. Refs</a></li>
<li><a href="#_pull_request_workflow">8.7. Pull request workflow</a></li>
<li><a href="#_leaving_veins">8.8. Leaving veins</a></li>
<li><a href="#_invariants">8.9. Invariants</a></li>
</ul>
</li>
<li><a href="#sec-protocol">9. Native protocol</a>
<ul class="sectlevel2">
<li><a href="#_overview">9.1. Overview</a></li>
<li><a href="#_framing">9.2. Framing</a></li>
<li><a href="#_messages">9.3. Messages</a></li>
<li><a href="#_clone_and_fetch_flow">9.4. Clone and fetch flow</a></li>
<li><a href="#sec-lazy">9.5. Lazy chunk fetching</a></li>
<li><a href="#_push_flow">9.6. Push flow</a></li>
<li><a href="#_server">9.7. Server</a></li>
<li><a href="#_errors">9.8. Errors</a></li>
</ul>
</li>
<li><a href="#sec-auth">10. Authentication and authorization</a>
<ul class="sectlevel2">
<li><a href="#_model">10.1. Model</a></li>
<li><a href="#_keys">10.2. Keys</a></li>
<li><a href="#_server_access_file">10.3. Server access file</a></li>
<li><a href="#_managing_access">10.4. Managing access</a></li>
<li><a href="#_handshake">10.5. Handshake</a></li>
<li><a href="#_transport_security">10.6. Transport security</a></li>
<li><a href="#_request_authorization">10.7. Request authorization</a></li>
<li><a href="#_resource_limits_for_unauthenticated_use">10.8. Resource limits for unauthenticated use</a></li>
<li><a href="#_audit_log">10.9. Audit log</a></li>
<li><a href="#_deployment_notes_informative">10.10. Deployment notes (informative)</a></li>
</ul>
</li>
<li><a href="#_command_line_interface">11. Command-line interface</a></li>
<li><a href="#sec-perf">12. Performance requirements</a>
<ul class="sectlevel2">
<li><a href="#_reference_workloads">12.1. Reference workloads</a></li>
<li><a href="#_requirements">12.2. Requirements</a></li>
<li><a href="#_measurement_method">12.3. Measurement method</a></li>
</ul>
</li>
<li><a href="#_security_considerations">13. Security considerations</a></li>
<li><a href="#_implementation_notes_informative">14. Implementation notes (informative)</a>
<ul class="sectlevel2">
<li><a href="#_required_library_support">14.1. Required library support</a></li>
<li><a href="#_structure">14.2. Structure</a></li>
<li><a href="#_test_strategy">14.3. Test strategy</a></li>
</ul>
</li>
<li><a href="#sec-milestones">15. Milestones</a></li>
<li><a href="#sec-open-questions">16. Open questions</a></li>
</ul>
</div>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="quoteblock abstract">
<blockquote>
veins (command-line program: <code>vn</code>) is a single-user-first version control system built around a chunked, content-addressed object store, an operation log with stable change IDs, and first-class conflicts that never insert markers into files. It keeps a two-way bridge to git so history can be imported from git, mirrored to git, and abandoned back to git at any time.
</blockquote>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
This is a draft. Items marked <strong>(review)</strong> should be confirmed. <a href="#sec-open-questions">Open questions</a> lists unresolved items.
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-intro">1. Introduction</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_purpose">1.1. Purpose</h3>
<div class="paragraph">
<p>veins exists because git has three properties that are painful for the primary use case (a solo developer working on large projects, some of which commit large generated files that are regenerated many times):</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Cloning repositories with many large, similar revisions is slow because pack files do not store object IDs for deltified objects. A client must reconstruct each object by walking its delta chain and then hash it ("Resolving deltas").</p>
</li>
<li>
<p>Merges can leave the repository or working tree in a half-finished state, and conflicts are expressed by inserting <code><<<<<<<</code> markers into the files themselves.</p>
</li>
<li>
<p>Rolling back arbitrary operations (rebases, merges, resets) is unreliable and relies on the reflog.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_goals">1.2. Goals</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Fast clone and checkout</strong> for histories with many large, similar revisions. No step of clone or checkout may scale with delta-chain length.</p>
</li>
<li>
<p><strong>Seamless rollback.</strong> Every state-changing command is recorded as an operation, and any operation can be undone or restored.</p>
</li>
<li>
<p><strong>Seamless merges.</strong> A merge never fails and never blocks. Conflicts are values stored in history, not text inserted into files.</p>
</li>
<li>
<p><strong>Lossless git interoperability.</strong> History can be imported from git, exported to git, and round-tripped with identical git object IDs. A user can leave veins for git at any time without losing commit history.</p>
</li>
<li>
<p><strong>Remote sharing</strong> through a native fetch/push protocol with lazy chunk fetching.</p>
</li>
<li>
<p><strong>Controlled sharing.</strong> A server grants identified keys read-only or read-write access to a repository, and can optionally serve a repository to anonymous readers. Read-only access is a core v1 feature.</p>
</li>
<li>
<p><strong>Corruption resistance.</strong> Silent data loss is treated as a worse failure than a crash.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_non_goals">1.3. Non-goals</h3>
<div class="ulist">
<ul>
<li>
<p>Replacing git as an ecosystem. Pull requests, issues, and CI remain git-hosted, and veins interoperates with them through the bridge.</p>
</li>
<li>
<p>General delta compression across unrelated objects. veins uses only bounded-depth chunk deltas between successive versions of the same file, so random access stays predictable (see <a href="#sec-pack-deltas">Delta records</a>).</p>
</li>
<li>
<p>Semantic (AST-level) merging in v1. The merge engine is designed so a structural layer can be added later.</p>
</li>
<li>
<p>User accounts, passwords, groups, per-bookmark or per-path permissions, or other hosting features in the server. Access control in v1 is per repository and per key (see <a href="#sec-auth">Authentication and authorization</a>).</p>
</li>
<li>
<p>Multi-writer concurrency beyond what the operation log provides (see <a href="#sec-oplog">Operation log</a>).</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_naming">1.4. Naming</h3>
<div class="paragraph">
<p>The product and file format are named <strong>veins</strong>. The command-line program is named <code>vn</code> (<code>vn.exe</code> on Windows). All command examples in this document use <code>vn</code>. The name <code>veins</code> is used for the repository directory (<code>.veins/</code>), configuration and attribute files (<code>.vnexclude</code>, <code>.vnattribs</code>, <code>.vnmergedata</code>), the object-ID domain separator, and reserved header keys (<code>veins-change-id</code>, <code>veins-sig</code>). Conforming implementations of the format are not required to ship a program called <code>vn</code>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_conventions">1.5. Conventions</h3>
<div class="paragraph">
<p>The key words MUST, MUST NOT, SHOULD, SHOULD NOT, and MAY are used as described in RFC 2119. Byte order is little-endian unless stated. Sections marked <em>informative</em> do not impose requirements.</p>
</div>
<div class="paragraph">
<p>Command-line options use Plan 9 style: a long option is a single dash followed by its name (for example <code>-message</code>, <code>-rev</code>, and <code>-verbose</code>). Short aliases MAY also be accepted. An unrecognized option MUST be reported as an error and MUST NOT be treated as an operand. <code>--</code> terminates option parsing; every argument after it is an operand.</p>
</div>
<div class="paragraph">
<p>User-facing diagnostics use level prefixes: <code>error:</code> for failures, <code>warning:</code> for non-fatal problems, and <code>info:</code> for informational results. Prefixes are colored when standard output/stderr is a terminal and <code>NO_COLOR</code> is unset.</p>
</div>
</div>
<div class="sect2">
<h3 id="_terminology">1.6. Terminology</h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Term</th>
<th class="tableblock halign-left valign-top">Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">vn</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The command-line program (<code>vn.exe</code> on Windows) used to operate on veins repositories.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Object</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An immutable, content-addressed record in the store (chunk, blob, tree, commit, conflict, operation, or view).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Chunk</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A content-defined slice of file data, stored as an independent object.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Blob</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The object that represents a file’s content: either inline data or a manifest of chunks.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Manifest</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An ordered list of chunk references (possibly a tree of lists) describing a large file.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Commit</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A snapshot of a root tree, with parents and metadata.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Change ID</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A stable 16-byte identifier carried across rewrites of the same logical change.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Conflict value</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A signed sum of values stored in place of a single value, representing an unresolved merge.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Operation</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A record of a state change to the repository, forming the operation log.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">View</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The set of heads, bookmarks, tags, and working-copy commits at a point in time.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Bookmark</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A named, movable pointer to a commit. Maps to a git branch.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Working copy</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The files on disk, tracked as a commit (see <a href="#sec-wc">Working copy</a>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Mirror</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The bare git repository <code>.veins/git</code> that veins keeps in sync with its own history.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Promised object</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An object known to exist on a remote and fetched on demand.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Key</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An Ed25519 key pair. The public key is a client’s identity on a server.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Role</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The permission a key holds on a repository: <code>read</code> or <code>write</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Anonymous session</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A connection that has not authenticated. It can only read, and only if the repository allows anonymous read.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_design_decisions">1.7. Design decisions</h3>
<div class="paragraph">
<p>The following decisions were made by the project owner.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 40%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Topic</th>
<th class="tableblock halign-left valign-top">Decision</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Git relationship</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Two-way. veins can export to git and import commits back from git (for example contributor pull requests).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Remotes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Full native fetch/push protocol with lazy chunk fetching.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Object hash</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">BLAKE3 (256-bit). Git SHA-1 IDs are computed only on export, and cached.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">History identity</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Operation log plus stable change IDs.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Renames</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Recorded explicitly in veins commits. Heuristic detection is used for imported git history.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Conflict presentation</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The working-copy file is clean (no markers), accompanied by <code>.base</code>, <code>.ours</code>, and <code>.theirs</code> sidecar files.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Authentication</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Native Ed25519 keys, verified by <code>vn serve</code> itself and independent of the transport.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Authorization</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Per-repository roles only: <code>read</code> and <code>write</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Anonymous access</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Optional anonymous read-only access for repositories marked public.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The following decisions were made by the spec author and are subject to review.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 40%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Topic</th>
<th class="tableblock halign-left valign-top">Decision <strong>(review)</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Working copy model</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The working copy is automatically snapshotted as a commit before each command (jj-style). There is no staging area.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Branch terminology</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">"Bookmark" is used for named movable pointers.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Chunking parameters</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Fixed in format v1 (FastCDC, 16 KiB / 64 KiB / 256 KiB) so that chunk IDs deduplicate across repositories.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Conflict resolution</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Explicit (<code>vn resolve</code>). Editing a conflicted file does not auto-resolve it, because no markers exist to detect.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Operation-log sync</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Local only. Remotes carry refs and objects, not operations.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Platform</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Linux and macOS first. Windows is deferred.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Authentication handshake</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Challenge-response with an Ed25519 signature over both nonces, the repository name, the protocol version, and a transport channel binding (see <a href="#sec-auth">Authentication and authorization</a>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Transport security rule</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Authentication is accepted only on secure transports (SSH, TLS, local). Insecure transports may carry only anonymous reads of public repositories.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Reference transports</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">SSH (stdio), TLS 1.3 (<code>veins://</code>), and local stdio (<code>file://</code>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Access management</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A text file <code>.veins/access</code> in the served repository, edited only locally on the server with <code>vn access</code>. There is no remote administration in v1.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Revocation</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Removing a key from <code>.veins/access</code>. Takes effect on new connections, and open sessions are re-checked when the file changes.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write role scope</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>write</code> can update or delete any ref. Repo-wide protections are listed in open questions.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Client key storage</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Per-user key directory with owner-only permissions and optional passphrase protection. Import of OpenSSH Ed25519 keys is allowed.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-arch">2. Architecture overview</h2>
<div class="sectionbody">
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">+------------------------------ vn CLI ------------------------------+
| status log diff new describe merge rebase resolve undo op ... |
+-----------+------------+-------------+-------------+---------------+
| working | merge | operation | git | native |
| copy | engine + | log + views | bridge | protocol |
| | conflicts | | (import/ | (serve/fetch/ |
| | | | export) | push) |
+-----------+------------+-------------+-------------+---------------+
| object store: packs, indexes, git-map, promised set |
+--------------------------------------------------------------------+</code></pre>
</div>
</div>
<div class="paragraph">
<p>All persistent state is either an immutable object in the store or a small mutable pointer (operation heads, working-copy cache, git-map). Everything user-visible is derived from the current operation’s view.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-data">3. Data model</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="sec-prims">3.1. Primitive encodings</h3>
<div class="paragraph">
<p>All objects use a canonical binary encoding. A decoder MUST reject any encoding that is not canonical (see <a href="#sec-canon">Canonical form</a>).</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Type</th>
<th class="tableblock halign-left valign-top">Encoding</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>u8</code>, <code>u16</code>, <code>u32</code>, <code>u64</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Unsigned integers, little-endian, fixed width.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>varint</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Unsigned LEB128, at most 10 bytes. MUST be minimal (no redundant trailing zero groups).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>bytes</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>varint</code> length followed by that many raw bytes.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>id</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">32 raw bytes (a BLAKE3 digest).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>list<T></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>varint</code> count followed by that many encoded <code>T</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>opt<T></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>u8</code> 0 (absent) or 1 (present, followed by <code>T</code>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sig</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>bytes</code> name, <code>bytes</code> email, <code>i64</code> Unix seconds, <code>i16</code> timezone offset in minutes.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>time_ms</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>i64</code> milliseconds since the Unix epoch, <code>i16</code> timezone offset in minutes.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Names, paths, emails, and messages are arbitrary bytes. veins MUST NOT assume UTF-8 for stored data.</p>
</div>
</div>
<div class="sect2">
<h3 id="sec-ids">3.2. Object IDs</h3>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">object_id = BLAKE3( "veins/1" 0x00 || type_byte || body )</code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 66.6667%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Type byte</th>
<th class="tableblock halign-left valign-top">Object</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x01</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">chunk</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x02</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">blob</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x03</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">tree</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x04</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">commit</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x05</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">conflict</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x06</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">operation</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x07</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">view</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <code>chunk</code> body is the raw chunk data. The ID of two objects with the same type and body is identical, so equal content has equal IDs everywhere.</p>
</div>
</div>
<div class="sect2">
<h3 id="_chunking">3.3. Chunking</h3>
<div class="paragraph">
<p>File data larger than the inline threshold is split into chunks using FastCDC with normalized chunking. The parameters are fixed for format version 1:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Parameter</th>
<th class="tableblock halign-left valign-top">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Minimum chunk size</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">16 KiB</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Average chunk size</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">64 KiB</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Maximum chunk size</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">256 KiB</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Normalization level</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Gear table</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Specified in Appendix A of the format test vectors (to be published with this spec)</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>A conforming implementation MUST produce identical chunk boundaries for identical input. Chunk boundaries depend only on file content.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Because regenerated files tend to change locally, chunk boundaries resynchronize after an edit, and unchanged regions share chunk IDs across revisions. This is what replaces delta chains.
</td>
</tr>
</table>
</div>
</div>
<div class="sect2">
<h3 id="sec-blobs">3.4. Blob objects and manifests</h3>
<div class="paragraph">
<p>A blob body is:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">u8 form ; 0 = inline, 1 = manifest leaf, 2 = manifest interior
form 0: bytes data
form 1: list< { id chunk_id, varint length } >
form 2: list< { id child_blob_id, varint total_length } ></code></pre>
</div>
</div>
<div class="paragraph">
<p>Canonical construction rules:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>A file of length at most 16 KiB MUST be stored as an inline blob (form 0). An empty file is an inline blob with empty data.</p>
</li>
<li>
<p>A larger file MUST be split into chunks and stored as a manifest. The chunk list is grouped into leaf nodes (form 1) using the boundary rule below. If more than one node results, the nodes are grouped into interior nodes (form 2) using the same rule applied to the child IDs, repeating until a single node remains. That node’s ID is the file’s blob ID.</p>
</li>
<li>
<p><strong>Boundary rule.</strong> After entry <code>i</code> in a level, the node is cut if the low 8 bits of <code>u32le(entry_id[0..4])</code> are zero, or the node has reached 1024 entries. A node MUST NOT be cut before it has 16 entries, except at the end of the level.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Because the boundary decision depends only on entry IDs, inserting or removing a chunk disturbs only a bounded number of nodes (a prolly-tree property). The blob ID is therefore stable for equal content and local edits produce local changes.</p>
</div>
</div>
<div class="sect2">
<h3 id="_tree_objects">3.5. Tree objects</h3>
<div class="paragraph">
<p>A tree body is a <code>list</code> of entries sorted by <code>name</code> in ascending bytewise order, with unique names:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">entry = { bytes name, u8 kind, id target }</code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Kind</th>
<th class="tableblock halign-left valign-top">Meaning (<code>target</code>)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x01</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Regular file (blob ID)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x02</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Executable file (blob ID)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x03</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Symbolic link (inline blob ID containing the link target)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x04</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Subtree (tree ID)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x05</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Git submodule (opaque: the 20-byte git SHA-1 right-padded with 12 zero bytes). Preserved and exported, not otherwise interpreted in v1.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x06</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Conflict (conflict object ID)</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Entry name rules. A name MUST be non-empty, MUST NOT be <code>.</code> or <code>..</code>, MUST NOT contain <code>/</code> or NUL, and MUST NOT equal <code>.veins</code> (any case). Implementations MUST refuse to check out a tree containing a name equal, case-insensitively, to <code>.git</code> or <code>.veins</code>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
veins sorts directory entries as plain names. Git sorts directory entries as if they ended with <code>/</code>. The git exporter MUST re-sort entries using git’s rule.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Empty directories are not representable and are not tracked.</p>
</div>
</div>
<div class="sect2">
<h3 id="sec-conflict-obj">3.6. Conflict objects</h3>
<div class="paragraph">
<p>A conflict object records an unresolved value as an alternating sum (see <a href="#sec-algebra">Conflict algebra</a>):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">value = { u8 kind, [id target when kind != 0x00] } ; kind 0x00 = absent
body = { list<value> adds, list<value> removes }</code></pre>
</div>
</div>
<div class="paragraph">
<p>Constraints:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><code>adds</code> MUST contain exactly one more element than <code>removes</code>, and <code>removes</code> MUST be non-empty.</p>
</li>
<li>
<p>The stored form MUST be simplified: no add may equal any remove, and the adds MUST NOT all be identical.</p>
</li>
<li>
<p>A <code>value</code> of kind <code>0x04</code> (a tree) is permitted. This represents a file-versus-directory conflict.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>A conflict object appears as a tree entry of kind <code>0x06</code>. Conflicts are stored at the level of individual entries, not whole trees, so a commit’s root tree is always a single tree ID.</p>
</div>
</div>
<div class="sect2">
<h3 id="sec-commit-obj">3.7. Commit objects</h3>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">u8 version = 1
list<id> parents
id root_tree
bytes[16] change_id ; fixed 16 bytes, no length prefix
sig author
sig committer
bytes message
u8 renames_state ; 0 = unknown, 1 = recorded
list<rename> renames ; empty if renames_state = 0
list<{bytes key, bytes value}> extra ; ordered</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">rename = { varint parent_index, u8 kind, bytes from_path, bytes to_path }
; kind: 0 = rename, 1 = copy
; paths are '/'-separated byte strings
; sorted by (parent_index, to_path)</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p><code>renames_state = 1</code> means the renames list is authoritative: any path not listed was not renamed relative to that parent. <code>renames_state = 0</code> means rename information is unknown and the merge engine MUST fall back to heuristics. Commits created by veins use state 1. Commits imported from git use state 0.</p>
</li>
<li>
<p><code>extra</code> carries headers from imported git commits (<code>encoding</code>, <code>gpgsig</code>, <code>mergetag</code>, and others) so they can be exported verbatim. Keys beginning with <code>veins-</code> are reserved.</p>
</li>
<li>
<p>The change ID is generated randomly when a change is first created and copied unchanged when the change is rewritten (amended, rebased, squashed).</p>
</li>
<li>
<p>A commit is <strong>conflicted</strong> if its tree, recursively, contains an entry of kind <code>0x06</code>. This is derived and MUST NOT be stored in the object. Implementations MAY cache it in an index.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_operation_and_view_objects">3.8. Operation and view objects</h3>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">operation = {
list<id> parents,
id view,
time_ms start,
time_ms end,
bytes hostname,
bytes username,
bytes description, ; e.g. "rebase commit k4m2..."
list<{bytes key, bytes value}> tags ; e.g. command line, "snapshot"
}
view = {
list<id> heads, ; visible head commits, sorted
list<{bytes name, target_set}> bookmarks, ; sorted by name
list<{bytes name, id}> tags, ; sorted by name
list<{bytes remote, bytes name, id}> remote_refs, ; sorted
list<{bytes workspace, id}> working_copies ; sorted
}
target_set = { list<opt<id>> adds, list<opt<id>> removes }
; resolved form: adds = [x], removes = []</code></pre>
</div>
</div>
<div class="paragraph">
<p>A bookmark with more than one add is a <strong>conflicted bookmark</strong> (for example after concurrent updates). Resolving it is a normal operation.</p>
</div>
</div>
<div class="sect2">
<h3 id="sec-canon">3.9. Canonical form and limits</h3>
<div class="paragraph">
<p>A conforming implementation MUST reject an object that:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>is not minimally encoded or has trailing bytes;</p>
</li>
<li>
<p>has unsorted or duplicate entries where sorting is required;</p>
</li>
<li>
<p>violates any rule in <a href="#sec-blobs">Blob objects and manifests</a> or <a href="#sec-conflict-obj">Conflict objects</a>;</p>
</li>
<li>
<p>exceeds a limit.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Implementations MUST enforce at least the following limits (a stricter limit MAY be chosen):</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 66.6666%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Item</th>
<th class="tableblock halign-left valign-top">Limit</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Chunk size</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">256 KiB</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Manifest node entries</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1024</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Tree entries</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1,000,000</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Name length</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">4096 bytes</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Path length (on checkout)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">65,536 bytes</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Conflict terms</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">64</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Commit message</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">16 MiB</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Any single object body (other than chunk)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">64 MiB</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-storage">4. Storage</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_repository_layout">4.1. Repository layout</h3>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">.veins/
format "veins-store 1"
config local configuration (never tracked)
access server only: authorized keys and the anonymous-read setting
lock advisory lock for compaction and gc
store/
packs/ pack-<hex>.vpack and pack-<hex>.vidx
tmp/ in-progress writes
op_heads/ one empty file per current operation head (named by op ID)
git/ bare git repository (the mirror)
git-map/ mapping tables between veins IDs and git IDs
working_copy/ stat cache, draft-edit references, conflict bookkeeping
resolutions/ recorded conflict resolutions</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_pack_files">4.2. Pack files</h3>
<div class="paragraph">
<p>veins has no loose objects. Objects are stored in pack files that are written once and never modified.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">vpack file:
magic "VPK1"
u32 format_version = 1
u64 object_count
record* (object_count records)
trailer 32-byte BLAKE3 of all preceding bytes
record:
id object ID (32 bytes)
u8 type_byte
u8 compression (0 = none, 1 = zstd, 2 = zstd delta)
varint raw_length
varint stored_length
bytes stored data (stored_length bytes, no length prefix)</code></pre>
</div>
</div>
<div class="paragraph">
<p>Records with compression 0 or 1 are read with one seek and one decompression. Chunks SHOULD be compressed with zstd (level 3 by default). Records that do not shrink SHOULD be stored uncompressed.</p>
</div>
<div class="paragraph">
<p>Records carry their IDs, so an index can be rebuilt by scanning headers without decompressing or rehashing. Records with compression 2 add a bounded number of base lookups, not a git-style walk of an unbounded delta chain.</p>
</div>
<div class="sect3">
<h4 id="sec-pack-deltas">4.2.1. Delta records</h4>
<div class="paragraph">
<p>Compression 2 stores a zstd frame whose dictionary is another record’s raw body:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">compression 2 payload:
varint base_record_offset
bytes zstd frame, dictionary = raw body of the base record</code></pre>
</div>
</div>
<div class="paragraph">
<p><code>raw_length</code> is the length of the reconstructed object. <code>base_record_offset</code> MUST point at a record earlier in the same pack; offsets therefore decrease strictly and cycles are impossible. All object IDs and hashes are computed over the reconstructed body, so a delta record is transparent above the pack layer.</p>
</div>
<div class="paragraph">
<p>Writers SHOULD use delta records only for chunks, against the chunk at the corresponding position in a previous version of the same file. Writers MUST bound chain depth with a small constant. The reference implementation caps chains at 4 links and stores deeper objects independently, so reading a chunk costs at most five dictionary decompressions.</p>
</div>
<div class="paragraph">
<p>Readers MUST accept records compressed with 0, 1, and 2. A reader MUST also cap the number of links it follows (the reference implementation uses 32 as a safety limit). A pack written before delta records were introduced contains only 0 and 1 and MUST remain readable. Implementations that predate compression 2 MUST reject such a pack as unsupported rather than returning wrong bytes.</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_index_files">4.3. Index files</h3>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">vidx file:
magic "VIX1"
u32 format_version = 1
u32[256] fanout ; cumulative count of ids whose first byte <= i
id[N] sorted object IDs
u64[N] pack offsets of the corresponding records
trailer 32 bytes: the pack's trailer hash
trailer 32 bytes: BLAKE3 of all preceding index bytes</code></pre>
</div>
</div>
<div class="paragraph">
<p>Lookup is a fanout jump plus binary search, performed over a memory-mapped index. An implementation MUST verify that the index’s pack trailer hash matches the pack before trusting it.</p>
</div>
</div>
<div class="sect2">
<h3 id="_writing_and_durability">4.4. Writing and durability</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Each state-changing command MUST write its new objects as a single new pack. The pack MUST be written to <code>store/tmp/</code>, flushed with <code>fsync</code>, and renamed into <code>store/packs/</code>, followed by the index (same procedure). The parent directory MUST be `fsync`ed after each rename.</p>
</li>
<li>
<p>A pack without an index is ignored (and may be deleted by gc). The index is the commit point for the pack.</p>
</li>
<li>
<p>Only after the pack and index are durable MAY the operation head be advanced (see <a href="#sec-oplog">Operation log</a>).</p>
</li>
<li>
<p>A crash at any point MUST leave the repository usable. At worst, unreferenced packs remain.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_reading_and_verification">4.5. Reading and verification</h3>
<div class="ulist">
<ul>
<li>
<p>Every object read from disk MUST be verified: the BLAKE3 of the decoded data MUST equal the ID used to look it up. Verification MUST be parallelizable and SHOULD use a SIMD implementation.</p>
</li>
<li>
<p>A verification failure MUST be a hard error naming the object and pack. The implementation MUST NOT silently fall back to another copy without reporting it.</p>
</li>
<li>
<p><code>vn fsck</code> MUST verify all packs, indexes, canonical form, referential integrity (every referenced object exists or is promised), the operation log chain, and the git-map’s consistency.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_compaction_and_garbage_collection">4.6. Compaction and garbage collection</h3>
<div class="ulist">
<ul>
<li>
<p>When more than 32 packs exist, the implementation SHOULD merge small packs into a larger one. Merging writes a new pack and index before deleting the sources.</p>
</li>
<li>
<p><code>vn gc</code> computes the set of objects reachable from every operation in the operation log that has not been expired, and rewrites packs to drop everything else. The default expiry for operations is 90 days (configurable). Unreachable objects younger than 24 hours MUST NOT be deleted, to protect in-flight writes.</p>
</li>
<li>
<p><code>vn repack</code> rewrites every indexed pack into one delta-compressed pack. It preserves every object and does not expire operations. The reference implementation provides <code>vn gc</code> as an alias for this conservative repack until operation expiry is implemented.</p>
</li>
<li>
<p>Repacking MUST write the new pack and index before deleting the source packs, and MUST NOT delete promised-object records. It MUST take the repository lock.</p>
</li>
<li>
<p>gc MUST NOT delete promised-object records, and MUST take the repository lock.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_promised_objects">4.7. Promised objects</h3>
<div class="paragraph">
<p>A repository cloned lazily records the remote that is the source of any object it references but does not hold. Such objects are <strong>promised</strong>. Reading a promised object that is absent triggers a fetch (see <a href="#sec-lazy">Lazy chunk fetching</a>). If the remote is unreachable, the read fails with an error that names the missing object and the remote. Promised status applies only to chunks and blob manifest nodes. Commits, trees, and conflicts are always present locally.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-oplog">5. Operation log and change IDs</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_operations">5.1. Operations</h3>
<div class="paragraph">
<p>Every command that changes repository state MUST create exactly one operation that records the resulting view. Read-only commands MUST NOT create operations. An operation that changes only the working-copy snapshot is tagged <code>snapshot</code>, and a snapshot that produces no change MUST NOT create an operation.</p>
</div>
<div class="paragraph">
<p>The current view is the view of the current operation head. The operation log is the DAG of operations through <code>parents</code>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_concurrency">5.2. Concurrency</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>A process loads all current operation heads from <code>op_heads/</code>.</p>
</li>
<li>
<p>If there is more than one head, it first creates a merge operation: the views are combined with the same three-way rule used for conflicts (bookmarks may become conflicted), and the old heads are removed.</p>
</li>
<li>
<p>After executing, the process writes its new operation’s pack, then creates <code>op_heads/<new op id></code> and removes the file(s) of its parent(s) via atomic file operations.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Two processes that run concurrently may therefore produce two heads. The next command resolves them. No locking is required for correctness.</p>
</div>
</div>
<div class="sect2">
<h3 id="_undo_and_restore">5.3. Undo and restore</h3>
<div class="ulist">
<ul>
<li>
<p><code>vn undo</code> creates a new operation whose view equals the view of the parent of the most recent undoable operation (that is, it records a restore, rather than deleting history).</p>
</li>
<li>
<p><code>vn op restore <op></code> creates a new operation whose view equals the view of <code><op></code>.</p>
</li>
<li>
<p><code>vn op revert <op></code> creates a new operation that applies the inverse of `<op>’s effect (the three-way merge of the current view, `<op>’s view, and `<op>’s parent view).</p>
</li>
<li>
<p>An undo is itself undoable. The operation log is append-only.</p>
</li>
<li>
<p>Objects are never deleted by undo, so a restore can always find them (until gc expires the operation).</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_change_ids">5.4. Change IDs</h3>
<div class="ulist">
<ul>
<li>
<p>A change ID is created when a commit is first created by veins (random, 16 bytes), and is copied to the rewritten commit when that commit is amended, rebased, or squashed.</p>
</li>
<li>
<p>A commit imported from git receives a change ID derived deterministically from its git SHA-1 (the first 16 bytes of BLAKE3 over <code>"veins/change" || git_sha</code>), unless the git commit carries a <code>veins-change-id</code> header, in which case that value is used.</p>
</li>
<li>
<p>Change IDs are displayed in lowercase base32 (RFC 4648 alphabet), as the shortest unique prefix with a minimum of 4 characters.</p>
</li>
<li>
<p>If two or more visible commits share a change ID, the change is <strong>divergent</strong>. <code>vn log</code> MUST flag divergence, and the commits are addressed by commit ID until one is abandoned.</p>
</li>
<li>
<p>Commands accept change IDs, commit ID prefixes, bookmark names, and <code>@</code> (the working-copy commit) wherever a revision is expected. A change ID that resolves to one visible commit refers to that commit.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="sec-tags">5.5. Tags</h3>
<div class="paragraph">
<p>Tags are named, movable pointers to commits. They are stored in <code>view.tags</code> and sorted by name. Unlike bookmarks, tags are release markers: they are exported as git tags and do not carry remote tracking state.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>vn tag set <name> [-rev <rev>]</code> creates or moves a tag. The default revision is <code>@</code>. The command snapshots the working copy first, records one operation, and rejects names that are not valid git ref names.</p>
</li>
<li>
<p><code>vn tag ls [-no-col-titles]</code> lists tags with their target commit and change ID. A <code>@</code> marker identifies the tag whose target is the working-copy commit.</p>
</li>
<li>
<p><code>vn tag rm <name></code> deletes a tag and records one operation. Removing a non-existent tag is an error.</p>
</li>
<li>
<p><code>vn tag latest</code> prints only the tag name and no prefix or decoration. The latest tag is the tag whose target commit has the greatest committer timestamp; ties are broken by natural name order, where digit runs compare numerically (so <code>v0.0.10</code> follows <code>v0.0.9</code>). If no tags exist the command fails.</p>
</li>
<li>
<p>Tags are exported to <code>.veins/git</code> as <code>refs/tags/<name></code> by <code>vn git export</code> and are imported from git <code>refs/tags</code> by <code>vn git import</code>. <code>vn git push</code> pushes the requested bookmark; it does not push tags.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-wc">6. Working copy</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_model_review">6.1. Model <strong>(review)</strong></h3>
<div class="paragraph">
<p>The working copy is represented by a commit (conventionally <code>@</code>) recorded in the view per workspace. Before each command that reads or writes the working copy, veins MUST snapshot the files on disk into <code>@</code> (creating a new commit with the same change ID, and an operation if anything changed). Consequences:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>There is no staging area and no stash. Every on-disk edit is captured in history and can be restored through the operation log.</p>
</li>
<li>
<p><code>vn new</code> starts a new empty change on top of <code>@</code>. <code>vn describe -message <msg></code> sets a message. <code>vn commit -message <msg></code> is <code>describe</code> followed by <code>new</code>.</p>
</li>
<li>
<p>Checking out a revision means making a new empty child of it the working-copy commit, then updating the files. A fresh clone does the same, so <code>vn stat</code> is clean until the first edit.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_empty_changes">6.2. Empty changes</h3>
<div class="paragraph">
<p><code>@</code> has changes when its root tree differs from the root tree of its first parent. A working-copy commit with no parents has changes when its root tree is not empty; it is compared with the empty tree.</p>
</div>
<div class="paragraph">
<p><code>vn describe</code> MUST NOT create a commit or operation when <code>@</code> has no changes and the requested message is identical to the current message.</p>
</div>
<div class="paragraph">
<p><code>vn commit</code> MUST NOT create a commit or operation when <code>@</code> has no changes, regardless of the requested message. It MUST instead report that there is nothing to commit and leave the repository unchanged. In particular, veins does not create empty commits implicitly.</p>
</div>
</div>
<div class="sect2">
<h3 id="_snapshotting">6.3. Snapshotting</h3>
<div class="ulist">
<ul>
<li>
<p>Tracked state is determined by the tree of the working-copy commit, plus any new files that are not ignored.</p>
</li>
<li>
<p>veins MUST keep a stat cache (path, size, mtime in nanoseconds, inode, content ID) in <code>.veins/working_copy/</code>. A file whose stat data is unchanged MUST NOT be re-read. A file whose mtime is within a "racy" window (less than 2 seconds old relative to the cache write) MUST be re-verified by content.</p>
</li>
<li>
<p>New or changed files are chunked and hashed in parallel. Files are only read once.</p>
</li>
<li>
<p>Ignore rules come from <code>.vnexclude</code> (gitignore syntax), which <code>vn ex</code> appends to. If <code>ignore.git = true</code> (default), <code>.gitignore</code> files are also honored.</p>
</li>
<li>
<p>File modes: only the owner execute bit is tracked. Files assigned an <code>eol:*</code> attribute in <code>.vnattribs</code> are normalized to LF in the store and materialized with the requested ending on checkout.</p>
</li>
<li>
<p>Exact renames (a deleted path and an added path with the same content ID) are recorded automatically in the snapshot commit’s <code>renames</code>. With <code>rename.autodetect = similar</code> (default), added/deleted pairs with similarity of at least 60% are also recorded. <code>rename.autodetect = off</code> records only renames made with <code>vn mv</code>.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_untracking_paths">6.4. Untracking paths</h3>
<div class="paragraph">
<p><code>vn rm [-delete] <path>…​</code> removes paths from the working-copy tree. By default the files remain on disk; <code>-delete</code> also removes the matched tracked files from disk. Arguments are resolved relative to the current directory and may be literal paths or globs using <code><strong></code>, <code>?</code>, and <code></strong>*</code>. <code>*</code> and <code>?</code> do not cross directory separators. If any argument does not match a tracked path, the command MUST fail without changing the working-copy tree.</p>
</div>
<div class="paragraph">
<p>Because every command snapshots the working copy first, a path that remains on disk and is not ignored will be added back to the working-copy tree by the next snapshot. <code>vn rm</code> MUST warn about such paths. <code>vn ex <pattern>…​</code> appends gitignore-style patterns to the repository-root <code>.vnexclude</code> so that removed paths stay untracked. A successful <code>vn rm</code> records one operation.</p>
</div>
</div>
<div class="sect2">
<h3 id="_checkout_safety">6.5. Checkout safety</h3>
<div class="paragraph">
<p>A checkout or update that would overwrite or delete a file MUST do so only if the file’s current content matches the snapshot (i.e., it was snapshotted first). Because every command snapshots first, local edits are never lost.</p>
</div>
<div class="paragraph">
<p>An implementation MUST:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>create files with <code>openat</code> relative to a verified directory, refusing to follow symlinks that point outside the working copy;</p>
</li>
<li>
<p>validate every path component per <a href="#sec-data">Data model</a> before writing;</p>
</li>
<li>
<p>write files by chunk streaming, so memory use is bounded by chunk size and not file size;</p>
</li>
<li>
<p>use multiple threads to write files.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-merge">7. Merging and conflicts</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_principles">7.1. Principles</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>A merge never fails.</strong> It produces a value, which may be a conflict.</p>
</li>
<li>
<p><strong>Conflicts live in history.</strong> A conflicted commit is a normal commit. It can be described, rebased, or built upon.</p>
</li>
<li>
<p><strong>Conflicts are values, not text.</strong> The merge engine and the object store never see markers.</p>
</li>
<li>
<p><strong>Resolution propagates.</strong> Resolving a conflict in one commit removes the conflict from descendants when it cancels algebraically.</p>
</li>
<li>
<p><strong>Deterministic.</strong> The same inputs MUST produce the same merged tree and conflict objects, so the same conflict has the same ID everywhere.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="sec-algebra">7.2. Conflict algebra</h3>
<div class="paragraph">
<p>A value is a formal sum of signed terms whose signs add up to +1:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">A0 - R0 + A1 - R1 + ... + An (n >= 0 removes, n+1 adds)</code></pre>
</div>
</div>
<div class="paragraph">
<p><code>n = 0</code> is an ordinary resolved value. A three-way merge of sides <code>S1</code> and <code>S2</code> with common base <code>B</code> is <code>S1 + S2 - B</code>, which is the term list <code>adds = [S1, S2]</code>, <code>removes = [B]</code>.</p>
</div>
<div class="paragraph">
<p>Operations:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Flatten.</strong> If a term is itself a conflict value, its terms are spliced into the sum (a negated conflict has its signs flipped).</p>
</li>
<li>
<p><strong>Cancel.</strong> For each remove in order, cancel the first not-yet-cancelled add that is equal to it. Cancelled pairs are deleted.</p>
</li>
<li>
<p><strong>Resolve.</strong> If, after cancellation, only one add remains, the value is resolved to it. If all remaining adds are equal, the value resolves to that value.</p>
</li>
<li>
<p><strong>Order.</strong> Surviving terms keep their original relative order. By convention, <code>adds[0]</code> is "ours" and <code>adds[1]</code> is "theirs".</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Sum</th>
<th class="tableblock halign-left valign-top">Result</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>A + B - A</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>B</code> (ours unchanged, theirs wins)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>A + A - B</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>A</code> (both sides made the same change)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>(A + B - O) + C - B</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>A + C - O</code> (rebasing a conflicted commit)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>X + (B - B)</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>X</code></p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_merge_base_selection">7.3. Merge base selection</h3>
<div class="paragraph">
<p>For merging heads <code>S1</code> and <code>S2</code>, the common ancestors are the lowest common ancestors of the two commits in the commit DAG. If there is exactly one, <code>base = B</code>. If there are multiple (a criss-cross), the base is a <strong>virtual conflict value</strong>, produced by folding <code>R1 + R2 - LCA(R1, R2)</code> recursively over the ancestors. The virtual base is never written as a commit. The final merge is <code>S1 + S2 - base</code>, flattened and simplified. Unlike git’s recursive strategy, no virtual commit is created and no intermediate conflict markers can leak.</p>
</div>
</div>
<div class="sect2">
<h3 id="_tree_merge">7.4. Tree merge</h3>
<div class="paragraph">
<p><code>merge_trees(terms)</code> takes a signed list of tree values (some possibly absent) and produces a tree. For each name present in any term:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Collect each term’s entry (or absent), keeping signs.</p>
</li>
<li>
<p>Flatten, cancel, and resolve. If the entry resolved, use it.</p>
</li>
<li>
<p>Otherwise, if all remaining non-absent terms are subtrees, recurse with the corresponding subtrees (absent terms become empty trees).</p>
</li>
<li>
<p>Otherwise, if all remaining non-absent terms are files (kind <code>0x01</code> or <code>0x02</code>), attempt a file merge (see <a href="#sec-filemerge">File merge</a>). The executable bit is merged independently using the same algebra. If content resolves but modes do not, the result is a conflict.</p>
</li>
<li>
<p>Otherwise (mixed kinds, for example a directory on one side and a file on the other, or a deletion against a modification), store a conflict object with the simplified terms.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Rename handling is applied before the per-name merge (see below).</p>
</div>
</div>
<div class="sect2">
<h3 id="_renames">7.5. Renames</h3>
<div class="paragraph">
<p>Before merging, the engine computes for each side a rename map relative to the base:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Walk the commits from the base to the side’s head. For each commit with <code>renames_state = 1</code>, apply its recorded renames. Composing renames means that <code>a → b</code> followed by <code>b → c</code> is <code>a → c</code>. A path that is deleted and re-added within the span is not a rename. Cross-parent entries (for merge commits) use the entries for the parent that is on the path.</p>
</li>
<li>
<p>For any commit in the span with <code>renames_state = 0</code> (typically imported from git), compute renames heuristically between that commit’s tree and its first parent’s tree. Exact content matches come first. Then similarity is scored as the Jaccard similarity of chunk-ID sets for blobs with more than one chunk, and line-based similarity for small blobs. Pairs of at least 50% similarity are accepted, assigned greedily by best score, with a cap of 5,000 candidate pairs per commit (beyond which only exact matches are used).</p>
</li>
<li>
<p>When a side renamed <code>P → Q</code> and the other side changed <code>P</code>, the merge treats the other side’s change as applying to <code>Q</code>. If both sides rename <code>P</code> to different paths, the result at <code>P</code> is a conflict whose terms are the two destinations.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_file_merge">7.6. File merge</h3>
<div id="sec-filemerge" class="paragraph">
<p>A file merge takes terms that are all regular files and attempts to produce a single blob.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Classification.</strong> A file is binary if it contains a NUL byte in its first 8 KiB, or if its path matches a <code>merge=binary</code> attribute. Binary files do not merge at the content level: they resolve only through the algebra.</p>
</li>
<li>
<p><strong>Chunk fast path.</strong> Compare the terms' manifests. Chunk ranges that are identical between a side and the base are copied directly. Only the windows that differ, expanded to enclosing line boundaries, are diffed.</p>
</li>
<li>
<p><strong>Line merge.</strong> Within a differing window, use a histogram diff to compute diffs from the base to each side, then merge hunks as in diff3. Two hunks conflict if their base ranges overlap or are adjacent (touching with no unchanged line between them). <code>merge.adjacent = merge</code> may relax adjacency.</p>
</li>
<li>
<p><strong>More than three terms.</strong> Fold left to right: pair each remove with the adds around it, merge, and carry the result. If any step conflicts, the original simplified terms are kept as the conflict value.</p>
</li>
<li>
<p><strong>Result.</strong> If the whole file merges, store the merged blob. Otherwise, the entry becomes a conflict object, and the working copy materialization is as described in the next section.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_materializing_conflicts_in_the_working_copy">7.7. Materializing conflicts in the working copy</h3>
<div class="paragraph">
<p>A conflicted path is materialized as follows. For a conflict with two adds (<code>ours = adds[0]</code>, <code>theirs = adds[1]</code>) and one remove (<code>base = removes[0]</code>), the files are:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 40%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Path</th>
<th class="tableblock halign-left valign-top">Content</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code><path></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <strong>merged file with conflicting regions resolved to ours</strong>. Non-conflicting hunks from both sides are applied. No markers are inserted. If <code>ours</code> is absent (deleted), <code><path></code> is not created.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code><path>.base</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The complete content of the base term (absent if the base term is absent).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code><path>.ours</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The complete content of <code>adds[0]</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code><path>.theirs</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The complete content of <code>adds[1]</code>.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>For conflicts with more than two adds, additional terms are named <code>.theirs2</code>, <code>.theirs3</code>, …​ for further adds and <code>.base2</code>, <code>.base3</code>, …​ for further removes.</p>
</div>
<div class="paragraph">
<p>Rules:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Sidecar files are <strong>never snapshotted</strong> while their path is conflicted. Snapshotting skips any file whose name matches <code><conflicted path>.(base|ours|theirs|theirsN|baseN)</code>.</p>
</li>
<li>
<p>If materializing a sidecar would overwrite a different tracked or untracked file, the command MUST fail before modifying the working copy and report the colliding path.</p>
</li>
<li>
<p>A file-versus-directory conflict is materialized with <code><path></code> set to the <code>ours</code> side and the other side written as <code><path>.theirs</code> (a file or directory tree).</p>
</li>
<li>
<p><code>vn conflicts</code> lists each conflicted path, its kind, and for text conflicts the line ranges of the conflicting hunks within <code><path></code> and within each sidecar. The <code>-porcelain</code> format MUST be stable, tab-separated, and documented. An editor integration can use it.</p>
</li>
<li>
<p><code>vn status</code> shows conflicted paths and the number of conflicted commits in the ancestry of <code>@</code>.</p>
</li>
<li>
<p>Edits to <code><path></code> while the conflict is unresolved are <strong>drafts</strong>. The snapshot stores the draft as a blob, referenced from <code>.veins/working_copy/</code> and from the view of the working-copy operation, so that the edit is recorded and survives undo and checkout. A draft never alters the stored conflict.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_resolving">7.8. Resolving</h3>
<div class="ulist">
<ul>
<li>
<p><code>vn resolve <path></code> accepts the current content of <code><path></code> as the resolution, replacing the conflict entry with that blob.</p>
</li>
<li>
<p><code>vn resolve -take ours|theirs|base <path></code> resolves to one term.</p>
</li>
<li>
<p><code>vn resolve -tool <cmd> <path></code> runs an external merge tool with the sidecars and <code><path></code> as arguments (<code>$BASE</code>, <code>$OURS</code>, <code>$THEIRS</code>, <code>$OUTPUT</code> placeholders), then resolves from <code>$OUTPUT</code> if the tool exits successfully.</p>
</li>
<li>
<p>On resolution, the sidecars for the path are deleted, and descendants are automatically rebased. Where the conflict cancels (for instance the same conflict appears in descendants), the descendants resolve without further user action.</p>
</li>
<li>
<p><code>vn resolve -list</code> is an alias of <code>vn conflicts</code>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Resolution never requires every conflict to be handled at once. Conflicts can be partially resolved, and the working copy is always usable.</p>
</div>
</div>
<div class="sect2">
<h3 id="_rebase_and_rewrite">7.9. Rebase and rewrite</h3>
<div class="paragraph">
<p>When rewriting commit <code>C</code> with parent <code>P</code> onto new parent <code>P'</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">tree(C') = tree(C) + tree(P') - tree(P)</code></pre>
</div>
</div>
<div class="paragraph">
<p>evaluated as a tree merge (flatten, cancel, resolve, recurse). For a merge commit, <code>tree(C') = tree© + Σ(tree(P'_i) - tree(P_i))</code>. All descendants of a rewritten commit are automatically rebased, producing a single operation. Conflicts propagate through descendants in value form, and cancel when the algebra allows.</p>
</div>
</div>
<div class="sect2">
<h3 id="_resolution_memory">7.10. Resolution memory</h3>
<div class="paragraph">
<p>When <code>merge.rerere = true</code> (default), veins records resolutions: the key is the BLAKE3 of the simplified conflict object, and the value is the resolved blob ID. The recorded resolutions are stored in <code>.veins/resolutions/</code>. Whenever a merge or rebase produces a conflict object whose key has a recorded resolution, veins resolves it automatically and notes it in the operation description. Keys are exact, so only identical conflicts are reused.</p>
</div>
</div>
<div class="sect2">
<h3 id="_path_policies">7.11. Path policies</h3>
<div class="paragraph">
<p>A tracked <code>.vnmergedata</code> file assigns merge behavior to paths, with one <code>glob attr=value</code> rule per line (later rules override earlier ones). <code>.veinsattributes</code> is not read.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 40%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Attribute</th>
<th class="tableblock halign-left valign-top">Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>merge=text</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Default for non-binary files.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>merge=binary</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Never merge content. Conflicts resolve only through the algebra.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>merge=regenerate</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">On conflict, take <code>ours</code>, record no conflict, and mark the path as <strong>needing regeneration</strong>.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>A tracked <code>.vnattribs</code> file classifies paths for generation, binary detection, and line-ending normalization. Rules use <code>glob attr…​</code> syntax; later matching rules override individual attributes.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 40%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Attribute</th>
<th class="tableblock halign-left valign-top">Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>gen</code> / <code>-gen</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Mark or unmark a path as generated. Generated files are excluded from <code>vn inf</code> totals unless <code>-inc-gen</code> is passed.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>txt</code> / <code>bin</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Force text or binary classification.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>eol:lf</code>, <code>eol:crlf</code>, <code>eol:cr</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Normalize a text file to LF in the store and write the requested ending on checkout.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>-eol</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Clear an inherited EOL policy.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code>*.c txt eol:lf
*.cmd txt eol:crlf
*.ssa gen
**/generated/* gen
*.bin bin
*.exe bin</code></pre>
</div>
</div>
<div class="paragraph">
<p>For <code>merge=regenerate</code>, <code>vn status</code> lists paths that need regeneration. If the local config defines <code>regenerate.<glob> = <command></code>, <code>vn regenerate</code> runs that command and snapshots the result. A commit that contains a path still marked as needing regeneration triggers a warning. Commands are only read from local config (<code>.veins/config</code>), never from tracked files.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
This is the intended answer to the case of a 100,000-line generated C file: no human ever merges it.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-git">8. Git interoperability</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_the_mirror_repository">8.1. The mirror repository</h3>
<div class="paragraph">
<p>veins maintains a bare git repository at <code>.veins/git</code>. It serves as the staging area for all git traffic. Network operations with git hosts (such as GitHub) are performed by invoking the <code>git</code> executable against this repository, and objects are then imported to or exported from the veins store. This keeps veins independent of the git transport protocols.</p>
</div>
</div>
<div class="sect2">
<h3 id="_id_mapping">8.2. ID mapping</h3>
<div class="paragraph">
<p>The directory <code>.veins/git-map/</code> holds persistent, append-only mapping tables:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 66.6667%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Table</th>
<th class="tableblock halign-left valign-top">Contents</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">commits</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">veins commit ID <→ git commit SHA-1</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">trees</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">veins tree ID <→ git tree SHA-1</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">blobs</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">veins blob ID <→ git blob SHA-1. Lazy IDs embed the SHA-1, but the mapping is still recorded for materialization and export.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">raw</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">veins ID → original git object bytes, for commits and trees that cannot be reconstructed canonically (see below)</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Lookups MUST work in both directions in O(log n) or better. Mappings are written in the same atomic step as the objects they refer to.</p>
</div>
</div>
<div class="sect2">
<h3 id="_import_git_to_veins">8.3. Import (git to veins)</h3>
<div class="paragraph">
<p><code>vn git import</code> converts every git commit reachable from the chosen refs that is not already in the map.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Order.</strong> Parents before children. Independent subtrees and blobs are converted in parallel.</p>
</li>
<li>
<p><strong>Blobs</strong> are chunked and stored as veins blobs. The SHA-1 to blob ID mapping is recorded.</p>
</li>
<li>
<p><strong>Trees</strong> are converted entry by entry. Git modes map as follows: <code>100644</code> → file; <code>100755</code> → executable; <code>120000</code> → symlink; <code>040000</code> → subtree; <code>160000</code> → submodule. Any other mode MUST cause the tree to be stored in <code>raw</code>.</p>
</li>
<li>
<p><strong>Commits.</strong> Author, committer (name, email, seconds, timezone), message, parents, and all other headers (<code>encoding</code>, <code>gpgsig</code>, <code>mergetag</code>, and so on) are carried into the fields and <code>extra</code>. <code>renames_state = 0</code>. The change ID is derived as described in <a href="#sec-oplog">Operation log and change IDs</a>.</p>
</li>
<li>
<p><strong>Round-trip check.</strong> The importer MUST re-serialize each commit and tree using the exporter, and compare the SHA-1 with the original. If they differ (non-canonical modes, unusual header order or whitespace, trailing data, and so on), the original bytes MUST be stored in <code>raw</code> and the exporter MUST use them verbatim.</p>
</li>
<li>
<p>Importing is idempotent. A commit whose SHA-1 is in the map is not converted again.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>The initial import of a long history pays git’s delta resolution cost once, for reading the source. This cost is not paid again on any later clone.</p>
</div>
</div>
<div class="sect2">
<h3 id="_lazy_git_backed_import_m1">8.4. Lazy git-backed import (M1)</h3>
<div class="paragraph">
<p>To keep import time independent of blob count and blob size, the M1 importer uses lazy blob IDs. It converts commits, trees, refs, the view, and the operation log, but it does not read, chunk, hash, or recompress blob bodies. A blob referenced by an imported tree is represented by a 32-byte lazy ID:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>`"veins-gitoid"` (12 bytes) followed by the 20-byte git SHA-1</pre>
</div>
</div>
<div class="paragraph">
<p>The body remains in the <code>.veins/git</code> mirror. Tree entries keep their normal file, executable, or symlink kind, but the target is a lazy blob ID instead of a canonical veins blob ID.</p>
</div>
<div class="paragraph">
<p>Reading a lazy blob reads the corresponding git object from the mirror. <code>vn checkout</code> uses this path, so an imported repository checks out to the same bytes as git. <code>vn fsck</code> treats lazy blob references as promised objects; they are not errors merely because they are absent from <code>.veins/store</code>.</p>
</div>
<div class="paragraph">
<p>Lazy IDs are deterministic for a given git blob. The <code>blobs</code> mapping table records them so that a later materialization pass can replace lazy references with canonical chunked veins blobs. Materialization is a separate operation and will rewrite the affected tree, commit, and view IDs. Deleting <code>.veins/git</code> while lazy references remain makes those blobs unavailable.</p>
</div>
<div class="paragraph">
<p><code>vn git materialize [path]</code> performs this pass. It reads every lazy blob reachable from the current view, chunks and stores it canonically, rewrites affected trees and conflict values, rewrites commits parents-first while preserving change IDs and metadata, updates view refs, and records one operation. Objects with no lazy descendants keep their existing IDs. The <code>commits</code>, <code>trees</code>, and <code>blobs</code> mapping tables are updated to the new veins IDs. If no lazy references remain, the command reports <code>already materialized</code> and creates no operation.</p>
</div>
<div class="paragraph">
<p>Lazy import is an importer fast path. Repositories created by a native veins clone use canonical chunked blobs and do not depend on a git mirror.</p>
</div>
</div>
<div class="sect2">
<h3 id="_export_veins_to_git">8.5. Export (veins to git)</h3>
<div class="paragraph">
<p><code>vn git export</code> writes the commits reachable from bookmarks and tags into the mirror.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Commits are exported parents first. For a commit with a <code>raw</code> entry, those bytes are emitted unchanged (when its tree and parents map to the same git SHAs). Otherwise, the commit is serialized in git’s canonical form from its fields, with <code>extra</code> headers in order.</p>
</li>
<li>
<p>Native commits (created by veins) include an extra header <code>veins-change-id <hex></code> <strong>(review)</strong>, so that a later import of the same git commit recovers the change ID. This header is never added to imported commits.</p>
</li>
<li>
<p>Blobs are SHA-1-hashed once per distinct blob ID. The result is cached in the <code>blobs</code> table. SHA-1 MUST be computed with collision detection (sha1dc, as git does).</p>
</li>
<li>
<p>Trees are serialized with git’s sort order (see <a href="#sec-data">Data model</a>).</p>
</li>
<li>
<p>Timestamps are exported at one-second precision.</p>
</li>
<li>
<p>Renames and change IDs (except as in the header above) are not representable in git and are dropped.</p>
</li>
<li>
<p>The exporter MAY write objects directly (as packs) or by driving <code>git fast-import</code>. Both MUST produce identical object IDs.</p>
</li>
<li>
<p><strong>Conflicted commits are not exported.</strong> If a bookmark points to a commit with a conflicted ancestor, the git branch is advanced to the nearest exportable ancestor on that bookmark’s first-parent chain, or is left unchanged if none exists. <code>vn git export</code> MUST report such bookmarks.</p>
</li>
<li>
<p>The working-copy commit is exported only if a bookmark points to it.</p>
</li>
<li>
<p>Export is incremental, driven by the commits map. Exporting one new commit MUST NOT require work proportional to repository size.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_refs">8.6. Refs</h3>
<div class="paragraph">
<p>Bookmarks map to git branches (<code>refs/heads/<name></code>), and tags to git tags (<code>refs/tags/<name></code>). Tags are created natively with <code>vn tag set</code> or imported from git. A bookmark’s remote tracking state is stored in <code>remote_refs</code> of the view and mirrored under <code>refs/remotes/<remote>/</code> in the mirror. Fetching moves remote refs, not local bookmarks. Local bookmarks move on explicit command or merge.</p>
</div>
</div>
<div class="sect2">
<h3 id="_pull_request_workflow">8.7. Pull request workflow</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><code>vn git push <remote> <bookmark></code> exports and runs <code>git push</code> from the mirror. Branch protection on the host prevents contributors pushing to your main branch.</p>
</li>
<li>
<p>A contributor opens a pull request against the host in the normal way.</p>
</li>
<li>
<p><code>vn git fetch <remote></code> runs <code>git fetch</code> into the mirror, then imports the new commits. Their git SHA-1s are preserved in the map.</p>
</li>
<li>
<p><code>vn</code> creates a bookmark for the imported branch. Review, test, and merge happen natively.</p>
</li>
<li>
<p>After the merge, <code>vn git push</code> exports the merge commit. Because the contributor’s commits are exported under their <strong>original</strong> SHA-1s (they are in the map, with <code>raw</code> where needed) and the merge commit lists them as parents, the host recognizes the pull request as merged. If the owner squashes or rebases instead, the pull request simply shows as closed.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_leaving_veins">8.8. Leaving veins</h3>
<div class="paragraph">
<p><code>vn git export -all</code> followed by copying <code>.veins/git</code> to a normal <code>.git</code> directory MUST yield a git repository whose working tree is identical to the veins working copy, and whose history contains all exported commits, plus any conflict-free state. No other conversion is required. Users MAY keep using veins afterwards.</p>
</div>
</div>
<div class="sect2">
<h3 id="_invariants">8.9. Invariants</h3>
<div class="paragraph">
<p>Conforming implementations MUST satisfy:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Import then export</strong> of any git repository reproduces every commit, tree, and blob SHA-1 exactly.</p>
</li>
<li>
<p><strong>Export then import</strong> of any exportable veins history in a fresh repository yields commits whose root trees and ancestry are isomorphic to the original (IDs may differ because change IDs and rename records are not carried unless the header is present).</p>
</li>
<li>
<p><strong>Idempotence.</strong> Repeating import or export with no changes performs no writes to the store other than its logs.</p>
</li>
</ol>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-protocol">9. Native protocol</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_overview">9.1. Overview</h3>
<div class="paragraph">
<p>The protocol is a request/response protocol over any reliable, ordered, bidirectional byte stream. Clients authenticate to the server with Ed25519 keys inside the protocol (see <a href="#sec-auth">Authentication and authorization</a>), whatever the transport. The protocol itself provides no confidentiality: that is the transport’s job. Object integrity is guaranteed by the object IDs themselves.</p>
</div>
<div class="paragraph">
<p>The reference transports are:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 28.5714%;">
<col style="width: 28.5714%;">
<col style="width: 42.8572%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">URL form</th>
<th class="tableblock halign-left valign-top">Transport</th>
<th class="tableblock halign-left valign-top">Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ssh://[user@]host[:port]/path</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">SSH. The client runs <code>ssh host vn serve -stdio <path></code>.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Secure. No channel binding is available.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>veins://host[:port]/repo</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">TCP with TLS 1.3 (<code>vn serve -listen</code>).</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Secure. Channel binding is the TLS exporter value. The client validates the server certificate against the system trust store, or against a pinned fingerprint set in <code>remote.<name>.tls-pin</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code><a href="file:///path" class="bare">file:///path</a></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Local. The client spawns <code>vn serve -stdio <path></code>.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Secure (local process).</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Other transports (for example HTTP/2) MAY be added. A transport is <strong>secure</strong> if it provides confidentiality and integrity and authenticates the server to the client. Plain, unencrypted transports MAY be provided, but are <strong>insecure</strong> and subject to the restrictions in <a href="#sec-auth">Authentication and authorization</a>.</p>
</div>
<div class="paragraph">
<p>Design requirements:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>A fresh clone MUST need no work proportional to delta-chain length, and no per-object reconstruction. The receiver writes received records straight into a pack.</p>
</li>
<li>
<p>The client MUST be able to fetch history (commits and trees) without file data, and fetch chunks on demand.</p>
</li>
<li>
<p>Chunks the client already holds MUST NOT be re-sent during incremental fetch.</p>
</li>
<li>
<p>A session without the <code>write</code> role MUST NOT be able to change anything in the repository, by any request.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_framing">9.2. Framing</h3>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">frame:
u32 length ; of the rest of the frame, max 16 MiB
u8 kind
u32 request_id ; chosen by the client; echoed in responses
bytes payload (length - 5 bytes)</code></pre>
</div>
</div>
<div class="paragraph">
<p>Multiple requests MAY be outstanding. Responses for different <code>request_id`s MAY be interleaved. Frames of one request arrive in order. Unknown `kind</code> values MUST be rejected with an <code>ERROR</code> frame.</p>
</div>
</div>
<div class="sect2">
<h3 id="_messages">9.3. Messages</h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Message</th>
<th class="tableblock halign-left valign-top">Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HELLO</code> / <code>HELLO_OK</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Version and capability negotiation, repository selection, and exchange of nonces. Capabilities include <code>zstd-records</code>, <code>lazy-chunks</code>, <code>push</code>, <code>auth-ed25519</code>. The highest common version is used. See <a href="#sec-auth">Authentication and authorization</a> for the fields.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>AUTH</code> / <code>AUTH_OK</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Proves possession of an Ed25519 key. Sent at most once per connection, directly after <code>HELLO_OK</code>. <code>AUTH_OK</code> reports the role granted.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>WHOAMI</code> / <code>WHOAMI_OK</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the session’s role (<code>anonymous</code>, <code>read</code>, or <code>write</code>) and key fingerprint.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>LIST_REFS</code> / <code>REFS</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns bookmarks and tags with their target commit IDs and change IDs.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>NEGOTIATE</code> / <code>NEGOTIATE_OK</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The client sends <code>wants</code> (commit IDs) and <code>haves</code> (commit IDs it owns, in batches of ancestors with exponentially increasing spacing). The server replies with which haves are known and whether it has enough common history.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>FETCH_SKELETON</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Requests all commits, trees, conflict objects, and blob manifest nodes reachable from <code>wants</code> and not reachable from the acknowledged <code>haves</code>. Response is a <code>RECORDS</code> stream.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>GET_CHUNKS</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Requests a list of chunk IDs. Response is a <code>RECORDS</code> stream in request order. Missing chunks produce <code>NOT_FOUND</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HAVE_QUERY</code> / <code>HAVE_BITMAP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The client sends a sorted list of IDs. The server returns a bitmap of which it holds. Used by push.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>PUT_RECORDS</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The client sends a <code>RECORDS</code> stream of objects to store. Ends with a trailer hash.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>UPDATE_REFS</code> / <code>UPDATE_REFS_OK</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Atomic compare-and-swap of refs: list of (name, expected old target, new target). All-or-nothing.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ERROR</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Error code and message. Terminates the request.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><code>RECORDS</code> streams contain a sequence of records in the same layout as pack records, terminated by an <code>END</code> frame containing the 32-byte BLAKE3 hash of the concatenated record bytes. Records on the wire MAY be zstd-compressed exactly as stored, so a server can send stored bytes without decompressing or recompressing. Each record carries its ID, so the receiver needs no per-object reconstruction to build the index.</p>
</div>
</div>
<div class="sect2">
<h3 id="_clone_and_fetch_flow">9.4. Clone and fetch flow</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><code>HELLO</code>, then <code>AUTH</code> (omitted for an anonymous read of a repository that allows it), then <code>LIST_REFS</code>.</p>
</li>
<li>
<p><code>NEGOTIATE</code> (for a clone, <code>haves</code> is empty and the server can skip to step 3).</p>
</li>
<li>
<p><code>FETCH_SKELETON</code>. The client writes the records into a pack as they arrive, builds the index in one pass, and verifies each record’s hash in parallel with receipt. Hashing uses multiple threads.</p>
</li>
<li>
<p>The client chooses a chunk policy (<code>vn clone -blobs <policy></code>):</p>
<div class="ulist">
<ul>
<li>
<p><code>head</code> (default): fetch all chunks needed to check out the target commit.</p>
</li>
<li>
<p><code>none</code>: fetch no chunks. Everything is promised.</p>
</li>
<li>
<p><code>all</code>: fetch every chunk in history.</p>
</li>
</ul>
</div>
</li>
<li>
<p>For <code>head</code> or <code>all</code>, the client computes the set of chunk IDs it lacks from the received manifests and issues <code>GET_CHUNKS</code>. On an initial clone with <code>all</code>, the server MAY satisfy this directly by streaming its packs, because it knows the client has nothing.</p>
</li>
<li>
<p>In incremental fetches, the client sends <code>GET_CHUNKS</code> only for chunk IDs it does not already hold (found by index lookup). Revisions of a regenerated file share most chunks, so only the changed chunks cross the wire.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>The client MAY verify hashes lazily in the background (<code>-verify=lazy</code>) but the default is eager. Failed verification MUST abort the operation and discard the received data.</p>
</div>
</div>
<div class="sect2">
<h3 id="sec-lazy">9.5. Lazy chunk fetching</h3>
<div class="ulist">
<ul>
<li>
<p>A repository with promised objects stores the <code>promisor</code> remote name in <code>config</code>.</p>
</li>
<li>
<p>Reading an absent promised chunk MUST trigger a <code>GET_CHUNKS</code> to the promisor. The client SHOULD prefetch following chunks of the same blob when the first chunk of the blob is requested (read-ahead), and SHOULD batch concurrent misses.</p>
</li>
<li>
<p>Fetched chunks are written to a new pack and are no longer promised.</p>
</li>
<li>
<p>Lazy fetches authenticate exactly like any other request. If the client’s access has been revoked, the fetch fails with <code>FORBIDDEN</code> or <code>AUTH_FAILED</code>, and local data is unaffected.</p>
</li>
<li>
<p>Commands that need file content (checkout, diff, merge) work in a lazy repository when the promisor is reachable. Commands that need only history (log, bookmark, rebase of non-conflicting changes by tree) do not touch the network.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_push_flow">9.6. Push flow</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><code>HELLO</code>, then <code>AUTH</code>, then <code>LIST_REFS</code>. The session MUST hold the <code>write</code> role; the server rejects the push otherwise (see <a href="#sec-auth">Authentication and authorization</a>).</p>
</li>
<li>
<p>The client determines the new commits and queries <code>HAVE_QUERY</code> for the chunk and manifest IDs that those commits reference but are not known to be on the server.</p>
</li>
<li>
<p>The client sends <code>PUT_RECORDS</code> containing the missing objects. The server verifies the hash of every record, enforces <a href="#sec-canon">canonical form and limits</a>, and checks <strong>closure</strong>: every object referenced by an accepted object MUST either exist on the server or be in the same push.</p>
</li>
<li>
<p>The client sends <code>UPDATE_REFS</code> with the expected old values. If any ref does not match, the update fails entirely, and the client MUST fetch and merge.</p>
</li>
<li>
<p>Pushing a conflicted commit is refused by default (<code>push.allow-conflicts = false</code>). A server MAY accept it.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>The operation log is <strong>not</strong> pushed or fetched. Operation history is a local concern.</p>
</div>
</div>
<div class="sect2">
<h3 id="_server">9.7. Server</h3>
<div class="paragraph">
<p><code>vn serve</code> operates on a normal veins store plus a ref table (<code>refs/</code> with one file per bookmark and tag, updated by atomic rename under a lock). A server repository has no working copy. It MUST compact and gc like any other store, and MUST NOT delete objects reachable from any ref.</p>
</div>
<div class="paragraph">
<p>Two modes exist:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><code>vn serve -stdio <repo></code> serves one repository over standard input and output. It is used by the SSH and local transports.</p>
</li>
<li>
<p><code>vn serve -listen <addr:port> -root <dir> -tls-cert <file> -tls-key <file></code> serves every repository under <code><dir></code> over TLS. The repository named in <code>HELLO</code> MUST be resolved relative to <code><dir></code>. Names containing <code>..</code>, absolute paths, or NUL MUST be rejected.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Each repository’s access policy is read from its own <code>.veins/access</code> file.</p>
</div>
</div>
<div class="sect2">
<h3 id="_errors">9.8. Errors</h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 66.6667%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Code</th>
<th class="tableblock halign-left valign-top">Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1 <code>UNSUPPORTED_VERSION</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No common protocol version.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2 <code>BAD_FRAME</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Malformed or oversized frame.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">3 <code>NOT_FOUND</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Requested object or ref does not exist.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">4 <code>HASH_MISMATCH</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A record’s ID does not match its content.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">5 <code>NON_CANONICAL</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An object violates canonical form or limits.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">6 <code>MISSING_CLOSURE</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Pushed object references an object the server lacks.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">7 <code>REF_CONFLICT</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>UPDATE_REFS</code> compare failed.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">8 <code>REJECTED</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Policy rejection (for example conflicted commit).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">9 <code>INTERNAL</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Server error.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">10 <code>UNAUTHENTICATED</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The request needs an authenticated identity (or the repository does not allow anonymous access) and the session has none.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">11 <code>FORBIDDEN</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The session is authenticated, but its role does not permit the request.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">12 <code>AUTH_FAILED</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Authentication failed. The same code is returned for an unknown key, a bad signature, a malformed key, and a nonexistent repository.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-auth">10. Authentication and authorization</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_model">10.1. Model</h3>
<div class="paragraph">
<p>A veins server authenticates clients itself, using <strong>Ed25519 keys</strong>. This is independent of the transport: the same keys work over SSH, TLS, and local connections, and the server never uses SSH user names, operating-system accounts, or TLS client certificates to decide what a client may do.</p>
</div>
<div class="paragraph">
<p>Authorization is <strong>per repository</strong>. A key has exactly one of two roles on a repository, and a repository MAY additionally allow anonymous reads.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Role</th>
<th class="tableblock halign-left valign-top">Permitted</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">anonymous</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read operations, only if the repository’s access file has an <code>anonymous read</code> directive.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>read</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read operations: everything a clone, fetch, or lazy chunk request needs.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>write</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Everything <code>read</code> can do, plus push.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>There are no accounts, passwords, groups, or per-bookmark and per-path rules in v1. A <code>read</code> key can read the complete repository: all history, all refs, all chunks. Anything committed to a repository is visible to every reader of that repository. Per-path secrecy is not provided and MUST NOT be implied by tooling.</p>
</div>
</div>
<div class="sect2">
<h3 id="_keys">10.2. Keys</h3>
<div class="ulist">
<ul>
<li>
<p>A key’s public half is 32 bytes. Its <strong>fingerprint</strong> is the lowercase base32 (RFC 4648 alphabet, no padding) encoding of the first 16 bytes of <code>BLAKE3("veins/key/1" || public_key)</code>, which is 26 characters.</p>
</li>
<li>
<p>Public keys are written as <code>ed25519:</code> followed by unpadded base64url of the 32 bytes.</p>
</li>
<li>
<p>Private keys are stored on the client in the user key directory: <code>$XDG_CONFIG_HOME/veins/keys/</code> (default <code>~/.config/veins/keys/</code>) on Linux and macOS, and <code>%APPDATA%\veins\keys\</code> on Windows. One file per key, named <code><key name>.key</code>. Each file holds a format version byte and the 32-byte seed. It SHOULD be encrypted with a passphrase (Argon2id key derivation and an authenticated cipher, with parameters recorded in the file).</p>
</li>
<li>
<p>On POSIX systems <code>vn</code> MUST refuse to use a private key file that is readable or writable by group or others.</p>
</li>
<li>
<p>Private keys MUST NOT be written to repositories, configuration files, logs, or error messages.</p>
</li>
<li>
<p>A remote selects its key with <code>remote.<name>.key = <key name></code>. The default key name is <code>default</code>.</p>
</li>
<li>
<p><code>vn key import -openssh <file></code> MAY be offered to import an OpenSSH Ed25519 private key.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_server_access_file">10.3. Server access file</h3>
<div class="paragraph">
<p>The file <code>.veins/access</code> in a served repository defines who may do what. It is UTF-8 text, one directive per line. Blank lines and lines beginning with <code>#</code> are ignored.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text"># allow <role> <public key> [<name>]
allow write ed25519:q3x8...43 characters of base64url... laptop
allow read ed25519:Zk2m...43 characters of base64url... ci-runner
# serve this repository to unauthenticated readers
anonymous read</code></pre>
</div>
</div>
<div class="paragraph">
<p>Rules:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><code>role</code> is <code>read</code> or <code>write</code>. <code>name</code> is optional, contains no whitespace, and is used only in logs and listings.</p>
</li>
<li>
<p>A key MUST appear at most once. A duplicate is an error.</p>
</li>
<li>
<p>An unknown directive, unknown role, or malformed key is an error. If the file has any error, the server MUST refuse to serve that repository (fail closed) and report the line number locally. It MUST NOT serve it with a partial policy.</p>
</li>
<li>
<p>If the file does not exist, nobody has access: no keys are authorized and anonymous reads are off.</p>
</li>
<li>
<p>On POSIX systems the server MUST refuse to use a file that is writable by group or others.</p>
</li>
<li>
<p>The server MUST read the file when a connection is opened. It SHOULD re-validate open sessions when the file’s modification time changes and terminate sessions whose key was removed or whose role was lowered (the session’s next request fails with <code>FORBIDDEN</code>).</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_managing_access">10.4. Managing access</h3>
<div class="paragraph">
<p>Access is managed only on the server machine, by someone with filesystem access to the repository. No protocol message changes the access file, so a <code>write</code> key cannot grant itself or anyone else access.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 40%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Command</th>
<th class="tableblock halign-left valign-top">Effect</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn access add -role read|write -key <public key or file> [-name <name>]</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Add a key.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn access list</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">List keys with role, name, and fingerprint, and whether anonymous read is on.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn access remove <fingerprint or name></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Remove a key (revocation).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn access anonymous on|off</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Add or remove the <code>anonymous read</code> directive.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Client-side key commands:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 40%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Command</th>
<th class="tableblock halign-left valign-top">Effect</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn key generate <name></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Create a key pair and print the public key and fingerprint.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn key list</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">List local keys with fingerprints.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn key show <name></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Print the public key.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn key import -openssh <file></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Import an OpenSSH Ed25519 key (optional feature).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn whoami [<remote>]</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Connect and report the role and key fingerprint the server grants.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_handshake">10.5. Handshake</h3>
<div class="paragraph">
<p>After the transport is established, the exchange is:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">HELLO (client -> server):
u16 min_version
u16 max_version
list<bytes> capabilities
bytes repo ; repository name; may be empty for stdio servers
bytes client_nonce ; 32 random bytes
HELLO_OK (server -> client):
u16 version ; highest version both support
list<bytes> capabilities
bytes server_nonce ; 32 random bytes, fresh for every connection
u8 auth_required ; 1 if anonymous reads are not allowed for this repository
AUTH (client -> server), optional, at most once:
bytes public_key ; 32 bytes
bytes signature ; 64 bytes
AUTH_OK (server -> client):
u8 role ; 1 = read, 2 = write
bytes fingerprint ; 16 bytes</code></pre>
</div>
</div>
<div class="paragraph">
<p>The signature is a pure Ed25519 signature (RFC 8032) over the message:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="text">"veins-auth/1" 0x00
|| u16 version ; the version from HELLO_OK
|| bytes repo ; exactly as sent in HELLO
|| server_nonce
|| client_nonce
|| bytes channel_binding ; empty if the transport provides none</code></pre>
</div>
</div>
<div class="paragraph">
<p>Rules:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The server MUST generate <code>server_nonce</code> from a cryptographically secure random source and MUST NOT reuse it. It MUST verify the signature over the message using the nonces of the current connection. A signature is never valid on any other connection.</p>
</li>
<li>
<p><strong>Channel binding.</strong> On TLS, <code>channel_binding</code> is the 32-byte TLS 1.3 exporter value for the label <code>EXPORTER-veins-auth/1</code> with an empty context. This ties the signature to the TLS session, so a malicious intermediary that accepts the client’s connection cannot forward the signature to the real server. Other transports MUST define their binding. On transports without a binding (SSH stdio, local), it is empty and protection against relay depends on the transport authenticating the server (the SSH host key).</p>
</li>
<li>
<p>The server finds the public key in <code>.veins/access</code>. If the key is unknown, or its signature is invalid, or the repository does not exist, the server MUST send <code>AUTH_FAILED</code> with identical content and timing characteristics for all three cases, so that probing cannot discover which keys or repositories exist.</p>
</li>
<li>
<p>After a failed attempt the server SHOULD delay its reply by a fixed amount and MUST close the connection after three failed attempts. A server SHOULD rate-limit failed attempts per source address where the transport exposes one.</p>
</li>
<li>
<p>A second <code>AUTH</code> on the same connection is a protocol error (<code>BAD_FRAME</code>). The session’s role is fixed once set and cannot be raised by a later message.</p>
</li>
<li>
<p>A client SHOULD authenticate whenever <code>auth_required</code> is 1 or it intends to push. A client that holds no key and sees <code>auth_required = 0</code> MAY proceed anonymously.</p>
</li>
<li>
<p>If the repository does not exist, <code>HELLO_OK</code> still returns <code>auth_required = 1</code>, and every later request except <code>WHOAMI</code> fails with <code>UNAUTHENTICATED</code>, so a nonexistent repository looks like a private one.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_transport_security">10.6. Transport security</h3>
<div class="ulist">
<ul>
<li>
<p>A server MUST NOT accept <code>AUTH</code> on an insecure transport. It MUST reply <code>AUTH_FAILED</code> and SHOULD close the connection.</p>
</li>
<li>
<p>On an insecure transport, only anonymous reads of repositories that allow them are possible. A server MUST reject every other request with <code>UNAUTHENTICATED</code>, including all write requests.</p>
</li>
<li>
<p>An implementation that offers an insecure transport MUST keep it disabled unless explicitly enabled by the operator, and it MUST be restricted to anonymous read-only use.</p>
</li>
<li>
<p>On an insecure transport the <strong>contents</strong> of fetched objects are protected by their hashes, but <strong>ref values</strong> are not authenticated and a network attacker can serve stale or withheld refs. Clients SHOULD warn when fetching refs over an insecure transport. Signed refs are a possible future extension.</p>
</li>
<li>
<p>The <code>file://</code> transport and <code>ssh://</code> transport are secure in the sense above. TLS clients MUST validate the server certificate, or match a pinned fingerprint, and MUST refuse TLS versions below 1.3.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_request_authorization">10.7. Request authorization</h3>
<div class="paragraph">
<p>The server MUST check authorization on <strong>every request</strong>, using the session’s role, and not only at connection time.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 16.6666%;">
<col style="width: 16.6666%;">
<col style="width: 16.6668%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Request</th>
<th class="tableblock halign-left valign-top">anonymous</th>
<th class="tableblock halign-left valign-top">read</th>
<th class="tableblock halign-left valign-top">write</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HELLO</code>, <code>AUTH</code>, <code>WHOAMI</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">yes</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>LIST_REFS</code>, <code>NEGOTIATE</code>, <code>FETCH_SKELETON</code>, <code>GET_CHUNKS</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">yes*</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">yes</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HAVE_QUERY</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">no</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">no</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">yes</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>PUT_RECORDS</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">no</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">no</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">yes</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>UPDATE_REFS</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">no</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">no</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">yes</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>(*) Only if the repository has an <code>anonymous read</code> directive. Otherwise the request fails with <code>UNAUTHENTICATED</code>.</p>
</div>
<div class="paragraph">
<p>When a request is refused, the server MUST return <code>UNAUTHENTICATED</code> if the session has no authenticated identity and <code>FORBIDDEN</code> if it has one with an insufficient role. A refused request MUST NOT change any server state.</p>
</div>
<div class="paragraph">
<p><code>HAVE_QUERY</code> requires <code>write</code> because it exists only to support push, and so that anonymous resource use stays bounded.</p>
</div>
</div>
<div class="sect2">
<h3 id="_resource_limits_for_unauthenticated_use">10.8. Resource limits for unauthenticated use</h3>
<div class="paragraph">
<p>A repository that allows anonymous reads can be used by anyone, so the server MUST bound resource use per connection and SHOULD bound it per source address: concurrent connections, bytes sent per period, the number of IDs in one <code>GET_CHUNKS</code> (at most 4096 for any session), the size of one <code>FETCH_SKELETON</code> response, and the time allowed to complete <code>HELLO</code>. The limits SHOULD be configurable by the operator.</p>
</div>
</div>
<div class="sect2">
<h3 id="_audit_log">10.9. Audit log</h3>
<div class="paragraph">
<p>A server SHOULD append to <code>.veins/server.log</code> one line for each connection outcome (time, source address if known, repository, role, key fingerprint or <code>anonymous</code>, and success or error code) and one line for each successful <code>UPDATE_REFS</code> (time, fingerprint, ref name, old and new targets). Logs MUST NOT contain private keys, nonces, or signatures.</p>
</div>
<div class="paragraph">
<p>Authentication identifies the <strong>key that pushed</strong>, not the <strong>author of the commits</strong>. Author and committer fields in commits remain self-asserted. Commit signing is a separate, future feature (see <code>veins-sig</code> in <a href="#sec-commit-obj">Commit objects</a>).</p>
</div>
</div>
<div class="sect2">
<h3 id="_deployment_notes_informative">10.10. Deployment notes (informative)</h3>
<div class="ulist">
<ul>
<li>
<p><strong>Over SSH.</strong> An SSH account that has a shell, or file access to the repository directory, can read and write the store directly and bypass veins' authorization entirely. To enforce read-only access, give users a restricted account whose only permitted command is the server, for example an <code>authorized_keys</code> entry of the form <code>command="vn serve -stdio /srv/veins/project",restrict ssh-ed25519 …​</code>. Then the veins keys, not the SSH accounts, decide each client’s role.</p>
</li>
<li>
<p><strong>Public repositories.</strong> Add <code>anonymous read</code> and serve over the TLS transport. Authenticated keys then matter only for pushing.</p>
</li>
<li>
<p><strong>Revoking a key.</strong> Run <code>vn access remove</code>. If the key was used to push something undesirable, history in the repository can still be rewritten or abandoned by an operator with local access.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_command_line_interface">11. Command-line interface</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The program is <code>vn</code> (<code>vn.exe</code> on Windows). The first column below lists each command as invoked.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 40%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Command</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn init [path] [-git-import:<gitdir>]</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Create a repository, optionally importing an existing git repo.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn clone <url> [-blobs head|none|all]</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Clone via the native protocol.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn status</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Working-copy changes, conflicts, files needing regeneration.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn log [-rev <revset>] [-lN | -fN] [-no-col-titles]</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Show history, newest first, flagging conflicted and divergent changes.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn inf [-inc-gen]</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Show repository, language and author statistics; generated paths are excluded unless <code>-inc-gen</code> is passed.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn show <rev></code>, <code>vn diff [-rev <rev>]</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Display a commit or a diff.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn new [<rev>…​]</code>, <code>vn describe [-message <message>]</code>, <code>vn commit -message <message></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Create and describe changes. <code>vn commit</code> does nothing when the working copy has no changes.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn mv</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Move tracked files, recording renames.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn rm [-delete] <path>…​</code>, <code>vn ex <pattern>…​</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Untrack paths from the working copy (files stay on disk by default), or add ignore patterns to <code>.vnexclude</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn merge <rev>…​</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Create a merge commit. Never fails; may produce conflicts.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn rebase -s <rev> -d <rev></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Rewrite commits onto a new parent, auto-rebasing descendants.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn squash</code>, <code>vn split</code>, <code>vn abandon</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Rewrite or remove changes.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn conflicts [-porcelain]</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">List conflicts with hunk line ranges.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn resolve</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">See <a href="#sec-merge">Merging and conflicts</a>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn regenerate</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Run configured regeneration commands for <code>merge=regenerate</code> paths.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn undo</code>, <code>vn op log</code>, <code>vn op restore <op></code>, <code>vn op revert <op></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Operation log commands.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn bookmark set|list|delete</code>, <code>vn tag set|ls|rm|latest</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Manage named pointers.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn fetch</code>, <code>vn push [<remote>] [<bookmark>]</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Native protocol; <code>push</code> uses the current bookmark when omitted.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn git import [-source:<gitdir>] [path]</code>, <code>vn git export</code>, <code>vn git materialize [path]</code>, <code>vn git fetch</code>, <code>vn git push</code>, <code>vn git remote</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Git bridge.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn serve -stdio <repo></code>, <code>vn serve -listen <addr:port> -root <dir> …​</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Run the native server over stdio or TLS.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn key generate|list|show|import</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Manage client keys.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn access add|list|remove|anonymous</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Manage a served repository’s access file (server side, local only).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn whoami [<remote>]</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Report the role and key fingerprint the server grants.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn fsck [-verbose]</code>, <code>vn repack [-level:<n>]</code>, <code>vn gc</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Verification, pack compaction, and garbage collection.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn config</code>, <code>vn cfg</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read and write configuration.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn help [<command>]</code>, <code>vn -help</code>, <code>vn version</code>, <code>vn -version</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Show usage or version information.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><code>vn cfg</code> reads and writes <code>.veins/config</code> by default. With <code>-global</code>, it edits the user-level <code>~/.local/config/veins/veins.toml</code>. <code>vn cfg <key></code> prints a value, <code>vn cfg <key> <value></code> sets one, <code>vn cfg -unset <key></code> removes one, and <code>vn cfg</code> with no arguments lists the configuration.</p>
</div>
<div class="paragraph">
<p><code>vn co <bookmark></code> and <code>vn bmk set <name></code> set the current bookmark, stored as <code>bookmark.current</code> in local config. <code>vn clone</code> and <code>vn git import</code> initialize it from the default branch (the checked-out or imported <code>HEAD</code>). Snapshots, <code>describe</code>, and <code>go</code> advance the current bookmark, and <code>vn push <remote></code> uses it when no bookmark argument is given.</p>
</div>
<div class="paragraph">
<p><code>vn log</code> prints commits newest first in aligned columns with no borders. Column titles are shown by default and can be omitted with <code>-no-col-titles</code>. <code>-lN</code> limits the output to the last N commits (newest N), while <code>-fN</code> shows the first N commits (oldest N) in oldest-first order. The separated forms <code>-l N</code> and <code>-f N</code>, and the bare forms <code>lN</code> and <code>fN</code>, are also accepted. Output is colored when standard output is a terminal; setting <code>NO_COLOR</code> disables color.</p>
</div>
<div class="paragraph">
<p><code>vn status</code> colors its change markers (<code>A</code> bright green, <code>M</code> cyan, <code>D</code> red, and <code>C</code> bright red). <code>vn diff</code> prints unified hunks with context; removed lines are red and added lines are green.</p>
</div>
<div class="paragraph">
<p>All commands that change state MUST be atomic with respect to the operation log: they either produce one operation or leave the repository unchanged.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-perf">12. Performance requirements</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_reference_workloads">12.1. Reference workloads</h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Workload</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">W1 (synthetic)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A repository of 2,000 revisions of one generated 100,000-line C file (about 4-6 MiB), where each regeneration changes 0.5-5% of lines in scattered locations, plus 200 ordinary source files with normal edit patterns.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">W2 (real)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <code>spectrelang/spectre</code> repository (about 17,700 objects, 228 MiB pack), as measured in the project’s initial investigation: 16.2 s clone from GitHub, about 8.6 s clone from a local <code>file://</code> copy, with roughly 19 CPU-seconds in index-pack.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">W3 (real)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The owner’s largest private project(s) that motivated veins.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_requirements">12.2. Requirements</h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 20%;">
<col style="width: 80%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">ID</th>
<th class="tableblock halign-left valign-top">Requirement</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">P1</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No phase of clone, fetch, or checkout may have cost proportional to delta-chain length. Reading any file at any revision MUST cost O(file size) plus a bounded number of index lookups.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">P2</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">On W1 and W2, a native <code>vn clone</code> over the same local or loopback transport SHOULD be at least 3x faster in wall-clock time than <code>git clone file://</code> of the same history after <code>git gc --aggressive</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">P3</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Clone throughput SHOULD be limited by the transport or disk, not CPU, on a machine with at least 4 cores.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">P4</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Incremental fetch of N new revisions of a large regenerated file SHOULD transfer bytes proportional to the changed chunks.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">P5</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vn status</code> with an unchanged working copy of 100,000 files SHOULD complete within 200 ms (warm cache).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">P6</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Exporting one new commit to git SHOULD complete within 1 s (excluding the network).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">P7</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Checkout of a large file MUST use bounded memory (chunk-sized buffers).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">P8</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Store size on W1 SHOULD be no more than 2x that of the same history in an aggressively repacked git repository. Delta-compressed chunks recover most of git’s delta benefit while preserving random access; bounded chains keep the read cost constant.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><strong>Go/no-go gate.</strong> At milestone M1 (see <a href="#sec-milestones">Milestones</a>), measure P2 on W1 and W2. If veins is less than 2x faster than git on the clone of W1, stop and reconsider the design (or use jj with a tuned git repack) before building further.</p>
</div>
</div>
<div class="sect2">
<h3 id="_measurement_method">12.3. Measurement method</h3>
<div class="paragraph">
<p>Benchmarks MUST be reproducible scripts: pinned inputs, cold and warm cache runs (drop caches between), at least five runs with median and spread reported, and CPU time, wall time, bytes read and written, and peak memory recorded. Baselines for git MUST be run on a freshly repacked server copy so that git’s reuse-of-existing-deltas behavior is accounted for.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_security_considerations">13. Security considerations</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><strong>Hostile repositories.</strong> All data received from the network or from imports MUST be treated as untrusted: verify hashes, enforce canonical form, enforce limits, and refuse names per the rules in <a href="#sec-data">Data model</a>.</p>
</li>
<li>
<p><strong>Decompression bombs.</strong> A record’s declared <code>raw_length</code> MUST be checked against type limits before decompressing, and decompression MUST stop at the declared length.</p>
</li>
<li>
<p><strong>Path attacks.</strong> Checkout MUST NOT write outside the repository root (no <code>..</code>, no absolute paths, no writes through symlinks that point outside, no case-folded <code>.git</code> or <code>.veins</code> components).</p>
</li>
<li>
<p><strong>Code execution.</strong> veins MUST NOT execute commands whose definition comes from tracked or fetched data. Merge tools, regenerate commands, and hooks are read from local config only.</p>
</li>
<li>
<p><strong>Hash function.</strong> BLAKE3 is not known to be vulnerable to collision attacks. Git SHA-1 is only used for export, with collision detection, and a detected collision MUST abort the export.</p>
</li>
<li>
<p><strong>Signatures.</strong> Signature support (<code>veins-sig</code> in <code>extra</code>) is reserved for a future version. Imported <code>gpgsig</code> headers are preserved but not verified by veins.</p>
</li>
<li>
<p><strong>Server.</strong> The server MUST validate every pushed object as described in <a href="#sec-protocol">Native protocol</a>, and rate-limit or bound resource use per connection.</p>
</li>
<li>
<p><strong>Authentication.</strong> Identity is an Ed25519 public key verified by a challenge-response signed over fresh nonces, the repository, the protocol version, and a channel binding. Replay of a captured signature fails because nonces are per-connection. Relay attacks are prevented by channel binding on TLS and by server authentication on SSH. See <a href="#sec-auth">Authentication and authorization</a>.</p>
</li>
<li>
<p><strong>Authorization.</strong> Roles are checked on every request. Write requests need the <code>write</code> role, and a refused request never changes state. Anonymous sessions are read-only. No protocol message modifies the access file.</p>
</li>
<li>
<p><strong>Information disclosure.</strong> An unknown key, a bad signature, and a nonexistent repository are indistinguishable to the client. A <code>read</code> key (or an anonymous session on a public repository) can read all history and all chunks. Secrets that were ever committed remain visible to every reader, and must be rotated rather than removed from history.</p>
</li>
<li>
<p><strong>Denial of service.</strong> Anonymous access exposes read paths to the internet. Servers MUST apply the resource limits in <a href="#sec-auth">Authentication and authorization</a>.</p>
</li>
<li>
<p><strong>Key handling.</strong> Private key files are owner-only and SHOULD be passphrase-protected. Comparisons of secret-dependent values MUST be constant time. Randomness MUST come from the operating system’s secure source.</p>
</li>
<li>
<p><strong>Insecure transports.</strong> Authentication is refused on them, and only anonymous reads are possible. Ref values on such transports are not authenticated.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_implementation_notes_informative">14. Implementation notes (informative)</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This section describes the project owner’s intended implementation language, Spectre, and has no normative weight.</p>
</div>
<div class="sect2">
<h3 id="_required_library_support">14.1. Required library support</h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 40%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Capability</th>
<th class="tableblock halign-left valign-top">Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Threads, mutexes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Exist. Mutex storage MUST be sized for the largest supported platform (aarch64 Linux <code>pthread_mutex_t</code> is 48 bytes), or over-allocated.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Condition variables / semaphores</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Needed for a work-queue thread pool.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">CPU count</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sysconf(_SC_NPROCESSORS_ONLN)</code> on POSIX.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Atomics</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">May require a small C shim. Do not spin on plain variables, because aggressive folding may hoist loads.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">BLAKE3</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Bind the C implementation (with SIMD) through FFI.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">zstd</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Bind through FFI.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">SHA-1 with collision detection</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Bind sha1dc through FFI. Needed for export only.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">File primitives</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>mmap</code>, <code>fsync</code>, atomic <code>rename</code>, <code>openat</code>/<code>O_NOFOLLOW</code>, directory fsync, <code>flock</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Ed25519</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Bind a maintained library (for example libsodium or Monocypher) through FFI. Do not implement it from scratch.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">TLS 1.3</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Bind a maintained TLS library that supports the exporter interface (RFC 5705 / RFC 8446 section 7.5), certificate validation, and pinning.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Secure randomness</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>getrandom</code> / <code>arc4random_buf</code> / <code>BCryptGenRandom</code> for nonces and key generation.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Passphrase KDF and AEAD</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Argon2id and an authenticated cipher for protecting private key files. libsodium provides both.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_structure">14.2. Structure</h3>
<div class="ulist">
<ul>
<li>
<p>Give each worker thread its own arena allocator for hashing and chunking to avoid heap contention.</p>
</li>
<li>
<p>Express codec invariants as contracts, for example postconditions asserting <code>decode(encode(x)) == x</code> and that canonical-form rules hold. Keep <code>trust</code> blocks small and confined to FFI and syscalls.</p>
</li>
<li>
<p>Keep the object format specification and a set of binary test vectors independent of any implementation, so that a second implementation (for example a small reader in another language, for debugging) can be checked against it.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_test_strategy">14.3. Test strategy</h3>
<div class="ulist">
<ul>
<li>
<p><strong>Round trip.</strong> Import a git repository, export it, and compare every SHA-1 (differential test against git). Run on W2, git’s own repository, and a Linux kernel subset.</p>
</li>
<li>
<p><strong>Fuzzing.</strong> Fuzz every decoder (objects, packs, indexes, protocol frames).</p>
</li>
<li>
<p><strong>Crash injection.</strong> Kill the process at random points during writes and verify that <code>vn fsck</code> is clean and the operation log is consistent.</p>
</li>
<li>
<p><strong>Authorization matrix.</strong> For every request type and every session type (anonymous, <code>read</code>, <code>write</code>, revoked key, unauthenticated on a private repository, authenticated attempt on an insecure transport), assert the exact result. Assert that anonymous and <code>read</code> sessions leave the repository byte-for-byte unchanged, including after malformed and oversized requests.</p>
</li>
<li>
<p><strong>Authentication.</strong> Fuzz <code>HELLO</code> and <code>AUTH</code>. Test replay of a captured <code>AUTH</code> on a new connection, wrong repository, wrong channel binding, truncated and malleable signatures, and identical failures for unknown keys and nonexistent repositories (compare bytes and timing).</p>
</li>
<li>
<p><strong>Algebra properties.</strong> Property tests for flatten/cancel/resolve: sum commutativity (up to term order), cancellation idempotence, rebase-then-resolve equivalence.</p>
</li>
<li>
<p><strong>Merge corpus.</strong> Replay historical merges from real repositories and compare outcomes with git’s three-way results. Differences must be explained (adjacency policy, renames).</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sec-milestones">15. Milestones</h2>
<div class="sectionbody">
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 14.2857%;">
<col style="width: 42.8571%;">
<col style="width: 42.8572%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">ID</th>
<th class="tableblock halign-left valign-top">Scope</th>
<th class="tableblock halign-left valign-top">Exit criteria</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">M0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Object codecs, IDs, chunker, pack and index format, <code>fsck</code>, test vectors.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Fuzz-clean. Test vectors published. Chunker deterministic across platforms.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">M1</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Git importer, store, checkout (parallel, bounded memory). Benchmarks on W1, W2.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Go/no-go:</strong> P1 and P2 measured. Import then checkout reproduces git’s working tree byte for byte.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">M2</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Working copy snapshotting, <code>status</code>, <code>log</code>, <code>diff</code>, <code>describe</code>, <code>new</code>, operation log, <code>undo</code>, <code>op restore</code>, git export.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Round-trip SHA invariants hold. Crash-injection tests pass.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">M3</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Conflict algebra, tree merge, file merge, renames, materialization with sidecars, <code>resolve</code>, rebase with auto-rebase, resolution memory.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Algebra property tests pass. Merge corpus replay explained.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">M4</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Git import-back, refs, fetch/push through the mirror, pull request workflow.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A contributor pull request can be imported, merged, and shown as merged on the host.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">M5</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Native protocol: serve over stdio and TLS, authentication and authorization (<code>vn key</code>, <code>vn access</code>, <code>vn whoami</code>, anonymous read), clone, fetch, push, lazy chunks, <code>-blobs</code> policies.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">P3 and P4 measured. Hostile-input tests pass. The authorization matrix tests pass: anonymous and <code>read</code> sessions never mutate the repository, and a revoked key loses access.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">M6</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Path policies (<code>regenerate</code>), gc, pack compaction, operation expiry, polish.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Long-running soak test with gc has no data loss.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect1">
<h2 id="sec-open-questions">16. Open questions</h2>
<div class="sectionbody">
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Working copy model.</strong> Should veins offer a git-like staging mode, or is the auto-snapshot model acceptable for all use? (Section "Working copy".)</p>
</li>
<li>
<p><strong>Line-aware chunking.</strong> Should chunk cut points prefer line boundaries for text files? This may improve diff and merge alignment, but makes the chunker content-type dependent and changes chunk IDs.</p>
</li>
<li>
<p><strong>Chunk parameters.</strong> Is 64 KiB average the best size for generated C? Smaller chunks dedupe better but increase manifest and index overhead. This should be tuned on W1 and W3 before the parameters are frozen.</p>
</li>
<li>
<p><strong>Change-ID header.</strong> Is adding <code>veins-change-id</code> to exported native commits acceptable? It changes the git SHA of every native commit versus an export without it, and some users might consider it noise.</p>
</li>
<li>
<p><strong>Cross-repository identity.</strong> A native commit that is exported and imported into a second repository yields a different veins commit ID than the original. Is that acceptable, or should an optional hashed <code>git_origin</code> field be allowed?</p>
</li>
<li>
<p><strong>Submodules and LFS.</strong> Submodules are preserved opaquely. LFS pointer files are ordinary files, and no LFS support is specified.</p>
</li>
<li>
<p><strong>Case-insensitive file systems.</strong> Need a policy for trees that contain names differing only by case.</p>
</li>
<li>
<p><strong>Windows.</strong> The native design assumes POSIX semantics for checkout safety. Windows support is deferred.</p>
</li>
<li>
<p><strong>Large directories.</strong> Tree objects are flat. Sharding for directories with very many entries is not specified.</p>
</li>
<li>
<p><strong>Structural merge.</strong> A tree-sitter-based layer is a candidate for a post-v1 extension of the file merge stage.</p>
</li>
<li>
<p><strong>Finer-grained access.</strong> Roles beyond <code>read</code> and <code>write</code>, groups, per-bookmark rules, and per-path read restrictions are out of scope for v1. Per-path read restrictions are especially hard because chunks are content-addressed and shared across paths.</p>
</li>
<li>
<p><strong>Repository-wide write protections.</strong> <code>write</code> can currently force-update and delete any ref. Should there be repository-wide settings such as denying non-fast-forward updates or deletions (not per-bookmark)?</p>
</li>
<li>
<p><strong>Key agents and hardware keys.</strong> Support for an ssh-agent-style key agent, or hardware-backed keys, so private keys need not sit on disk.</p>
</li>
<li>
<p><strong>Key lifetime.</strong> Expiry dates on keys, and whether a time-limited key is worth the added file format.</p>
</li>
<li>
<p><strong>Signed refs and commit signing.</strong> Authenticating ref values on insecure transports and attributing commits cryptographically.</p>
</li>
<li>
<p><strong>HTTPS transport.</strong> Whether to add an HTTP/2 transport, which would help with proxies and firewalls and would need its own channel-binding definition.</p>
</li>
<li>
<p><strong>Default TLS port and URL scheme.</strong> No default port is specified for <code>vn serve -listen</code>.</p>
</li>
<li>
<p><strong>Line endings.</strong> No <code>autocrlf</code>-style conversion exists. Users who work on mixed platforms and mirror to git may need a policy.</p>
</li>
</ol>
</div>
</div>
</div>
</div>
<div id="footer">
<div id="footer-text">
Version 0.1-draft<br>
Last updated 2026-11-28 19:16:07 UTC
</div>
</div>
</body>
</html>