Skip to content

Commit 9c0ea77

Browse files
committed
no-mistakes(review): Reject incomplete Lavish decision forms and answers
1 parent 9ad0f57 commit 9c0ea77

2 files changed

Lines changed: 39 additions & 14 deletions

File tree

.agents/skills/lavish-decision-boards/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ A read-only status page is not a decision surface.
5555
- Never rely on poll output or conversation memory as the only copy because ephemeral poll output can be reaped.
5656
- Treat a `lavish-axi poll` return as transport or lifecycle output, not automatically as the captain's answer.
5757
- Act only after genuine connection and receipt of one unambiguous batch with `submission: "explicit-send-batch"`, a nonempty structured `answers` array, and a manifest containing `expectedQuestionKeys` and `expectedCount`.
58-
- Accept the batch only when the manifest keys are nonempty and unique, its count equals its key count, the answer keys are nonempty and unique, and the answer-key set exactly equals the manifest-key set.
59-
- Disconnects, UI flicker, re-polls, layout or audit returns, session events, and empty, partial, subset, missing-answer, unmarked, or ambiguous payloads are not submissions; ignore them and keep waiting.
58+
- Accept the batch only when the manifest keys are nonempty and unique, its count equals its key count, and every manifest key has exactly one structured answer entry with the same key and a nonempty `answer` value.
59+
- Reject absent, empty, extra, or duplicate answer keys, every manifest mismatch, and every disconnect, UI flicker, re-poll, layout or audit return, session event, unmarked return, or ambiguous return; ignore them and keep waiting.
6060
- If a return is ambiguous or lacks a clear explicit-decision payload, treat it as not submitted and do not act until the captain's actual answer is verified in the payload.

.agents/skills/lavish-decision-boards/assets/lavish-board-template.html

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
form.q label:has(input:checked){border-color:var(--accent);background:var(--accent-soft)}
7676
form.q input[type=radio]{margin-top:2px;accent-color:var(--accent);width:16px;height:16px;flex:none}
7777
.selection-status{font-size:13px;color:var(--ink-2);margin:0 0 10px;min-height:20px}
78+
.submission-status{font-size:13px;color:var(--red);margin:10px 0 0;min-height:20px}
7879
button{font-family:inherit;font-size:13.5px;font-weight:650;border-radius:9px;cursor:pointer;border:1px solid var(--accent);background:var(--accent);color:#fff;padding:8px 15px}
7980
</style>
8081
</head>
@@ -98,11 +99,17 @@ <h3>What should be decided?</h3>
9899
</div>
99100

100101
<button type="button" data-send-answers onclick="sendAnswers()">Send answers</button>
102+
<p class="submission-status" data-submission-status role="alert" aria-live="assertive"></p>
101103
</div>
102104
<script>
103-
document.querySelectorAll('form[data-lavish-question]').forEach(function(form){
105+
document.querySelectorAll('form.q').forEach(function(form){
104106
form.addEventListener('change',function(){
105-
var key=form.dataset.lavishQuestion;
107+
var key=(form.dataset.lavishQuestion||'').trim();
108+
if(!key){
109+
form.querySelector('[data-selection-status]').textContent=
110+
'Configuration error: add a unique data-lavish-question value to this decision form.';
111+
return;
112+
}
106113
var choice=new FormData(form).get(key);
107114
form.querySelector('[data-selection-status]').textContent=
108115
choice?'Selected locally (not sent): '+choice:'No answer selected.';
@@ -112,25 +119,43 @@ <h3>What should be decided?</h3>
112119
var submissionInFlight=false;
113120

114121
function sendAnswers(){
115-
var forms=Array.from(document.querySelectorAll('form[data-lavish-question]'));
122+
var forms=Array.from(document.querySelectorAll('form.q'));
116123
var answers=[];
117124
var firstIncomplete=null;
118125
var sendButton=document.querySelector('[data-send-answers]');
126+
var submissionStatus=document.querySelector('[data-submission-status]');
119127
if(submissionInFlight)return;
120-
forms.forEach(function(form){
121-
var key=form.dataset.lavishQuestion;
128+
function failConfiguration(message){
129+
sendButton.disabled=true;
130+
sendButton.textContent='Cannot send answers';
131+
submissionStatus.textContent=message;
132+
}
133+
if(!forms.length){
134+
failConfiguration('Configuration error: add at least one decision form before serving this board.');
135+
return;
136+
}
137+
var keyedForms=forms.map(function(form,index){
138+
return {form:form,key:(form.dataset.lavishQuestion||'').trim(),index:index};
139+
});
140+
var missingKey=keyedForms.find(function(item){return !item.key;});
141+
if(missingKey){
142+
failConfiguration('Configuration error: decision form '+(missingKey.index+1)+' needs a unique nonempty data-lavish-question value.');
143+
return;
144+
}
145+
var expectedQuestionKeys=keyedForms.map(function(item){return item.key;});
146+
var uniqueQuestionKeys=new Set(expectedQuestionKeys);
147+
if(uniqueQuestionKeys.size!==expectedQuestionKeys.length){
148+
failConfiguration('Configuration error: every decision form needs a unique data-lavish-question value.');
149+
return;
150+
}
151+
keyedForms.forEach(function(item){
152+
var form=item.form;
153+
var key=item.key;
122154
var choice=new FormData(form).get(key);
123155
if(!choice){firstIncomplete=firstIncomplete||form;return;}
124156
answers.push({key:key,label:form.dataset.lavishLabel||key,answer:choice});
125157
});
126158
if(firstIncomplete){firstIncomplete.reportValidity();return;}
127-
var expectedQuestionKeys=answers.map(function(answer){return answer.key;});
128-
var uniqueQuestionKeys=new Set(expectedQuestionKeys);
129-
if(!answers.length||expectedQuestionKeys.some(function(key){return !key;})||uniqueQuestionKeys.size!==expectedQuestionKeys.length){
130-
sendButton.disabled=true;
131-
sendButton.textContent='Board configuration error';
132-
return;
133-
}
134159
if(!window.lavish||!window.lavish.queuePrompt||!window.lavish.sendQueuedPrompts)return;
135160
var batch={
136161
submission:'explicit-send-batch',

0 commit comments

Comments
 (0)